Documentation ¶
Index ¶
- Constants
- Variables
- func EnableClientHandlingTimeHistogram(opts ...HistogramOption)
- func EnableClientStreamReceiveTimeHistogram(opts ...HistogramOption)
- func EnableClientStreamSendTimeHistogram(opts ...HistogramOption)
- func EnableHandlingTimeHistogram(opts ...HistogramOption)
- func RegisterClient(server *grpc.Server, opts ...Option)
- func RegisterServer(server *grpc.Server, opts ...Option)
- type BloomFilter
- type ClientMetrics
- func (m *ClientMetrics) Collect(ch chan<- prom.Metric)
- func (m *ClientMetrics) Describe(ch chan<- *prom.Desc)
- func (m *ClientMetrics) EnableClientHandlingTimeHistogram(opts ...HistogramOption)
- func (m *ClientMetrics) EnableClientStreamReceiveTimeHistogram(opts ...HistogramOption)
- func (m *ClientMetrics) EnableClientStreamSendTimeHistogram(opts ...HistogramOption)
- func (m *ClientMetrics) StreamClientInterceptor() ...
- func (m *ClientMetrics) UnaryClientInterceptor() func(ctx context.Context, method string, req, reply interface{}, ...) error
- type CounterOption
- type HistogramOption
- type Option
- func WithCounterOption(counterOpts []CounterOption) Option
- func WithDuration(duration []float64) Option
- func WithEndpointLabelMappingFn(endpointLabelMappingFn RequestLabelMappingFn) Option
- func WithExcludeRegexCode(excludeRegexCode []string) Option
- func WithExcludeRegexMethodName(excludeRegexMethodName []string) Option
- func WithExcludeRegexRegexServiceName(excludeRegexServiceName []string) Option
- func WithExcludeRegexRpcType(excludeRegexRpcType []string) Option
- func WithHandlerUrl(handlerUrl string) Option
- func WithName(name string) Option
- func WithNamespace(namespace string) Option
- func WithPromHandler(r *http.ServeMux) Option
- func WithSlowTime(slowTime float64) Option
- type RequestLabelMappingFn
- type ServerMetrics
- func (m *ServerMetrics) Collect(ch chan<- prom.Metric)
- func (m *ServerMetrics) Describe(ch chan<- *prom.Desc)
- func (m *ServerMetrics) EnableHandlingTimeHistogram(opts ...HistogramOption)
- func (m *ServerMetrics) InitializeMetrics(server *grpc.Server)
- 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" )
Variables ¶
var ( // DefaultClientMetrics is the default instance of ClientMetrics. It is // intended to be used in conjunction the default Prometheus metrics // registry. DefaultClientMetrics *ClientMetrics // UnaryClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Unary RPCs. UnaryClientInterceptor func(ctx context.Context, method string, req interface{}, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error // StreamClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Streaming RPCs. StreamClientInterceptor func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) )
var ( // DefaultServerMetrics is the default instance of ServerMetrics. It is // intended to be used in conjunction the default Prometheus metrics // registry. DefaultServerMetrics *ServerMetrics // UnaryServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Unary RPCs. UnaryServerInterceptor func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) // StreamServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs. StreamServerInterceptor func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error )
Functions ¶
func EnableClientHandlingTimeHistogram ¶
func EnableClientHandlingTimeHistogram(opts ...HistogramOption)
EnableClientHandlingTimeHistogram 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 and the default Prometheus metrics registry.
func EnableClientStreamReceiveTimeHistogram ¶
func EnableClientStreamReceiveTimeHistogram(opts ...HistogramOption)
EnableClientStreamReceiveTimeHistogram turns on recording of single message receive time of streaming RPCs. This function acts on the DefaultClientMetrics variable and the default Prometheus metrics registry.
func EnableClientStreamSendTimeHistogram ¶
func EnableClientStreamSendTimeHistogram(opts ...HistogramOption)
EnableClientStreamSendTimeHistogram turns on recording of single message send time of streaming RPCs. This function acts on the DefaultClientMetrics variable and the default Prometheus metrics registry.
func EnableHandlingTimeHistogram ¶
func EnableHandlingTimeHistogram(opts ...HistogramOption)
EnableHandlingTimeHistogram 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 DefaultServerMetrics variable and the default Prometheus metrics registry.
func RegisterClient ¶ added in v0.2.21
RegisterClient 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 DefaultClientMetrics variable.
func RegisterServer ¶ added in v0.2.21
RegisterServer 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.
Types ¶
type BloomFilter ¶ added in v0.2.21
func NewBloomFilter ¶ added in v0.2.21
func NewBloomFilter() *BloomFilter
func (*BloomFilter) Add ¶ added in v0.2.21
func (bf *BloomFilter) Add(value string)
func (*BloomFilter) Contains ¶ added in v0.2.21
func (bf *BloomFilter) Contains(value string) bool
type ClientMetrics ¶
type ClientMetrics struct {
// 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(counterOpts ...CounterOption) *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) Collect ¶
func (m *ClientMetrics) Collect(ch chan<- prom.Metric)
Collect is called by the Prometheus registry when collecting metrics. The implementation sends each collected metric via the provided channel and returns once the last metric has been sent.
func (*ClientMetrics) Describe ¶
func (m *ClientMetrics) Describe(ch chan<- *prom.Desc)
Describe sends the super-set of all possible descriptors of metrics collected by this Collector to the provided channel and returns once the last descriptor has been sent.
func (*ClientMetrics) EnableClientHandlingTimeHistogram ¶
func (m *ClientMetrics) EnableClientHandlingTimeHistogram(opts ...HistogramOption)
EnableClientHandlingTimeHistogram turns on recording of handling time of RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.
func (*ClientMetrics) EnableClientStreamReceiveTimeHistogram ¶
func (m *ClientMetrics) EnableClientStreamReceiveTimeHistogram(opts ...HistogramOption)
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) EnableClientStreamSendTimeHistogram ¶
func (m *ClientMetrics) EnableClientStreamSendTimeHistogram(opts ...HistogramOption)
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) 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 CounterOption ¶
type CounterOption func(*prom.CounterOpts)
A CounterOption lets you add options to Counter metrics using With* funcs.
func WithConstLabels ¶
func WithConstLabels(labels prom.Labels) CounterOption
WithConstLabels allows you to add ConstLabels to Counter metrics.
type HistogramOption ¶
type HistogramOption func(*prom.HistogramOpts)
A HistogramOption lets you add options to Histogram metrics using With* funcs.
func WithHistogramBuckets ¶
func WithHistogramBuckets(buckets []float64) HistogramOption
WithHistogramBuckets allows you to specify custom bucket ranges for histograms if EnableHandlingTimeHistogram is on.
func WithHistogramConstLabels ¶
func WithHistogramConstLabels(labels prom.Labels) HistogramOption
WithHistogramConstLabels allows you to add custom ConstLabels to histograms metrics.
type Option ¶ added in v0.2.21
type Option func(*config)
Option for queue system
func WithCounterOption ¶ added in v0.2.21
func WithCounterOption(counterOpts []CounterOption) Option
WithCounterOption set counterOpts function 1
func WithDuration ¶ added in v0.2.21
WithDuration set duration function 0.1, 0.3, 1.2, 5
func WithEndpointLabelMappingFn ¶ added in v0.2.21
func WithEndpointLabelMappingFn(endpointLabelMappingFn RequestLabelMappingFn) Option
WithEndpointLabelMappingFn set endpointLabelMappingFn function
func WithExcludeRegexCode ¶ added in v0.2.21
WithExcludeRegexCode set excludeRegexCode function regexp
func WithExcludeRegexMethodName ¶ added in v0.2.21
WithExcludeRegexMethodName set excludeRegexMethodName function regexp
func WithExcludeRegexRegexServiceName ¶ added in v0.2.21
WithExcludeRegexRegexServiceName set excludeRegexServiceName function regexp
func WithExcludeRegexRpcType ¶ added in v0.2.21
WithExcludeRegexRpcType set excludeRegexRpcType function regexp
func WithHandlerUrl ¶ added in v0.2.21
WithHandlerUrl set handlerUrl function
func WithNamespace ¶ added in v0.2.21
WithNamespace set namespace function
func WithPromHandler ¶ added in v0.2.21
WithPromHandler set router function
func WithSlowTime ¶ added in v0.2.21
WithSlowTime set slowTime function 1
type RequestLabelMappingFn ¶ added in v0.2.21
type ServerMetrics ¶
type ServerMetrics struct {
// 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(counterOpts ...CounterOption) *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) Collect ¶
func (m *ServerMetrics) Collect(ch chan<- prom.Metric)
Collect is called by the Prometheus registry when collecting metrics. The implementation sends each collected metric via the provided channel and returns once the last metric has been sent.
func (*ServerMetrics) Describe ¶
func (m *ServerMetrics) Describe(ch chan<- *prom.Desc)
Describe sends the super-set of all possible descriptors of metrics collected by this Collector to the provided channel and returns once the last descriptor has been sent.
func (*ServerMetrics) EnableHandlingTimeHistogram ¶
func (m *ServerMetrics) EnableHandlingTimeHistogram(opts ...HistogramOption)
EnableHandlingTimeHistogram enables histograms being registered when registering the ServerMetrics on a Prometheus registry. Histograms can be expensive on Prometheus servers. It takes options to configure histogram options such as the defined buckets.
func (*ServerMetrics) InitializeMetrics ¶
func (m *ServerMetrics) InitializeMetrics(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) 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.