otelgrpc

package module
v1.2.115 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
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()
)
View Source
var (
	// InstrumentationName is the name of this instrumentation package.
	InstrumentationName = "" /* 135-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
	}
)

Functions

func AttrsFromRequest

func AttrsFromRequest(req *http.Request, localAddress string) []attribute.KeyValue

AttrsFromRequest generates attributes as specified by the OpenTelemetry specification for a span.

func AttrsFromResponse

func AttrsFromResponse(resp *http.Response) []attribute.KeyValue

AttrsFromResponse generates attributes as specified by the OpenTelemetry specification for a span.

func EnableClientHandledTimeHistogram

func EnableClientHandledTimeHistogram(opts ...metric.Float64HistogramOption)

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.Int64HistogramOption)

EnableClientStreamReceiveSizeHistogram turns on recording of single message receive size of streaming RPCs. This function acts on the DefaultClientMetrics variable

func EnableClientStreamSendSizeHistogram

func EnableClientStreamSendSizeHistogram(opts ...metric.Int64HistogramOption)

EnableClientStreamSendSizeHistogram turns on recording of single message receive size of streaming RPCs. This function acts on the DefaultClientMetrics variable

func Meter

func Meter() metric.Meter

func ResetClientCounter

func ResetClientCounter(opts ...metric.InstrumentOption) error

ResetClientCounter recreate recording of all counters of RPCs. This function acts on the DefaultClientMetrics 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) 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) ResetCounter

func (m *ClientMetrics) ResetCounter(opts ...metric.InstrumentOption) (err error)

ResetCounter recreate recording of all counters of RPCs.

func (*ClientMetrics) UnaryClientInterceptor

func (m *ClientMetrics) UnaryClientInterceptor() func(req *http.Request, retry int, invoker http_.ClientInvoker, opts ...http_.DoWithBackoffOption) (resp *http.Response, err error)

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

Jump to

Keyboard shortcuts

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