Documentation
¶
Index ¶
- Constants
- func ExtractTraceID(ctx context.Context) string
- func Init(ctx context.Context) (shutdown func(context.Context) error, err error)
- func Middleware(next http.Handler, bodyLimit int) http.Handler
- func RecordError(ctx context.Context, err error)
- func Tracer() trace.Tracer
- func WrapTransport(base http.RoundTripper, bodyLimit int) http.RoundTripper
Constants ¶
const ServiceName = "kirocc"
ServiceName is the OTel service name used for resource and tracer identification.
Variables ¶
This section is empty.
Functions ¶
func ExtractTraceID ¶
ExtractTraceID returns the OTel trace ID from the context as a 32-char hex string. Returns an empty string if no valid OTel span is present (e.g., when OTel is disabled).
func Init ¶
Init initializes the OTel TracerProvider with an OTLP HTTP exporter. The OTLP endpoint is configured via the standard OTEL_EXPORTER_OTLP_ENDPOINT environment variable (defaults to http://localhost:4318). Returns a shutdown function that flushes and shuts down the TracerProvider.
func Middleware ¶
Middleware returns an HTTP middleware that creates OTel server spans and records request/response headers and request body as span events.
func RecordError ¶
RecordError records an error on the span in the given context. Safe to call even if no active span exists.
func WrapTransport ¶
func WrapTransport(base http.RoundTripper, bodyLimit int) http.RoundTripper
WrapTransport wraps an http.RoundTripper with OTel tracing that creates client spans for each outgoing request, recording headers and body as span events.
Types ¶
This section is empty.