Documentation ¶
Overview ¶
Package omgrpc provides helpers to track grpc/openmetrics.
Index ¶
- func InstrumentActiveConns(m openmetrics.GaugeFamily) stats.Handler
- func InstrumentCallCount(m openmetrics.CounterFamily) stats.Handler
- func InstrumentCallDuration(m openmetrics.HistogramFamily) stats.Handler
- type CallStats
- type CallStatsHandler
- func (h CallStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats)
- func (h CallStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h CallStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h CallStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ConnStats
- type ConnStatsHandler
- func (h ConnStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats)
- func (h ConnStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h ConnStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h ConnStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ConnStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstrumentActiveConns ¶
func InstrumentActiveConns(m openmetrics.GaugeFamily) stats.Handler
InstrumentActiveConns returns default stats.Handler to instrument number of active gRPC connections. It populates no labels.
func InstrumentCallCount ¶
func InstrumentCallCount(m openmetrics.CounterFamily) stats.Handler
InstrumentCallCount returns default stats.Handler to instrument RPC call count. It populates labels it can recognize and leaves others empty:
- "method" - full method name like "/com.package/MethodName"
- "status" or "code" - populated with gRPC code string: https://pkg.go.dev/google.golang.org/grpc/codes#Code
func InstrumentCallDuration ¶
func InstrumentCallDuration(m openmetrics.HistogramFamily) stats.Handler
InstrumentCallDuration returns default stats.Handler to instrument RPC call duration in units configured for metric. It populates labels it can recognize and leaves others empty:
- "method" - full method name like "/com.package/MethodName"
- "status" or "code" - populated with gRPC code string: https://pkg.go.dev/google.golang.org/grpc/codes#Code
Types ¶
type CallStats ¶
type CallStats struct { IsClient bool // indicates client-side stats FailFast bool // only valid for client FullMethodName string IsClientStream, IsServerStream bool BeginTime, EndTime time.Time InHeader, InTrailer metadata.MD OutHeader, OutTrailer metadata.MD LocalAddr, RemoteAddr net.Addr BytesRecv, BytesSent int Error error // RPC call error, can be examined with s, _ := grpc/status.FromError(err); s.Code() }
CallStats holds all the RPC call-related data that can be collected by stats handler.
type CallStatsHandler ¶
type CallStatsHandler func(*CallStats)
CallStatsHandler implements https://pkg.go.dev/google.golang.org/grpc/stats#Handler for RPC calls. CallStats argument is reused (pooled), so pointer cannot be stored - copy instead.
It assumes that stats.Handler methods are never called concurrently.
func (CallStatsHandler) HandleConn ¶
func (h CallStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats)
HandleConn implements grpc/stats.Handler interface and does nothing.
func (CallStatsHandler) HandleRPC ¶
func (h CallStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC processes the RPC stats.
func (CallStatsHandler) TagConn ¶
func (h CallStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
TagConn implements grpc/stats.Handler interface and does nothing.
func (CallStatsHandler) TagRPC ¶
func (h CallStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
TagRPC attaches omgrpc-internal data to RPC context.
type ConnStats ¶
type ConnStats struct { IsClient bool // indicates client-side stats Status ConnStatus LocalAddr, RemoteAddr net.Addr BytesRecv, BytesSent int // supported only for server side, only when Connected=false }
ConnStats holds connection stats.
type ConnStatsHandler ¶
type ConnStatsHandler func(*ConnStats)
ConnStatsHandler implements https://pkg.go.dev/google.golang.org/grpc/stats#Handler for RPC connections. ConnStats argument is reused (pooled), so pointer cannot be stored - copy instead.
It assumes that stats.Handler methods are never called concurrently.
func (ConnStatsHandler) HandleConn ¶
func (h ConnStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats)
TagRPC attaches omgrpc-internal data to connection context.
func (ConnStatsHandler) HandleRPC ¶
func (h ConnStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
TagConn tracks server-side
func (ConnStatsHandler) TagConn ¶
func (h ConnStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
TagRPC attaches omgrpc-internal data to connection context.
func (ConnStatsHandler) TagRPC ¶
func (h ConnStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
TagConn implements grpc/stats.Handler interface and does nothing.
type ConnStatus ¶
type ConnStatus int8
ConnStatus holds connection status.
const ( Connected ConnStatus = iota Disconnected )