Documentation
¶
Overview ¶
Package otelconnect provides OpenTelemetry tracing and metrics for github.com/bufbuild/connect-go servers and clients. The specification followed was the OpenTelemetry specification with both the rpc metrics specification and rpc trace specification implemented.
Index ¶
- type AttributeFilter
- type Interceptor
- type Option
- func WithAttributeFilter(filter AttributeFilter) Option
- func WithFilter(filter func(context.Context, *Request) bool) Option
- func WithMeterProvider(provider metric.MeterProvider) Option
- func WithPropagator(propagator propagation.TextMapPropagator) Option
- func WithTraceRequestHeader(keys ...string) Option
- func WithTraceResponseHeader(keys ...string) Option
- func WithTracerProvider(provider trace.TracerProvider) Option
- func WithTrustRemote() Option
- func WithoutMetrics() Option
- func WithoutServerPeerAttributes() Option
- func WithoutTraceEvents() Option
- func WithoutTracing() Option
- type Request
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AttributeFilter ¶
AttributeFilter is used to filter attributes out based on the Request and attribute.KeyValue. If the filter returns true the attribute will be kept else it will be removed. AttributeFilter must be safe to call concurrently.
type Interceptor ¶
type Interceptor struct {
// contains filtered or unexported fields
}
Interceptor implements connect.Interceptor that adds OpenTelemetry metrics and tracing to connect handlers and clients.
func NewInterceptor ¶
func NewInterceptor(options ...Option) *Interceptor
NewInterceptor constructs and returns an Interceptor which implements connect.Interceptor that adds OpenTelemetry metrics and tracing to Connect handlers and clients.
func (*Interceptor) WrapStreamingClient ¶
func (i *Interceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc
WrapStreamingClient implements otel tracing and metrics for streaming connect clients.
func (*Interceptor) WrapStreamingHandler ¶
func (i *Interceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc
WrapStreamingHandler implements otel tracing and metrics for streaming connect handlers.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
An Option configures the OpenTelemetry instrumentation.
func WithAttributeFilter ¶
func WithAttributeFilter(filter AttributeFilter) Option
WithAttributeFilter sets the attribute filter for all metrics and trace attributes.
func WithFilter ¶
WithFilter configures the instrumentation to emit traces and metrics only when the filter function returns true. Filter functions must be safe to call concurrently.
func WithMeterProvider ¶
func WithMeterProvider(provider metric.MeterProvider) Option
WithMeterProvider configures the instrumentation to use the supplied metric.MeterProvider when extracting and injecting trace context. By default, the instrumentation uses global.MeterProvider().
func WithPropagator ¶
func WithPropagator(propagator propagation.TextMapPropagator) Option
WithPropagator configures the instrumentation to use the supplied propagator when extracting and injecting trace context. By default, the instrumentation uses otel.GetTextMapPropagator().
func WithTraceRequestHeader ¶
WithTraceRequestHeader enables header attributes for the request header keys provided. Attributes will be added as Trace attributes only.
func WithTraceResponseHeader ¶
WithTraceResponseHeader enables header attributes for the response header keys provided. Attributes will be added as Trace attributes only.
func WithTracerProvider ¶
func WithTracerProvider(provider trace.TracerProvider) Option
WithTracerProvider configures the instrumentation to use the supplied provider when creating a tracer. By default, the instrumentation uses otel.GetTracerProvider().
func WithTrustRemote ¶
func WithTrustRemote() Option
WithTrustRemote sets the Interceptor to trust remote spans. By default, all incoming server spans are untrusted and will be linked with a trace.Link and will not be a child span. By default, all client spans are trusted and no change occurs when WithTrustRemote is used.
func WithoutServerPeerAttributes ¶
func WithoutServerPeerAttributes() Option
WithoutServerPeerAttributes removes net.peer.port and net.peer.name attributes from server trace and span attributes. The default behavior follows the OpenTelemetry semantic conventions for RPC, but produces very high-cardinality data; this option significantly reduces cardinality in most environments.
func WithoutTraceEvents ¶ added in v0.4.0
func WithoutTraceEvents() Option
WithoutTraceEvents disables trace events for both unary and streaming interceptors. This reduces the quantity of data sent to your tracing system by omitting per-message information like message size.
type Request ¶
Request is the information about each RPC available to filter functions. It contains the common subset of connect.AnyRequest, connect.StreamingClientConn, and connect.StreamingHandlerConn.