tracing

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceName = "kirocc"

ServiceName is the OTel service name used for resource and tracer identification.

Variables

This section is empty.

Functions

func ExtractTraceID

func ExtractTraceID(ctx context.Context) string

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

func Init(ctx context.Context) (shutdown func(context.Context) error, err error)

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

func Middleware(next http.Handler, bodyLimit int) http.Handler

Middleware returns an HTTP middleware that creates OTel server spans and records request/response headers and request body as span events.

func RecordError

func RecordError(ctx context.Context, err error)

RecordError records an error on the span in the given context. Safe to call even if no active span exists.

func Tracer

func Tracer() trace.Tracer

Tracer returns the package-level OTel tracer.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL