Documentation
¶
Overview ¶
Package traces configures OpenTelemetry tracing and metrics for the config module.
It centralizes three concerns:
- initialization of tracer and meter providers from OTEL_* environment variables
- construction of OpenTelemetry resources using application metadata from Viper
- middleware and interceptor wiring for Gin and gRPC server instrumentation
Main entry points:
- InitOtel to install global tracer and meter providers
- MiddlewareOtel to instrument incoming Gin requests
- MiddlewareOtelGRPCUnary to instrument unary gRPC handlers
- MiddlewareOtelGRPCStream to instrument streaming gRPC handlers
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitOtel ¶
InitOtel initializes the global OpenTelemetry propagator, tracer provider, and meter provider.
Behavior is driven mainly by standard OTEL_* environment variables. When OTEL_SDK_DISABLED is true, the package installs no-op providers and returns a shutdown function that does nothing.
On success it returns a shutdown function that must be called during application shutdown to flush and release tracing and metrics resources.
func MiddlewareOtel ¶
func MiddlewareOtel() gin.HandlerFunc
MiddlewareOtel returns a Gin middleware that instruments incoming HTTP requests with OpenTelemetry.
The middleware uses the globally configured propagator, tracer provider, and meter provider. Paths configured in `traces.SkipPaths` are excluded when the request URL contains any of those values.
func MiddlewareOtelGRPCStream ¶
func MiddlewareOtelGRPCStream() grpc.StreamServerInterceptor
func MiddlewareOtelGRPCUnary ¶
func MiddlewareOtelGRPCUnary() grpc.UnaryServerInterceptor
Types ¶
This section is empty.