Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTransport ¶
func NewTransport(config contractsconfig.Config, telemetry contractstelemetry.Telemetry, base http.RoundTripper) http.RoundTripper
NewTransport returns an http.RoundTripper instrumented with OpenTelemetry. It wraps the provided base RoundTripper with otelhttp using the configured telemetry facade's tracer provider, meter provider, and propagator.
If telemetry is nil, no instrumentation is applied. In that case, http.DefaultTransport is returned when base is nil; otherwise the provided base RoundTripper is returned.
func Telemetry ¶
func Telemetry(opts ...Option) http.Middleware
Telemetry creates HTTP server telemetry middleware that instruments incoming requests with tracing and metrics. The optional opts parameters allow customizing the server configuration (such as span naming and enabling or disabling instrumentation). It returns an http.Middleware that propagates context, records spans and metrics when telemetry is enabled, and otherwise transparently passes requests through when telemetry is disabled or not initialized.
The underlying handler is resolved lazily on the first request. The application configures middleware before booting providers, so the telemetry facade is not yet available when Telemetry is called; resolving eagerly would permanently capture a disabled handler.
Types ¶
type Filter ¶
Filter determines whether a specific request should be traced. Return true to trace the request, or false to exclude it.
type MiddlewareHandler ¶
type MiddlewareHandler struct {
// contains filtered or unexported fields
}
func (*MiddlewareHandler) Handle ¶
func (r *MiddlewareHandler) Handle(ctx http.Context)
func (*MiddlewareHandler) Signature ¶
func (r *MiddlewareHandler) Signature() string
type Option ¶
type Option func(*ServerConfig)
Option applies configuration to the server instrumentation.
func WithFilter ¶
func WithMetricAttributes ¶
func WithSpanNameFormatter ¶
func WithSpanNameFormatter(f SpanNameFormatter) Option
type ServerConfig ¶
type ServerConfig struct {
Enabled bool `json:"enabled"`
ExcludedPaths []string `json:"excluded_paths"`
ExcludedMethods []string `json:"excluded_methods"`
Filters []Filter `json:"-"`
SpanNameFormatter SpanNameFormatter `json:"-"`
MetricAttributes []attribute.KeyValue `json:"-"`
}
ServerConfig maps to "telemetry.instrumentation.http_server".