Documentation ¶
Overview ¶
Package promgrpc is an instrumentation package that allows capturing metrics of your gRPC based services, both the server and the client side. The main goal of version 4 was to make it modular without sacrificing the simplicity of use.
It is still possible to integrate the package in just a few lines. However, if necessary, metrics can be added, removed or modified freely.
Design ¶
The package does not introduce any new concepts to an already complicated environment. Instead, it focuses on providing implementations of interfaces exported by gRPC and Prometheus libraries.
It causes no side effects nor has global state. Instead, it comes with handy one-liners to reduce integration overhead.
The package achieved high modularity by using Inversion of Control. We can define three layers of abstraction, where each is configurable or if necessary replaceable.
Collectors serve one purpose, storing metrics. These are types well known from Prometheus ecosystem, like counters, gauges, histograms or summaries. This package comes with a set of predefined functions that create a specific instances for each use case. For example:
func NewRequestsTotalCounterVec(Subsystem, ...CollectorOption) *prometheus.CounterVec
Level higher consist of stats handlers. This layer is responsible for metrics collection. It is aware of a collector and knows how to use it to record event occurrences. Each implementation satisfies stats.Handler and prometheus.Collector interface and knows how to monitor a single dimension, e.g. a total number of received/sent requests:
func NewClientRequestsTotalStatsHandler(*prometheus.GaugeVec, ...StatsHandlerOption) *ClientRequestsTotalStatsHandler func NewServerRequestsTotalStatsHandler(*prometheus.GaugeVec, ...StatsHandlerOption) *ServerRequestsTotalStatsHandler
Above all, there is a coordinator. StatsHandler combines multiple stats handlers into a single instance.
Metrics ¶
The package comes with eighteen predefined metrics — nine for server and nine for client side:
grpc_client_connections grpc_client_message_received_size_histogram_bytes grpc_client_message_sent_size_histogram_bytes grpc_client_messages_received_total grpc_client_messages_sent_total grpc_client_request_duration_histogram_seconds grpc_client_requests_in_flight grpc_client_requests_sent_total grpc_client_responses_received_total grpc_server_connections grpc_server_message_received_size_histogram_bytes grpc_server_message_sent_size_histogram_bytes grpc_server_messages_received_total grpc_server_messages_sent_total grpc_server_request_duration_histogram_seconds grpc_server_requests_in_flight grpc_server_requests_received_total grpc_server_responses_sent_total
Configuration ¶
The package does not require any configuration whatsoever but makes it possible. It is beneficial for different reasons.
Having all metrics enabled could not be desirable. Some, like histograms, can create significant overhead on the producer side. If performance is critical, it advisable to reduce the set of metrics. To do that, implement a custom version of coordinator constructor, ClientStatsHandler and/or ServerStatsHandler.
Another good reason to change default settings is backward compatibility. Migration of Grafana dashboards is not an easy nor quick task. If the discrepancy is small and, e.g. the only necessary adjustment is changing the namespace, it is achievable by passing CollectorWithNamespace to a collector constructor. It is the same very known pattern from the gRPC package, with some enhancements. What makes it different is that both StatsHandlerOption and CollectorOption have a shareable variant, called ShareableCollectorOption and ShareableStatsHandlerOption respectively. Thanks to that, it is possible to pass options related to stats handlers and collectors to coordinator constructors. Constructors take care of moving options to the correct receivers.
Mixing both strategies described above will give even greater freedom. However, if that is even not enough, it is possible to reimplement an entire stack for a given metric or metrics.
Example ¶
reg := prometheus.NewRegistry() ssh := promgrpc.ServerStatsHandler( promgrpc.CollectorWithNamespace("example"), promgrpc.CollectorWithConstLabels(prometheus.Labels{"service": "foo"}), ) csh := promgrpc.ClientStatsHandler( promgrpc.CollectorWithConstLabels(prometheus.Labels{"service": "bar"}), ) srv := grpc.NewServer(grpc.StatsHandler(ssh)) imp := newDemoServer() test.RegisterTestServiceServer(srv, imp) reg.MustRegister(ssh) reg.MustRegister(csh)
Output:
Index ¶
- func NewClientConnectionsGaugeVec(opts ...CollectorOption) *prometheus.GaugeVec
- func NewClientMessageReceivedSizeHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
- func NewClientMessageSentSizeHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
- func NewClientMessagesReceivedTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
- func NewClientMessagesSentTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
- func NewClientRequestDurationHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
- func NewClientRequestsInFlightGaugeVec(opts ...CollectorOption) *prometheus.GaugeVec
- func NewClientRequestsTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
- func NewClientResponsesTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
- func NewServerConnectionsGaugeVec(opts ...CollectorOption) *prometheus.GaugeVec
- func NewServerMessageReceivedSizeHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
- func NewServerMessageSentSizeHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
- func NewServerMessagesReceivedTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
- func NewServerMessagesSentTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
- func NewServerRequestDurationHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
- func NewServerRequestsInFlightGaugeVec(opts ...CollectorOption) *prometheus.GaugeVec
- func NewServerRequestsTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
- func NewServerResponsesTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
- type ClientConnectionsStatsHandler
- func (h *ClientConnectionsStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ClientConnectionsStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ClientConnectionsStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats)
- func (h *ClientConnectionsStatsHandler) HandleRPC(_ context.Context, _ stats.RPCStats)
- func (h *ClientConnectionsStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ClientConnectionsStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ClientMessageReceivedSizeStatsHandler
- func (h *ClientMessageReceivedSizeStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ClientMessageReceivedSizeStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ClientMessageReceivedSizeStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ClientMessageReceivedSizeStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ClientMessageReceivedSizeStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ClientMessageReceivedSizeStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ClientMessageSentSizeStatsHandler
- func (h *ClientMessageSentSizeStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ClientMessageSentSizeStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ClientMessageSentSizeStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ClientMessageSentSizeStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ClientMessageSentSizeStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ClientMessageSentSizeStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ClientMessagesReceivedTotalStatsHandler
- func (h *ClientMessagesReceivedTotalStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ClientMessagesReceivedTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ClientMessagesReceivedTotalStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ClientMessagesReceivedTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ClientMessagesReceivedTotalStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ClientMessagesReceivedTotalStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ClientMessagesSentTotalStatsHandler
- func (h *ClientMessagesSentTotalStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ClientMessagesSentTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ClientMessagesSentTotalStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ClientMessagesSentTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ClientMessagesSentTotalStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ClientMessagesSentTotalStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ClientRequestDurationStatsHandler
- func (h *ClientRequestDurationStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ClientRequestDurationStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ClientRequestDurationStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ClientRequestDurationStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ClientRequestDurationStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ClientRequestDurationStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ClientRequestsInFlightStatsHandler
- func (h *ClientRequestsInFlightStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ClientRequestsInFlightStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ClientRequestsInFlightStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ClientRequestsInFlightStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ClientRequestsInFlightStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ClientRequestsInFlightStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ClientRequestsTotalStatsHandler
- func (h *ClientRequestsTotalStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ClientRequestsTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ClientRequestsTotalStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ClientRequestsTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ClientRequestsTotalStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ClientRequestsTotalStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ClientResponsesTotalStatsHandler
- func (h *ClientResponsesTotalStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ClientResponsesTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ClientResponsesTotalStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ClientResponsesTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ClientResponsesTotalStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ClientResponsesTotalStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type CollectorOption
- type HandleRPCLabelFunc
- type ServerConnectionsStatsHandler
- func (h *ServerConnectionsStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ServerConnectionsStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ServerConnectionsStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats)
- func (h *ServerConnectionsStatsHandler) HandleRPC(_ context.Context, _ stats.RPCStats)
- func (h *ServerConnectionsStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerConnectionsStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ServerMessageReceivedSizeStatsHandler
- func (h *ServerMessageReceivedSizeStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ServerMessageReceivedSizeStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ServerMessageReceivedSizeStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ServerMessageReceivedSizeStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ServerMessageReceivedSizeStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerMessageReceivedSizeStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ServerMessageSentSizeStatsHandler
- func (h *ServerMessageSentSizeStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ServerMessageSentSizeStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ServerMessageSentSizeStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ServerMessageSentSizeStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ServerMessageSentSizeStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerMessageSentSizeStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ServerMessagesReceivedTotalStatsHandler
- func (h *ServerMessagesReceivedTotalStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ServerMessagesReceivedTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ServerMessagesReceivedTotalStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ServerMessagesReceivedTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ServerMessagesReceivedTotalStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerMessagesReceivedTotalStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ServerMessagesSentTotalStatsHandler
- func (h *ServerMessagesSentTotalStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ServerMessagesSentTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ServerMessagesSentTotalStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ServerMessagesSentTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ServerMessagesSentTotalStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerMessagesSentTotalStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ServerRequestDurationStatsHandler
- func (h *ServerRequestDurationStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ServerRequestDurationStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ServerRequestDurationStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ServerRequestDurationStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ServerRequestDurationStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerRequestDurationStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ServerRequestsInFlightStatsHandler
- func (h *ServerRequestsInFlightStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ServerRequestsInFlightStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ServerRequestsInFlightStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ServerRequestsInFlightStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ServerRequestsInFlightStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerRequestsInFlightStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ServerRequestsTotalStatsHandler
- func (h *ServerRequestsTotalStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ServerRequestsTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ServerRequestsTotalStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ServerRequestsTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ServerRequestsTotalStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerRequestsTotalStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ServerResponsesTotalStatsHandler
- func (h *ServerResponsesTotalStatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *ServerResponsesTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *ServerResponsesTotalStatsHandler) HandleConn(_ context.Context, _ stats.ConnStats)
- func (h *ServerResponsesTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
- func (h *ServerResponsesTotalStatsHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (h *ServerResponsesTotalStatsHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type ShareableCollectorOption
- type ShareableOption
- type ShareableStatsHandlerOption
- type StatsHandler
- func (h *StatsHandler) Collect(in chan<- prometheus.Metric)
- func (h *StatsHandler) Describe(in chan<- *prometheus.Desc)
- func (h *StatsHandler) HandleConn(ctx context.Context, sts stats.ConnStats)
- func (h *StatsHandler) HandleRPC(ctx context.Context, sts stats.RPCStats)
- func (h *StatsHandler) TagConn(ctx context.Context, inf *stats.ConnTagInfo) context.Context
- func (h *StatsHandler) TagRPC(ctx context.Context, inf *stats.RPCTagInfo) context.Context
- type StatsHandlerCollector
- type StatsHandlerOption
- type TagRPCLabelFunc
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientConnectionsGaugeVec ¶
func NewClientConnectionsGaugeVec(opts ...CollectorOption) *prometheus.GaugeVec
NewClientConnectionsGaugeVec instantiates client-side GaugeVec suitable for use with NewClientConnectionsStatsHandler.
func NewClientMessageReceivedSizeHistogramVec ¶
func NewClientMessageReceivedSizeHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
NewClientMessageReceivedSizeHistogramVec instantiates default client-side HistogramVec suitable for use with NewClientMessageReceivedSizeStatsHandler.
func NewClientMessageSentSizeHistogramVec ¶
func NewClientMessageSentSizeHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
NewClientMessageSentSizeHistogramVec instantiates client-side HistogramVec suitable for use with NewClientMessageSentSizeStatsHandler.
func NewClientMessagesReceivedTotalCounterVec ¶
func NewClientMessagesReceivedTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
NewClientMessagesReceivedTotalCounterVec instantiates client-side CounterVec suitable for use with NewClientMessagesReceivedTotalStatsHandler.
func NewClientMessagesSentTotalCounterVec ¶
func NewClientMessagesSentTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
NewClientMessagesSentTotalCounterVec instantiates client-side CounterVec suitable for use with NewClientMessagesSentTotalStatsHandler.
func NewClientRequestDurationHistogramVec ¶
func NewClientRequestDurationHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
NewClientRequestDurationHistogramVec instantiates client-side HistogramVec suitable for use with NewClientRequestDurationStatsHandler.
func NewClientRequestsInFlightGaugeVec ¶
func NewClientRequestsInFlightGaugeVec(opts ...CollectorOption) *prometheus.GaugeVec
NewClientRequestsInFlightGaugeVec instantiates client-side GaugeVec suitable for use with NewClientRequestsInFlightStatsHandler.
func NewClientRequestsTotalCounterVec ¶
func NewClientRequestsTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
NewClientRequestsTotalCounterVec instantiates client-side CounterVec suitable for use with NewClientRequestsTotalStatsHandler.
func NewClientResponsesTotalCounterVec ¶
func NewClientResponsesTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
NewClientResponsesTotalCounterVec instantiates client-side CounterVec suitable for use with NewClientResponsesTotalStatsHandler.
func NewServerConnectionsGaugeVec ¶
func NewServerConnectionsGaugeVec(opts ...CollectorOption) *prometheus.GaugeVec
NewServerConnectionsGaugeVec instantiates client-side GaugeVec suitable for use with NewServerConnectionsStatsHandler.
func NewServerMessageReceivedSizeHistogramVec ¶
func NewServerMessageReceivedSizeHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
NewServerMessageReceivedSizeHistogramVec instantiates default server-side HistogramVec suitable for use with NewServerMessageReceivedSizeStatsHandler.
func NewServerMessageSentSizeHistogramVec ¶
func NewServerMessageSentSizeHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
NewServerMessageSentSizeHistogramVec instantiates default server-side HistogramVec suitable for use with NewServerMessageSentSizeStatsHandler.
func NewServerMessagesReceivedTotalCounterVec ¶
func NewServerMessagesReceivedTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
NewServerMessagesReceivedTotalCounterVec instantiates default server-side CounterVec suitable for use with NewServerMessagesReceivedTotalStatsHandler.
func NewServerMessagesSentTotalCounterVec ¶
func NewServerMessagesSentTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
NewServerMessagesSentTotalCounterVec instantiates default server-side CounterVec suitable for use with NewServerMessagesSentTotalStatsHandler.
func NewServerRequestDurationHistogramVec ¶
func NewServerRequestDurationHistogramVec(opts ...CollectorOption) *prometheus.HistogramVec
NewServerRequestDurationHistogramVec instantiates default server-side HistogramVec suitable for use with NewServerRequestDurationStatsHandler.
func NewServerRequestsInFlightGaugeVec ¶
func NewServerRequestsInFlightGaugeVec(opts ...CollectorOption) *prometheus.GaugeVec
NewServerRequestsInFlightGaugeVec instantiates default server-side GaugeVec suitable for use with NewServerRequestsInFlightStatsHandler.
func NewServerRequestsTotalCounterVec ¶
func NewServerRequestsTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
NewServerRequestsTotalCounterVec instantiates default server-side CounterVec suitable for use with NewServerRequestsTotalStatsHandler.
func NewServerResponsesTotalCounterVec ¶
func NewServerResponsesTotalCounterVec(opts ...CollectorOption) *prometheus.CounterVec
NewServerResponsesTotalCounterVec instantiates default server-side CounterVec suitable for use with NewServerResponsesTotalStatsHandler.
Types ¶
type ClientConnectionsStatsHandler ¶
type ClientConnectionsStatsHandler struct {
// contains filtered or unexported fields
}
ClientConnectionsStatsHandler dedicated client-side StatsHandlerCollector that counts the number of outgoing connections.
func NewClientConnectionsStatsHandler ¶
func NewClientConnectionsStatsHandler(vec *prometheus.GaugeVec) *ClientConnectionsStatsHandler
NewClientConnectionsStatsHandler instantiates ClientConnectionsStatsHandler based on given GaugeVec. The GaugeVec must have zero, one or two non-const non-curried labels. For those, the only allowed names are "grpc_remote_addr" and "grpc_local_addr".
func (*ClientConnectionsStatsHandler) Collect ¶
func (h *ClientConnectionsStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ClientConnectionsStatsHandler) Describe ¶
func (h *ClientConnectionsStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ClientConnectionsStatsHandler) HandleConn ¶
func (h *ClientConnectionsStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats)
HandleConn implements stats Handler interface.
type ClientMessageReceivedSizeStatsHandler ¶
type ClientMessageReceivedSizeStatsHandler struct {
// contains filtered or unexported fields
}
ClientMessageReceivedSizeStatsHandler dedicated client-side StatsHandlerCollector that counts individual observations of received message size.
func NewClientMessageReceivedSizeStatsHandler ¶
func NewClientMessageReceivedSizeStatsHandler(vec prometheus.ObserverVec, opts ...StatsHandlerOption) *ClientMessageReceivedSizeStatsHandler
NewClientMessageReceivedSizeStatsHandler instantiates ClientMessageReceivedSizeStatsHandler based on given ObserverVec and options. The CounterVec must have zero, one, two, three or four non-const non-curried labels. For those, the only allowed names are "grpc_is_fail_fast", "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ClientMessageReceivedSizeStatsHandler) Collect ¶
func (h *ClientMessageReceivedSizeStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ClientMessageReceivedSizeStatsHandler) Describe ¶
func (h *ClientMessageReceivedSizeStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ClientMessageReceivedSizeStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ClientMessageReceivedSizeStatsHandler) HandleRPC ¶
func (h *ClientMessageReceivedSizeStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ClientMessageSentSizeStatsHandler ¶
type ClientMessageSentSizeStatsHandler struct {
// contains filtered or unexported fields
}
ClientMessageSentSizeStatsHandler dedicated client-side StatsHandlerCollector that counts individual observations of sent message size.
func NewClientMessageSentSizeStatsHandler ¶
func NewClientMessageSentSizeStatsHandler(vec prometheus.ObserverVec, opts ...StatsHandlerOption) *ClientMessageSentSizeStatsHandler
NewClientMessageSentSizeStatsHandler instantiates ClientMessageSentSizeStatsHandler based on given ObserverVec and options. The ObserverVec must have zero, one, two, three or four non-const non-curried labels. For those, the only allowed names are "grpc_is_fail_fast", "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ClientMessageSentSizeStatsHandler) Collect ¶
func (h *ClientMessageSentSizeStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ClientMessageSentSizeStatsHandler) Describe ¶
func (h *ClientMessageSentSizeStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ClientMessageSentSizeStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ClientMessageSentSizeStatsHandler) HandleRPC ¶
func (h *ClientMessageSentSizeStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ClientMessagesReceivedTotalStatsHandler ¶
type ClientMessagesReceivedTotalStatsHandler struct {
// contains filtered or unexported fields
}
ClientMessagesReceivedTotalStatsHandler dedicated client-side StatsHandlerCollector that counts number of messages received.
func NewClientMessagesReceivedTotalStatsHandler ¶
func NewClientMessagesReceivedTotalStatsHandler(vec *prometheus.CounterVec, opts ...StatsHandlerOption) *ClientMessagesReceivedTotalStatsHandler
NewClientMessagesReceivedTotalStatsHandler instantiates ClientMessagesReceivedTotalStatsHandler based on given CounterVec and options. The CounterVec must have zero, one, two, three or four non-const non-curried labels. For those, the only allowed names are "grpc_is_fail_fast", "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ClientMessagesReceivedTotalStatsHandler) Collect ¶
func (h *ClientMessagesReceivedTotalStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ClientMessagesReceivedTotalStatsHandler) Describe ¶
func (h *ClientMessagesReceivedTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ClientMessagesReceivedTotalStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ClientMessagesReceivedTotalStatsHandler) HandleRPC ¶
func (h *ClientMessagesReceivedTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ClientMessagesSentTotalStatsHandler ¶
type ClientMessagesSentTotalStatsHandler struct {
// contains filtered or unexported fields
}
ClientMessagesSentTotalStatsHandler dedicated client-side StatsHandlerCollector that counts number of messages sent.
func NewClientMessagesSentTotalStatsHandler ¶
func NewClientMessagesSentTotalStatsHandler(vec *prometheus.CounterVec, opts ...StatsHandlerOption) *ClientMessagesSentTotalStatsHandler
NewClientMessagesSentTotalStatsHandler instantiates ClientMessagesSentTotalStatsHandler based on given CounterVec and options. The CounterVec must have zero, one, two, three or four non-const non-curried labels. For those, the only allowed names are "grpc_is_fail_fast", "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ClientMessagesSentTotalStatsHandler) Collect ¶
func (h *ClientMessagesSentTotalStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ClientMessagesSentTotalStatsHandler) Describe ¶
func (h *ClientMessagesSentTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ClientMessagesSentTotalStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ClientMessagesSentTotalStatsHandler) HandleRPC ¶
func (h *ClientMessagesSentTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ClientRequestDurationStatsHandler ¶
type ClientRequestDurationStatsHandler struct {
// contains filtered or unexported fields
}
ClientRequestDurationStatsHandler dedicated client-side StatsHandlerCollector that counts individual observations of request duration.
func NewClientRequestDurationStatsHandler ¶
func NewClientRequestDurationStatsHandler(vec prometheus.ObserverVec, opts ...StatsHandlerOption) *ClientRequestDurationStatsHandler
NewClientRequestDurationStatsHandler instantiates ClientRequestDurationStatsHandler based on given ObserverVec and options. The ObserverVec must have zero, one, two, three, four or five non-const non-curried labels. For those, the only allowed names are "grpc_is_fail_fast", "grpc_method", "grpc_service", "grpc_client_user_agent" and "grpc_code".
func (*ClientRequestDurationStatsHandler) Collect ¶
func (h *ClientRequestDurationStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ClientRequestDurationStatsHandler) Describe ¶
func (h *ClientRequestDurationStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ClientRequestDurationStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ClientRequestDurationStatsHandler) HandleRPC ¶
func (h *ClientRequestDurationStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC processes the RPC stats.
type ClientRequestsInFlightStatsHandler ¶
type ClientRequestsInFlightStatsHandler struct {
// contains filtered or unexported fields
}
ClientRequestsInFlightStatsHandler dedicated client-side StatsHandlerCollector that counts the number of requests currently in flight.
func NewClientRequestsInFlightStatsHandler ¶
func NewClientRequestsInFlightStatsHandler(vec *prometheus.GaugeVec, opts ...StatsHandlerOption) *ClientRequestsInFlightStatsHandler
NewClientRequestsInFlightStatsHandler instantiates ClientRequestsInFlightStatsHandler based on given GaugeVec and options. The GaugeVec must have zero, one, two, three or four non-const non-curried labels. For those, the only allowed names are "grpc_is_fail_fast", "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ClientRequestsInFlightStatsHandler) Collect ¶
func (h *ClientRequestsInFlightStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ClientRequestsInFlightStatsHandler) Describe ¶
func (h *ClientRequestsInFlightStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ClientRequestsInFlightStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ClientRequestsInFlightStatsHandler) HandleRPC ¶
func (h *ClientRequestsInFlightStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC processes the RPC stats.
type ClientRequestsTotalStatsHandler ¶
type ClientRequestsTotalStatsHandler struct {
// contains filtered or unexported fields
}
ClientRequestsTotalStatsHandler dedicated client-side StatsHandlerCollector that counts number of requests sent.
func NewClientRequestsTotalStatsHandler ¶
func NewClientRequestsTotalStatsHandler(vec *prometheus.CounterVec, opts ...StatsHandlerOption) *ClientRequestsTotalStatsHandler
NewClientRequestsTotalStatsHandler instantiates ClientRequestsTotalStatsHandler based on given CounterVec and options. The CounterVec must have zero, one, two, three or four non-const non-curried labels. For those, the only allowed names are "grpc_is_fail_fast", "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ClientRequestsTotalStatsHandler) Collect ¶
func (h *ClientRequestsTotalStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ClientRequestsTotalStatsHandler) Describe ¶
func (h *ClientRequestsTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ClientRequestsTotalStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ClientRequestsTotalStatsHandler) HandleRPC ¶
func (h *ClientRequestsTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ClientResponsesTotalStatsHandler ¶
type ClientResponsesTotalStatsHandler struct {
// contains filtered or unexported fields
}
ClientResponsesTotalStatsHandler dedicated client-side StatsHandlerCollector that counts number of responses received.
func NewClientResponsesTotalStatsHandler ¶
func NewClientResponsesTotalStatsHandler(vec *prometheus.CounterVec, opts ...StatsHandlerOption) *ClientResponsesTotalStatsHandler
NewClientResponsesTotalStatsHandler instantiates ClientResponsesTotalStatsHandler based on given CounterVec and options. The CounterVec must have zero, one, two, three, four or five non-const non-curried labels. For those, the only allowed names are "grpc_is_fail_fast", "grpc_method", "grpc_service", "grpc_client_user_agent" and "grpc_code".
func (*ClientResponsesTotalStatsHandler) Collect ¶
func (h *ClientResponsesTotalStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ClientResponsesTotalStatsHandler) Describe ¶
func (h *ClientResponsesTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ClientResponsesTotalStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ClientResponsesTotalStatsHandler) HandleRPC ¶
func (h *ClientResponsesTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type CollectorOption ¶
type CollectorOption interface {
// contains filtered or unexported methods
}
CollectorOption configures a collector.
type HandleRPCLabelFunc ¶
HandleRPCLabelFunc type represents a function signature that can be passed into a stats handler and used instead of default one. That way caller gets the ability to modify the way labels are assembled.
type ServerConnectionsStatsHandler ¶
type ServerConnectionsStatsHandler struct {
// contains filtered or unexported fields
}
ServerConnectionsStatsHandler dedicated server-side StatsHandlerCollector that counts the number of incoming connections.
func NewServerConnectionsStatsHandler ¶
func NewServerConnectionsStatsHandler(vec *prometheus.GaugeVec) *ServerConnectionsStatsHandler
NewServerConnectionsStatsHandler instantiates ServerConnectionsStatsHandler based on given GaugeVec. The GaugeVec must have zero, one, two or three non-const non-curried labels. For those, the only allowed names are "grpc_remote_addr", "grpc_local_addr" and "grpc_client_user_agent".
func (*ServerConnectionsStatsHandler) Collect ¶
func (h *ServerConnectionsStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ServerConnectionsStatsHandler) Describe ¶
func (h *ServerConnectionsStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ServerConnectionsStatsHandler) HandleConn ¶
func (h *ServerConnectionsStatsHandler) HandleConn(ctx context.Context, stat stats.ConnStats)
HandleConn implements stats Handler interface.
type ServerMessageReceivedSizeStatsHandler ¶
type ServerMessageReceivedSizeStatsHandler struct {
// contains filtered or unexported fields
}
ServerMessageReceivedSizeStatsHandler dedicated server-side StatsHandlerCollector that counts individual observations of received message size.
func NewServerMessageReceivedSizeStatsHandler ¶
func NewServerMessageReceivedSizeStatsHandler(vec prometheus.ObserverVec, opts ...StatsHandlerOption) *ServerMessageReceivedSizeStatsHandler
NewServerMessageReceivedSizeStatsHandler instantiates ServerMessageReceivedSizeStatsHandler based on given ObserverVec and options. The ObserverVec must have zero, one, two or three non-const non-curried labels. For those, the only allowed names are "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ServerMessageReceivedSizeStatsHandler) Collect ¶
func (h *ServerMessageReceivedSizeStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ServerMessageReceivedSizeStatsHandler) Describe ¶
func (h *ServerMessageReceivedSizeStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ServerMessageReceivedSizeStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ServerMessageReceivedSizeStatsHandler) HandleRPC ¶
func (h *ServerMessageReceivedSizeStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ServerMessageSentSizeStatsHandler ¶
type ServerMessageSentSizeStatsHandler struct {
// contains filtered or unexported fields
}
ServerMessageSentSizeStatsHandler dedicated server-side StatsHandlerCollector that counts individual observations of sent message size.
func NewServerMessageSentSizeStatsHandler ¶
func NewServerMessageSentSizeStatsHandler(vec prometheus.ObserverVec, opts ...StatsHandlerOption) *ServerMessageSentSizeStatsHandler
NewServerMessageSentSizeStatsHandler instantiates ServerMessageSentSizeStatsHandler based on given ObserverVec and options. The ObserverVec must have zero, one, two or three non-const non-curried labels. For those, the only allowed names are "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ServerMessageSentSizeStatsHandler) Collect ¶
func (h *ServerMessageSentSizeStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ServerMessageSentSizeStatsHandler) Describe ¶
func (h *ServerMessageSentSizeStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ServerMessageSentSizeStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ServerMessageSentSizeStatsHandler) HandleRPC ¶
func (h *ServerMessageSentSizeStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ServerMessagesReceivedTotalStatsHandler ¶
type ServerMessagesReceivedTotalStatsHandler struct {
// contains filtered or unexported fields
}
ServerMessagesReceivedTotalStatsHandler dedicated server-side StatsHandlerCollector that counts number of messages received.
func NewServerMessagesReceivedTotalStatsHandler ¶
func NewServerMessagesReceivedTotalStatsHandler(vec *prometheus.CounterVec, opts ...StatsHandlerOption) *ServerMessagesReceivedTotalStatsHandler
NewServerMessagesReceivedTotalStatsHandler instantiates ServerMessagesReceivedTotalStatsHandler based on given CounterVec and options. The CounterVec must have zero, one, two or three non-const non-curried labels. For those, the only allowed names are "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ServerMessagesReceivedTotalStatsHandler) Collect ¶
func (h *ServerMessagesReceivedTotalStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ServerMessagesReceivedTotalStatsHandler) Describe ¶
func (h *ServerMessagesReceivedTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ServerMessagesReceivedTotalStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ServerMessagesReceivedTotalStatsHandler) HandleRPC ¶
func (h *ServerMessagesReceivedTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ServerMessagesSentTotalStatsHandler ¶
type ServerMessagesSentTotalStatsHandler struct {
// contains filtered or unexported fields
}
ServerMessagesSentTotalStatsHandler dedicated server-side StatsHandlerCollector that counts number of messages sent.
func NewServerMessagesSentTotalStatsHandler ¶
func NewServerMessagesSentTotalStatsHandler(vec *prometheus.CounterVec, opts ...StatsHandlerOption) *ServerMessagesSentTotalStatsHandler
NewServerMessagesSentTotalStatsHandler instantiates ServerMessagesSentTotalStatsHandler based on given CounterVec and options. The CounterVec must have zero, one, two or three non-const non-curried labels. For those, the only allowed names are "grpc_method", "grpc_service" and "grpc_client_user_agent".
func (*ServerMessagesSentTotalStatsHandler) Collect ¶
func (h *ServerMessagesSentTotalStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ServerMessagesSentTotalStatsHandler) Describe ¶
func (h *ServerMessagesSentTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ServerMessagesSentTotalStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ServerMessagesSentTotalStatsHandler) HandleRPC ¶
func (h *ServerMessagesSentTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ServerRequestDurationStatsHandler ¶
type ServerRequestDurationStatsHandler struct {
// contains filtered or unexported fields
}
ServerRequestDurationStatsHandler dedicated server-side StatsHandlerCollector that counts individual observations of request duration.
func NewServerRequestDurationStatsHandler ¶
func NewServerRequestDurationStatsHandler(vec prometheus.ObserverVec, opts ...StatsHandlerOption) *ServerRequestDurationStatsHandler
NewServerRequestDurationStatsHandler instantiates ServerRequestDurationStatsHandler based on given ObserverVec and options. The ObserverVec must have zero, one, two, three or four non-const non-curried labels. For those, the only allowed names are "grpc_method", "grpc_service", "grpc_client_user_agent" and "grpc_code".
func (*ServerRequestDurationStatsHandler) Collect ¶
func (h *ServerRequestDurationStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ServerRequestDurationStatsHandler) Describe ¶
func (h *ServerRequestDurationStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ServerRequestDurationStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ServerRequestDurationStatsHandler) HandleRPC ¶
func (h *ServerRequestDurationStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC processes the RPC stats.
type ServerRequestsInFlightStatsHandler ¶
type ServerRequestsInFlightStatsHandler struct {
// contains filtered or unexported fields
}
ServerRequestsInFlightStatsHandler dedicated server-side StatsHandlerCollector that counts the number of requests currently in flight.
func NewServerRequestsInFlightStatsHandler ¶
func NewServerRequestsInFlightStatsHandler(vec *prometheus.GaugeVec, opts ...StatsHandlerOption) *ServerRequestsInFlightStatsHandler
NewServerRequestsInFlightStatsHandler instantiates ServerRequestsInFlightStatsHandler based on given GaugeVec and options. The GaugeVec must have zero, one or two non-const non-curried labels. For those, the only allowed names are "grpc_method" and "grpc_service".
func (*ServerRequestsInFlightStatsHandler) Collect ¶
func (h *ServerRequestsInFlightStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ServerRequestsInFlightStatsHandler) Describe ¶
func (h *ServerRequestsInFlightStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ServerRequestsInFlightStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ServerRequestsInFlightStatsHandler) HandleRPC ¶
func (h *ServerRequestsInFlightStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC processes the RPC stats.
type ServerRequestsTotalStatsHandler ¶
type ServerRequestsTotalStatsHandler struct {
// contains filtered or unexported fields
}
ServerRequestsTotalStatsHandler dedicated server-side StatsHandlerCollector that counts number of requests sent.
func NewServerRequestsTotalStatsHandler ¶
func NewServerRequestsTotalStatsHandler(vec *prometheus.CounterVec, opts ...StatsHandlerOption) *ServerRequestsTotalStatsHandler
NewServerRequestsTotalStatsHandler instantiates ServerRequestsTotalStatsHandler based on given CounterVec and options. The CounterVec must have zero, one or two non-const non-curried labels. For those, the only allowed names are "grpc_method" and "grpc_service".
func (*ServerRequestsTotalStatsHandler) Collect ¶
func (h *ServerRequestsTotalStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ServerRequestsTotalStatsHandler) Describe ¶
func (h *ServerRequestsTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ServerRequestsTotalStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ServerRequestsTotalStatsHandler) HandleRPC ¶
func (h *ServerRequestsTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ServerResponsesTotalStatsHandler ¶
type ServerResponsesTotalStatsHandler struct {
// contains filtered or unexported fields
}
ServerResponsesTotalStatsHandler dedicated server-side StatsHandlerCollector that counts number of responses received.
func NewServerResponsesTotalStatsHandler ¶
func NewServerResponsesTotalStatsHandler(vec *prometheus.CounterVec, opts ...StatsHandlerOption) *ServerResponsesTotalStatsHandler
NewServerResponsesTotalStatsHandler instantiates ServerResponsesTotalStatsHandler based on given CounterVec and options. The CounterVec must have zero, one, two, three or four non-const non-curried labels. For those, the only allowed names are "grpc_method", "grpc_service", "grpc_client_user_agent" and "grpc_code".
func (*ServerResponsesTotalStatsHandler) Collect ¶
func (h *ServerResponsesTotalStatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*ServerResponsesTotalStatsHandler) Describe ¶
func (h *ServerResponsesTotalStatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*ServerResponsesTotalStatsHandler) HandleConn ¶
HandleConn implements stats Handler interface.
func (*ServerResponsesTotalStatsHandler) HandleRPC ¶
func (h *ServerResponsesTotalStatsHandler) HandleRPC(ctx context.Context, stat stats.RPCStats)
HandleRPC implements stats Handler interface.
type ShareableCollectorOption ¶
type ShareableCollectorOption interface { ShareableOption CollectorOption }
ShareableCollectorOption is CollectorOption extended with shareable capability.
func CollectorWithConstLabels ¶
func CollectorWithConstLabels(constLabels prometheus.Labels) ShareableCollectorOption
CollectorWithConstLabels returns a ShareableCollectorOption which adds a set of constant labels to a collector.
func CollectorWithNamespace ¶
func CollectorWithNamespace(namespace string) ShareableCollectorOption
CollectorWithNamespace returns a ShareableCollectorOption which sets namespace of a collector.
func CollectorWithUserAgent ¶
func CollectorWithUserAgent(name, version string) ShareableCollectorOption
CollectorWithUserAgent ...
type ShareableOption ¶
type ShareableOption interface {
// contains filtered or unexported methods
}
ShareableOption is a simple wrapper for shareable method. It makes it possible to distinguish options reserved for direct usage, from those that are applicable on a set of objects.
type ShareableStatsHandlerOption ¶
type ShareableStatsHandlerOption interface { ShareableOption StatsHandlerOption }
ShareableStatsHandlerOption is StatsHandlerOption extended with shareable capability.
type StatsHandler ¶
type StatsHandler struct {
// contains filtered or unexported fields
}
StatsHandler wraps set of stats handlers and coordinate their execution. Additionally, it tags RPC requests with a common set of labels. That way it reduces context manipulation overhead and improves overall performance.
func ClientStatsHandler ¶
func ClientStatsHandler(opts ...ShareableOption) *StatsHandler
ClientStatsHandler instantiates a default client-side coordinator together with every metric specific stats handler provided by this package.
func NewStatsHandler ¶
func NewStatsHandler(handlers ...StatsHandlerCollector) *StatsHandler
NewStatsHandler allocates a new coordinator. It allows passing a various number of handlers that later it will iterate through.
func ServerStatsHandler ¶
func ServerStatsHandler(opts ...ShareableOption) *StatsHandler
ServerStatsHandler instantiates a default server-side coordinator together with every metric specific stats handler provided by this package.
func (*StatsHandler) Collect ¶
func (h *StatsHandler) Collect(in chan<- prometheus.Metric)
Collect implements prometheus Collector interface.
func (*StatsHandler) Describe ¶
func (h *StatsHandler) Describe(in chan<- *prometheus.Desc)
Describe implements prometheus Collector interface.
func (*StatsHandler) HandleConn ¶
func (h *StatsHandler) HandleConn(ctx context.Context, sts stats.ConnStats)
HandleConn implements stats Handler interface.
func (*StatsHandler) HandleRPC ¶
func (h *StatsHandler) HandleRPC(ctx context.Context, sts stats.RPCStats)
HandleRPC implements stats Handler interface.
func (*StatsHandler) TagConn ¶
func (h *StatsHandler) TagConn(ctx context.Context, inf *stats.ConnTagInfo) context.Context
TagConn implements stats Handler interface.
func (*StatsHandler) TagRPC ¶
func (h *StatsHandler) TagRPC(ctx context.Context, inf *stats.RPCTagInfo) context.Context
TagRPC implements stats Handler interface.
type StatsHandlerCollector ¶
type StatsHandlerCollector interface { stats.Handler prometheus.Collector }
StatsHandlerCollector is a simple wrapper for stats Handler and prometheus Collector interfaces.
type StatsHandlerOption ¶
type StatsHandlerOption interface {
// contains filtered or unexported methods
}
StatsHandlerOption configures a stats handler behaviour.
func StatsHandlerWithHandleRPCLabelsFunc ¶
func StatsHandlerWithHandleRPCLabelsFunc(fn HandleRPCLabelFunc) StatsHandlerOption
StatsHandlerWithHandleRPCLabelsFunc allows to inject custom HandleRPCLabelFunc to a stats handler. It is not shareable because there little to no chance that all stats handlers need the same set of labels.
func StatsHandlerWithTagRPCLabelsFunc ¶
func StatsHandlerWithTagRPCLabelsFunc(fn TagRPCLabelFunc) StatsHandlerOption
StatsHandlerWithTagRPCLabelsFunc allows to inject custom TagRPCLabelFunc to a stats handler. It is not shareable because of performance reasons. If all stats handlers require the same set of additional labels, it is better to implement a custom coordinator (e.g. by embedding StatsHandler) with self-defined TagRPC method. That way, it is guaranteed that new tagging execute only once and default implementation be overridden.
type TagRPCLabelFunc ¶
TagRPCLabelFunc type represents a function signature that can be passed into StatsHandlerWithTagRPCLabelsFunc.
Source Files ¶
- collector.go
- doc.go
- label.go
- metric_client_connections.go
- metric_client_message_received_size_histogram_bytes.go
- metric_client_message_sent_size_histogram_bytes.go
- metric_client_messages_received_total.go
- metric_client_messages_sent_total.go
- metric_client_request_duration_histogram_seconds.go
- metric_client_requests_in_flight.go
- metric_client_requests_total.go
- metric_client_responses_total.go
- metric_server_connections.go
- metric_server_message_received_size_histogram_bytes.go
- metric_server_message_sent_size_histogram_bytes.go
- metric_server_messages_received_total.go
- metric_server_messages_sent_total.go
- metric_server_request_duration_histogram_seconds.go
- metric_server_requests_in_flight.go
- metric_server_requests_total.go
- metric_server_responses_total.go
- options.go
- promgrpc.go
- stats_handler.go