metrics

package module
v2.0.0-rc.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 6 Imported by: 11

Documentation

Index

Constants

View Source
const (
	Unary        grpcType = "unary"
	ClientStream grpcType = "client_stream"
	ServerStream grpcType = "server_stream"
	BidiStream   grpcType = "bidi_stream"
)

grpcType describes all types of grpc connection.

Variables

This section is empty.

Functions

func FromError

func FromError(err error) (s *status.Status, ok bool)

FromError returns a grpc status if error code is a valid grpc status.

func StreamClientInterceptor

func StreamClientInterceptor(clientMetrics *ClientMetrics) grpc.StreamClientInterceptor

StreamClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Streaming RPCs.

func StreamServerInterceptor

func StreamServerInterceptor(serverMetrics *ServerMetrics) grpc.StreamServerInterceptor

StreamServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs.

func UnaryClientInterceptor

func UnaryClientInterceptor(clientMetrics *ClientMetrics) grpc.UnaryClientInterceptor

UnaryClientInterceptor is a gRPC client-side interceptor that provides Prometheus monitoring for Unary RPCs.

func UnaryServerInterceptor

func UnaryServerInterceptor(serverMetrics *ServerMetrics) grpc.UnaryServerInterceptor

UnaryServerInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Unary RPCs.

Types

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(opts ...ClientMetricsOption) *ClientMetrics

NewClientMetrics returns a new ClientMetrics object.

func NewRegisteredClientMetrics

func NewRegisteredClientMetrics(registry openmetrics.Registerer, opts ...ClientMetricsOption) *ClientMetrics

NewRegisteredClientMetrics returns a custom ClientMetrics object registered with the user's registry, and registers some common metrics associated with every instance.

func (*ClientMetrics) Collect

func (m *ClientMetrics) Collect(ch chan<- openmetrics.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<- *openmetrics.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) MustRegister

func (m *ClientMetrics) MustRegister(registry openmetrics.Registerer)

MustRegister registers the metrics with the registry and panics if any error occurs much like DefaultRegisterer of Prometheus.

func (*ClientMetrics) Register

func (m *ClientMetrics) Register(registry openmetrics.Registerer) error

Register registers the metrics with the registry. returns error much like DefaultRegisterer of Prometheus.

type ClientMetricsOption

type ClientMetricsOption func(*clientMetricsConfig)

func WithClientCounterOptions

func WithClientCounterOptions(opts ...CounterOption) ClientMetricsOption

func WithClientHandlingTimeHistogram

func WithClientHandlingTimeHistogram(opts ...HistogramOption) ClientMetricsOption

WithClientHandlingTimeHistogram turns on recording of handling time of RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.

func WithClientStreamRecvHistogram

func WithClientStreamRecvHistogram(opts ...HistogramOption) ClientMetricsOption

WithClientStreamRecvHistogram turns on recording of single message receive time of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.

func WithClientStreamSendHistogram

func WithClientStreamSendHistogram(opts ...HistogramOption) ClientMetricsOption

WithClientStreamSendHistogram turns on recording of single message send time of streaming RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.

type CounterOption

type CounterOption func(*openmetrics.CounterOpts)

A CounterOption lets you add options to Counter metrics using With* funcs.

func WithConstLabels

func WithConstLabels(labels openmetrics.Labels) CounterOption

WithConstLabels allows you to add ConstLabels to Counter metrics.

type HistogramOption

type HistogramOption func(*openmetrics.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 openmetrics.Labels) HistogramOption

WithHistogramConstLabels allows you to add custom ConstLabels to histograms metrics.

type Kind

type Kind string

Kind describes whether interceptor is a client or server type.

const (
	KindClient Kind = "client"
	KindServer Kind = "server"
)

Enum for Client and Server Kind.

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 NewRegisteredServerMetrics

func NewRegisteredServerMetrics(registry openmetrics.Registerer, opts ...ServerMetricsOption) *ServerMetrics

NewRegisteredServerMetrics returns a custom ServerMetrics object registered with the user's registry, and registers some common metrics associated with every instance.

func NewServerMetrics

func NewServerMetrics(opts ...ServerMetricsOption) *ServerMetrics

NewServerMetrics returns a new ServerMetrics object.

func (*ServerMetrics) Collect

func (m *ServerMetrics) Collect(ch chan<- openmetrics.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<- *openmetrics.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) 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) MustRegister

func (m *ServerMetrics) MustRegister(registry openmetrics.Registerer)

MustRegister registers the metrics with the registry and panics if any error occurs much like DefaultRegisterer of Prometheus.

func (*ServerMetrics) Register

func (m *ServerMetrics) Register(registry openmetrics.Registerer) error

Register registers the metrics with the registry. returns error much like DefaultRegisterer of Prometheus.

type ServerMetricsOption

type ServerMetricsOption func(*serverMetricsConfig)

func WithServerCounterOptions

func WithServerCounterOptions(opts ...CounterOption) ServerMetricsOption

func WithServerHandlingTimeHistogram

func WithServerHandlingTimeHistogram(opts ...HistogramOption) ServerMetricsOption

WithServerHandlingTimeHistogram turns on recording of handling time of RPCs. Histogram metrics can be very expensive for Prometheus to retain and query.

Directories

Path Synopsis
testproto
v1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL