package stats
Import Path
google.golang.org/grpc/stats (on go.dev)
Dependency Relation
imports 5 packages, and imported by 4 packages
Involved Source Files
handlers.go
metrics.go
Package stats is for collecting and reporting various network and RPC stats.
This package is for monitoring purpose only. All fields are read-only.
All APIs are experimental.
Package-Level Type Names (total 18, all are exported)
Begin contains stats for the start of an RPC attempt.
- Server-side: Triggered after `InHeader`, as headers are processed
before the RPC lifecycle begins.
- Client-side: The first stats event recorded.
FailFast is only valid if this Begin is from client side.
BeginTime is the time when the RPC attempt begins.
Client is true if this Begin is from client side.
FailFast indicates if this RPC is failfast.
IsClientStream indicates whether the RPC is a client streaming RPC.
IsServerStream indicates whether the RPC is a server streaming RPC.
IsTransparentRetryAttempt indicates whether this attempt was initiated
due to transparently retrying a previous attempt.
IsClient indicates if the stats information is from client side.
(*Begin) isRPCStats()
*Begin : RPCStats
ConnBegin contains stats about connection establishment.
Client is true if this ConnBegin is from client side.
IsClient indicates if this is from client side.
(*ConnBegin) isConnStats()
*ConnBegin : ConnStats
ConnEnd contains stats about connection termination.
Client is true if this ConnBegin is from client side.
IsClient indicates if this is from client side.
(*ConnEnd) isConnStats()
*ConnEnd : ConnStats
ConnStats contains stats information about connections.
IsClient returns true if this ConnStats is from client side.
( ConnStats) isConnStats()
*ConnBegin
*ConnEnd
func Handler.HandleConn(context.Context, ConnStats)
ConnTagInfo defines the relevant information needed by connection context tagger.
LocalAddr is the local address of the corresponding connection.
RemoteAddr is the remote address of the corresponding connection.
func Handler.TagConn(context.Context, *ConnTagInfo) context.Context
DelayedPickComplete indicates that the RPC is unblocked following a delay in
selecting a connection for the call.
IsClient indicates DelayedPickComplete is available on the client.
(*DelayedPickComplete) isRPCStats()
*DelayedPickComplete : RPCStats
End contains stats about RPC completion.
BeginTime is the time when the RPC began.
Client is true if this End is from client side.
EndTime is the time when the RPC ends.
Error is the error the RPC ended with. It is an error generated from
status.Status and can be converted back to status.Status using
status.FromError if non-nil.
Trailer contains the trailer metadata received from the server. This
field is only valid if this End is from the client side.
Deprecated: use Trailer in InTrailer instead.
IsClient indicates if this is from client side.
(*End) isRPCStats()
*End : RPCStats
Handler defines the interface for the related stats handling (e.g., RPCs, connections).
HandleConn processes the Conn stats.
HandleRPC processes the RPC stats.
TagConn can attach some information to the given context.
The returned context will be used for stats handling.
For conn stats handling, the context used in HandleConn for this
connection will be derived from the context returned.
For RPC stats handling,
- On server side, the context used in HandleRPC for all RPCs on this
connection will be derived from the context returned.
- On client side, the context is not derived from the context returned.
TagRPC can attach some information to the given context.
The context used for the rest lifetime of the RPC will be derived from
the returned context.
func google.golang.org/grpc.StatsHandler(h Handler) grpc.ServerOption
func google.golang.org/grpc.WithStatsHandler(h Handler) grpc.DialOption
func google.golang.org/grpc/internal/stats.NewMetricsRecorderList(shs []Handler) *stats.MetricsRecorderList
func google.golang.org/grpc/internal/transport.NewServerHandlerTransport(w http.ResponseWriter, r *http.Request, stats []Handler, bufferPool mem.BufferPool) (transport.ServerTransport, error)
InHeader contains stats about header reception.
- Server-side: The first stats event after the RPC request is received.
Client is true if this InHeader is from client side.
Compression is the compression algorithm used for the RPC.
The following fields are valid only if Client is false.
FullMethod is the full RPC method string, i.e., /package.service/method.
Header contains the header metadata received.
LocalAddr is the local address of the corresponding connection.
RemoteAddr is the remote address of the corresponding connection.
WireLength is the wire length of header.
IsClient indicates if the stats information is from client side.
(*InHeader) isRPCStats()
*InHeader : RPCStats
InPayload contains stats about an incoming payload.
Client is true if this InPayload is from client side.
CompressedLength is the size of the compressed payload data. Does not
include any framing (gRPC or HTTP/2). Same as Length if compression not
enabled.
Length is the size of the uncompressed payload data. Does not include any
framing (gRPC or HTTP/2).
Payload is the payload with original type. This may be modified after
the call to HandleRPC which provides the InPayload returns and must be
copied if needed later.
RecvTime is the time when the payload is received.
WireLength is the size of the compressed payload data plus gRPC framing.
Does not include HTTP/2 framing.
IsClient indicates if the stats information is from client side.
(*InPayload) isRPCStats()
*InPayload : RPCStats
InTrailer contains stats about trailer reception.
Client is true if this InTrailer is from client side.
Trailer contains the trailer metadata received from the server. This
field is only valid if this InTrailer is from the client side.
WireLength is the wire length of trailer.
IsClient indicates if the stats information is from client side.
(*InTrailer) isRPCStats()
*InTrailer : RPCStats
MetricSet is a set of metrics to record. Once created, MetricSet is immutable,
however Add and Remove can make copies with specific metrics added or
removed, respectively.
Do not construct directly; use NewMetricSet instead.
metrics are the set of metrics to initialize.
Add adds the metricNames to the metrics set and returns a new copy with the
additional metrics.
Join joins the metrics passed in with the metrics set, and returns a new copy
with the merged metrics.
Metrics returns the metrics set. The returned map is read-only and must not
be modified.
Remove removes the metricNames from the metrics set and returns a new copy
with the metrics removed.
func NewMetricSet(metricNames ...string) *MetricSet
func (*MetricSet).Add(metricNames ...string) *MetricSet
func (*MetricSet).Join(metrics *MetricSet) *MetricSet
func (*MetricSet).Remove(metricNames ...string) *MetricSet
func google.golang.org/grpc/experimental/stats.NewMetrics(metrics ...stats.Metric) *stats.Metrics
func (*MetricSet).Join(metrics *MetricSet) *MetricSet
var google.golang.org/grpc/experimental/stats.DefaultMetrics *MetricSet
OutHeader contains stats about header transmission.
- Client-side: Only occurs after 'Begin', as headers are always the first
thing sent on a stream.
Client is true if this OutHeader is from client side.
Compression is the compression algorithm used for the RPC.
The following fields are valid only if Client is true.
FullMethod is the full RPC method string, i.e., /package.service/method.
Header contains the header metadata sent.
LocalAddr is the local address of the corresponding connection.
RemoteAddr is the remote address of the corresponding connection.
IsClient indicates if this stats information is from client side.
(*OutHeader) isRPCStats()
*OutHeader : RPCStats
OutPayload contains stats about an outgoing payload.
Client is true if this OutPayload is from client side.
CompressedLength is the size of the compressed payload data. Does not
include any framing (gRPC or HTTP/2). Same as Length if compression not
enabled.
Length is the size of the uncompressed payload data. Does not include any
framing (gRPC or HTTP/2).
Payload is the payload with original type. This may be modified after
the call to HandleRPC which provides the OutPayload returns and must be
copied if needed later.
SentTime is the time when the payload is sent.
WireLength is the size of the compressed payload data plus gRPC framing.
Does not include HTTP/2 framing.
IsClient indicates if this stats information is from client side.
(*OutPayload) isRPCStats()
*OutPayload : RPCStats
func google.golang.org/grpc.outPayload(client bool, msg any, dataLength, payloadLength int, t time.Time) *OutPayload
OutTrailer contains stats about trailer transmission.
Client is true if this InTrailer is from client side.
Trailer contains the trailer metadata received from the server. This
field is only valid if this InTrailer is from the client side.
WireLength is the wire length of trailer.
IsClient indicates if this stats information is from client side.
(*OutTrailer) isRPCStats()
*OutTrailer : RPCStats
PickerUpdated indicates that the RPC is unblocked following a delay in
selecting a connection for the call.
Deprecated: will be removed in a future release; use DelayedPickComplete
instead.
RPCStats contains stats information about RPCs.
IsClient returns true if this RPCStats is from client side.
( RPCStats) isRPCStats()
*Begin
*DelayedPickComplete
*End
*InHeader
*InPayload
*InTrailer
*OutHeader
*OutPayload
*OutTrailer
func Handler.HandleRPC(context.Context, RPCStats)
RPCTagInfo defines the relevant information needed by RPC context tagger.
FailFast indicates if this RPC is failfast.
This field is only valid on client side, it's always false on server side.
FullMethodName is the RPC method in the format of /package.service/method.
NameResolutionDelay indicates if the RPC needed to wait for the
initial name resolver update before it could begin. This should only
happen if the channel is IDLE when the RPC is started. Note that
all retry or hedging attempts for an RPC that experienced a delay
will have it set.
This field is only valid on the client side; it is always false on
the server side.
func Handler.TagRPC(context.Context, *RPCTagInfo) context.Context
Package-Level Functions (total 5, all are exported)
NewMetricSet returns a MetricSet containing metricNames.
SetTags attaches stats tagging data to the context, which will be sent in
the outgoing RPC with the header grpc-tags-bin. Subsequent calls to
SetTags will overwrite the values from earlier calls.
Deprecated: set the `grpc-tags-bin` header in the metadata instead.
SetTrace attaches stats tagging data to the context, which will be sent in
the outgoing RPC with the header grpc-trace-bin. Subsequent calls to
SetTrace will overwrite the values from earlier calls.
Deprecated: set the `grpc-trace-bin` header in the metadata instead.
Tags returns the tags from the context for the inbound RPC.
Deprecated: obtain the `grpc-tags-bin` header from metadata instead.
Trace returns the trace from the context for the inbound RPC.
Deprecated: obtain the `grpc-trace-bin` header from metadata instead.
The pages are generated with Golds v0.7.6. (GOOS=linux GOARCH=amd64)