Documentation
¶
Overview ¶
Package otelecho provides OpenTelemetry instrumentation for the labstack/echo package.
This package wraps the upstream OpenTelemetry contrib package (go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho) and adds custom functionality:
- Zerolog logging of trace IDs
- Setting X-Ngc-Trace-Id header
- Storing tracer in context for use by other packages
The upstream package is used directly as a dependency instead of copying the code to avoid Apache license issues and to benefit from upstream updates and fixes.
Note: The upstream package's go.mod contains a replace directive for the b3 propagator, but this is resolved automatically by Go's module system when using the package as a dependency. The replace directive is ignored for dependencies and only affects builds within the upstream repository itself.
Index ¶
Constants ¶
const ( // TracerKey is a key for current tracer TracerKey = "otel-go-contrib-tracer-labstack-echo" // TracerName is name of the tracer TracerName = "go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho" // TraceHdr is header name for ngc trace id TraceHdr = "X-Ngc-Trace-Id" )
Variables ¶
var ( WithPropagators = upstreamotelecho.WithPropagators WithTracerProvider = upstreamotelecho.WithTracerProvider WithSkipper = upstreamotelecho.WithSkipper )
Functions ¶
func Middleware ¶
func Middleware(service string, opts ...upstreamotelecho.Option) echo.MiddlewareFunc
Middleware wraps the upstream otelecho middleware and adds custom functionality: - Zerolog logging of trace IDs (from extracted context before span creation) - Setting X-Ngc-Trace-Id header - Storing tracer in context for use by other packages