Documentation ¶
Index ¶
- func AddRequestAttributes(ctx context.Context, attrs ...attribute.KeyValue)
- func GrpcPeer(ctx context.Context) string
- func HTTPPeer(r *http.Request) string
- func LoggingMiddleware(logger *zap.Logger, next http.Handler) http.Handler
- func LoggingStreamServerInterceptor(logger *zap.Logger) grpc.StreamServerInterceptor
- func LoggingUnaryServerInterceptor(logger *zap.Logger) grpc.UnaryServerInterceptor
- func Middleware(serviceName string, logger *zap.Logger, next http.Handler) http.Handler
- func Must[T any](val T, err error) T
- func MuxHandle(mux *http.ServeMux, pattern string, handler http.Handler)
- func TracingMiddleware(next http.Handler, serviceName string) http.Handler
- func ZapCtx(ctx context.Context) zap.Field
- type Exporter
- type Options
- type ShutdownFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddRequestAttributes ¶ added in v0.27.0
AddRequestAttributes sets attributes on the current trace span, the finish log of the current request, and the activity track
func GrpcPeer ¶ added in v0.29.0
GrpcPeer returns the client address, using the "real" IP passed by the load balancer if available.
func HTTPPeer ¶ added in v0.29.0
HTTPPeer returns the client address, using the "real" IP passed by the load balancer if available.
func LoggingMiddleware ¶
LoggingMiddleware is a HTTP request logging middleware. Note: It also recovers from panics and handles them as internal errors.
func LoggingStreamServerInterceptor ¶
func LoggingStreamServerInterceptor(logger *zap.Logger) grpc.StreamServerInterceptor
LoggingStreamServerInterceptor is a gRPC streaming interceptor that logs requests. It also recovers from panics and returns them as internal errors.
func LoggingUnaryServerInterceptor ¶
func LoggingUnaryServerInterceptor(logger *zap.Logger) grpc.UnaryServerInterceptor
LoggingUnaryServerInterceptor is a gRPC unary interceptor that logs requests. It also recovers from panics and returns them as internal errors.
func Middleware ¶
Middleware is HTTP middleware that combines all observability-related middlewares.
func MuxHandle ¶ added in v0.42.0
MuxHandle is a wrapper around http.ServeMux.Handle that adds route tags to the handler. It does NOT wrap the handler with observability.Middleware. The caller is expected to add that on the ServeMux itself.
func TracingMiddleware ¶
TracingMiddleware is HTTP middleware that adds tracing to the request.
Types ¶
type Options ¶
type Options struct { MetricsExporter Exporter TracesExporter Exporter ServiceName string ServiceVersion string }
Options for configuring telemetry setup
type ShutdownFunc ¶
ShutdownFunc stops global telemetry
func Start ¶
Start configures traces and metrics globally. Use "go.opentelemetry.io/otel.Tracer" to access global tracers. Use "go.opentelemetry.io/otel.Meter" to access global meters. If using OtelExporter (otel collector), make sure to set the OTEL_EXPORTER_OTLP_ENDPOINT env var. For a full list of Otel env vars, see: https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/otlp/otlptrace.