Documentation ¶
Index ¶
- Constants
- Variables
- func EnableClientHandledTimeHistogram(opts ...metric.InstrumentOption) error
- func EnableClientStreamReceiveSizeHistogram(opts ...metric.InstrumentOption) error
- func EnableClientStreamReceiveTimeHistogram(opts ...metric.InstrumentOption) error
- func EnableClientStreamSendSizeHistogram(opts ...metric.InstrumentOption) error
- func EnableClientStreamSendTimeHistogram(opts ...metric.InstrumentOption) error
- func EnableServerHandledTimeHistogram(opts ...metric.Float64HistogramOption) error
- func EnableServerStreamReceiveSizeHistogram(opts ...metric.Int64HistogramOption) error
- func EnableServerStreamReceiveTimeHistogram(opts ...metric.Float64HistogramOption) error
- func EnableServerStreamSendSizeHistogram(opts ...metric.Int64HistogramOption) error
- func EnableServerStreamSendTimeHistogram(opts ...metric.Float64HistogramOption) error
- func FromError(err error) (s *status.Status, ok bool)
- func Meter() metric.Meter
- func Register(ctx context.Context, server *grpc.Server)
- func ResetClientCounter(opts ...metric.InstrumentOption) error
- func ResetServerCounter(opts ...metric.InstrumentOption) error
- type ClientMetrics
- func (m *ClientMetrics) EnableClientHandledTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
- func (m *ClientMetrics) EnableClientStreamReceiveSizeHistogram(opts ...metric.Int64HistogramOption) (err error)
- func (m *ClientMetrics) EnableClientStreamReceiveTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
- func (m *ClientMetrics) EnableClientStreamSendSizeHistogram(opts ...metric.Int64HistogramOption) (err error)
- func (m *ClientMetrics) EnableClientStreamSendTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
- func (m *ClientMetrics) ResetCounter(opts ...metric.InstrumentOption) (err error)
- func (m *ClientMetrics) StreamClientInterceptor() ...
- func (m *ClientMetrics) UnaryClientInterceptor() func(ctx context.Context, method string, req, reply interface{}, ...) error
- type ServerMetrics
- func (m *ServerMetrics) EnableServerHandledTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
- func (m *ServerMetrics) EnableServerStreamReceiveSizeHistogram(opts ...metric.Int64HistogramOption) (err error)
- func (m *ServerMetrics) EnableServerStreamReceiveTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
- func (m *ServerMetrics) EnableServerStreamSendSizeHistogram(opts ...metric.Int64HistogramOption) (err error)
- func (m *ServerMetrics) EnableServerStreamSendTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
- func (m *ServerMetrics) InitializeMetrics(ctx context.Context, server *grpc.Server)
- func (m *ServerMetrics) ResetCounter(opts ...metric.InstrumentOption) (err error)
- func (m *ServerMetrics) StreamServerInterceptor() ...
- func (m *ServerMetrics) UnaryServerInterceptor() ...
Constants ¶
const ( Unary grpcType = "unary" ClientStream grpcType = "client_stream" ServerStream grpcType = "server_stream" BidiStream grpcType = "bidi_stream" )
const ( // GRPCTypeKey is convention for grpc type of gRPC connection. GRPCTypeKey = attribute.Key("rpc.grpc.type") )
Variables ¶
var ( // DefaultClientMetrics is the default instance of ClientMetrics. It is // intended to be used in conjunction the default Prometheus metrics // registry. DefaultClientMetrics = NewClientMetrics() // UnaryClientMetricInterceptor is a gRPC client-side interceptor that provides Metric monitoring for Unary RPCs. UnaryClientMetricInterceptor = DefaultClientMetrics.UnaryClientInterceptor() // StreamClientMetricInterceptor is a gRPC client-side interceptor that provides Metric monitoring for Streaming RPCs. StreamClientMetricInterceptor = DefaultClientMetrics.StreamClientInterceptor() )
var ( // InstrumentationName is the name of this instrumentation package. InstrumentationName = "" /* 137-byte string literal not displayed */ // InstrumentationVersion is the version of this instrumentation package. InstrumentationVersion = otelcontrib.Version() // AttrsFilter is a filter before Report AttrsFilter = func(attrs ...attribute.KeyValue) []attribute.KeyValue { return attrs } )
var ( // DefaultServerMetrics is the default instance of ServerMetrics. It is // intended to be used in conjunction the default Prometheus metrics // registry. DefaultServerMetrics = NewServerMetrics() // UnaryServerMetricInterceptor is a gRPC server-side interceptor that provides Metric monitoring for Unary RPCs. UnaryServerMetricInterceptor = DefaultServerMetrics.UnaryServerInterceptor() // StreamServerMetricInterceptor is a gRPC server-side interceptor that provides Metric monitoring for Streaming RPCs. StreamServerMetricInterceptor = DefaultServerMetrics.StreamServerInterceptor() )
Functions ¶
func EnableClientHandledTimeHistogram ¶
func EnableClientHandledTimeHistogram(opts ...metric.InstrumentOption) error
EnableClientHandledTimeHistogram turns on recording of handling time of RPCs. Histogram metrics can be very expensive for Prometheus to retain and query. This function acts on the DefaultClientMetrics variable.
func EnableClientStreamReceiveSizeHistogram ¶
func EnableClientStreamReceiveSizeHistogram(opts ...metric.InstrumentOption) error
EnableClientStreamReceiveSizeHistogram turns on recording of single message receive size of streaming RPCs. This function acts on the DefaultClientMetrics variable
func EnableClientStreamReceiveTimeHistogram ¶
func EnableClientStreamReceiveTimeHistogram(opts ...metric.InstrumentOption) error
EnableClientStreamReceiveTimeHistogram turns on recording of single message receive time of streaming RPCs. This function acts on the DefaultClientMetrics variable.
func EnableClientStreamSendSizeHistogram ¶
func EnableClientStreamSendSizeHistogram(opts ...metric.InstrumentOption) error
EnableClientStreamSendSizeHistogram turns on recording of single message receive size of streaming RPCs. This function acts on the DefaultClientMetrics variable
func EnableClientStreamSendTimeHistogram ¶
func EnableClientStreamSendTimeHistogram(opts ...metric.InstrumentOption) error
EnableClientStreamSendTimeHistogram turns on recording of single message send time of streaming RPCs. This function acts on the DefaultClientMetrics variable.
func EnableServerHandledTimeHistogram ¶
func EnableServerHandledTimeHistogram(opts ...metric.Float64HistogramOption) error
EnableServerHandledTimeHistogram turns on recording of handling time of RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func EnableServerStreamReceiveSizeHistogram ¶
func EnableServerStreamReceiveSizeHistogram(opts ...metric.Int64HistogramOption) error
EnableServerStreamReceiveSizeHistogram turns on recording of single message receive size of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func EnableServerStreamReceiveTimeHistogram ¶
func EnableServerStreamReceiveTimeHistogram(opts ...metric.Float64HistogramOption) error
EnableServerStreamReceiveTimeHistogram turns on recording of single message receive time of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func EnableServerStreamSendSizeHistogram ¶
func EnableServerStreamSendSizeHistogram(opts ...metric.Int64HistogramOption) error
EnableServerStreamSendSizeHistogram turns on recording of single message send size of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func EnableServerStreamSendTimeHistogram ¶
func EnableServerStreamSendTimeHistogram(opts ...metric.Float64HistogramOption) error
EnableServerStreamSendTimeHistogram turns on recording of single message send time of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func FromError ¶
FromError Since error can be wrapped and the `FromError` function only checks for `GRPCStatus` function and as a fallback uses the `Unknown` gRPC status we need to unwrap the error if possible to get the original status. pkg/errors and Go native errors packages have two different approaches so we try to unwrap both types. Eventually should be implemented in the go-grpc status function `FromError`. See https://github.com/grpc/grpc-go/issues/2934
func Register ¶
Register takes a gRPC server and pre-initializes all counters to 0. This allows for easier monitoring in Prometheus (no missing metrics), and should be called *after* all services have been registered with the server. This function acts on the DefaultServerMetrics variable.
func ResetClientCounter ¶
func ResetClientCounter(opts ...metric.InstrumentOption) error
ResetClientCounter recreate recording of all counters of RPCs. This function acts on the DefaultClientMetrics variable.
func ResetServerCounter ¶
func ResetServerCounter(opts ...metric.InstrumentOption) error
ResetServerCounter recreate recording of all counters of RPCs. This function acts on the DefaultServerMetrics variable.
Types ¶
type ClientMetrics ¶
type ClientMetrics struct { ClientHostport string // contains filtered or unexported fields }
ClientMetrics represents a collection of metrics to be registered on a Prometheus metrics registry for a gRPC client.
func NewClientMetrics ¶
func NewClientMetrics(opts ...metric.InstrumentOption) *ClientMetrics
NewClientMetrics returns a ClientMetrics object. Use a new instance of ClientMetrics when not using the default Prometheus metrics registry, for example when wanting to control which metrics are added to a registry as opposed to automatically adding metrics via init functions.
func (*ClientMetrics) EnableClientHandledTimeHistogram ¶
func (m *ClientMetrics) EnableClientHandledTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
EnableClientHandledTimeHistogram turns on recording of handling time of RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ClientMetrics) EnableClientStreamReceiveSizeHistogram ¶
func (m *ClientMetrics) EnableClientStreamReceiveSizeHistogram(opts ...metric.Int64HistogramOption) (err error)
EnableClientStreamReceiveSizeHistogram turns on recording of single message receive size of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ClientMetrics) EnableClientStreamReceiveTimeHistogram ¶
func (m *ClientMetrics) EnableClientStreamReceiveTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
EnableClientStreamReceiveTimeHistogram turns on recording of single message receive time of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ClientMetrics) EnableClientStreamSendSizeHistogram ¶
func (m *ClientMetrics) EnableClientStreamSendSizeHistogram(opts ...metric.Int64HistogramOption) (err error)
EnableClientStreamSendSizeHistogram turns on recording of single message send size of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ClientMetrics) EnableClientStreamSendTimeHistogram ¶
func (m *ClientMetrics) EnableClientStreamSendTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
EnableClientStreamSendTimeHistogram turns on recording of single message send time of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ClientMetrics) ResetCounter ¶
func (m *ClientMetrics) ResetCounter(opts ...metric.InstrumentOption) (err error)
ResetCounter recreate recording of all counters of RPCs.
func (*ClientMetrics) StreamClientInterceptor ¶
func (m *ClientMetrics) StreamClientInterceptor() func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error)
StreamClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Streaming RPCs.
func (*ClientMetrics) UnaryClientInterceptor ¶
func (m *ClientMetrics) UnaryClientInterceptor() func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
UnaryClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Unary RPCs.
type ServerMetrics ¶
type ServerMetrics struct { ServerHostport string // contains filtered or unexported fields }
ServerMetrics represents a collection of metrics to be registered on a Prometheus metrics registry for a gRPC server.
func NewServerMetrics ¶
func NewServerMetrics(opts ...metric.InstrumentOption) *ServerMetrics
NewServerMetrics returns a ServerMetrics object. Use a new instance of ServerMetrics when not using the default Prometheus metrics registry, for example when wanting to control which metrics are added to a registry as opposed to automatically adding metrics via init functions.
func (*ServerMetrics) EnableServerHandledTimeHistogram ¶
func (m *ServerMetrics) EnableServerHandledTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
EnableServerHandledTimeHistogram turns on recording of handling time of RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ServerMetrics) EnableServerStreamReceiveSizeHistogram ¶
func (m *ServerMetrics) EnableServerStreamReceiveSizeHistogram(opts ...metric.Int64HistogramOption) (err error)
EnableServerStreamReceiveSizeHistogram turns on recording of single message receive size of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ServerMetrics) EnableServerStreamReceiveTimeHistogram ¶
func (m *ServerMetrics) EnableServerStreamReceiveTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
EnableServerStreamReceiveTimeHistogram turns on recording of single message receive time of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ServerMetrics) EnableServerStreamSendSizeHistogram ¶
func (m *ServerMetrics) EnableServerStreamSendSizeHistogram(opts ...metric.Int64HistogramOption) (err error)
EnableServerStreamSendSizeHistogram turns on recording of single message send size of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ServerMetrics) EnableServerStreamSendTimeHistogram ¶
func (m *ServerMetrics) EnableServerStreamSendTimeHistogram(opts ...metric.Float64HistogramOption) (err error)
EnableServerStreamSendTimeHistogram turns on recording of single message send time of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ServerMetrics) InitializeMetrics ¶
func (m *ServerMetrics) InitializeMetrics(ctx context.Context, server *grpc.Server)
InitializeMetrics initializes all metrics, with their appropriate null value, for all gRPC methods registered on a gRPC server. This is useful, to ensure that all metrics exist when collecting and querying.
func (*ServerMetrics) ResetCounter ¶
func (m *ServerMetrics) ResetCounter(opts ...metric.InstrumentOption) (err error)
ResetCounter recreate recording of all counters of RPCs.
func (*ServerMetrics) StreamServerInterceptor ¶
func (m *ServerMetrics) StreamServerInterceptor() func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error
StreamServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs.
func (*ServerMetrics) UnaryServerInterceptor ¶
func (m *ServerMetrics) UnaryServerInterceptor() func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
UnaryServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Unary RPCs.