{"modulePath":"github.com/bitechdev/ResolveSpec","version":"v1.3.14","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package tracing\n\n## Constants\n\n```go\nconst (\n\t// DefaultSampleRate is used when Config.SampleRate is zero.\n\tDefaultSampleRate = 0.1\n\t// DefaultAttributeValueLimit caps the length of any span attribute value.\n\tDefaultAttributeValueLimit = 1024\n\t// DefaultInitTimeout bounds exporter and resource creation.\n\tDefaultInitTimeout = 10 * time.Second\n)\n```\n\n## Functions\n\n```go\nfunc AddEvent(ctx context.Context, name string, attrs ...attribute.KeyValue)\n```\nAddEvent adds an event to the current span\n\n```go\nfunc InitTracer(config Config) (func(context.Context) error, error)\n```\nInitTracer initializes the OpenTelemetry tracer using a background context.\n\n```go\nfunc InitTracerContext(ctx context.Context, config Config) (func(context.Context) error, error)\n```\nInitTracerContext initializes the OpenTelemetry tracer. ctx bounds startup work. Calling it again while a tracer is active returns an error; call the returned shutdown function first.\n\n```go\nfunc Middleware(next http.Handler) http.Handler\n```\nMiddleware returns an HTTP middleware that creates spans for requests. The span name uses the matched route pattern (http.ServeMux's Request.Pattern); use MiddlewareWithRoute for other routers. It should be installed inside the panic recovery middleware: panics are recorded on the span and re-raised.\n\n```go\nfunc MiddlewareWithRoute(fn func(*http.Request) string) func(http.Handler) http.Handler\n```\nMiddlewareWithRoute is like Middleware but resolves the low-cardinality route template with fn, called after the handler ran (so the router has matched). A nil fn falls back to Request.Pattern.\n\n```go\nfunc RecordError(ctx context.Context, err error)\n```\nRecordError records an error on the current span\n\n```go\nfunc SetAttributes(ctx context.Context, attrs ...attribute.KeyValue)\n```\nSetAttributes sets attributes on the current span\n\n```go\nfunc SpanFromContext(ctx context.Context) trace.Span\n```\nSpanFromContext returns the current span from the context\n\n```go\nfunc StartSpan(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span)\n```\nStartSpan starts a new span with the given name\n\n## Types\n\n```go\ntype Config struct {\n\tServiceName    string\n\tServiceVersion string\n\tEndpoint       string // OTLP endpoint (e.g., \"localhost:4317\")\n\tEnabled        bool\n\n\t// Insecure exports traces over plaintext gRPC. TLS is used unless this is set.\n\tInsecure bool\n\t// TLSConfig customises TLS for the exporter. Nil uses the system roots. Ignored when Insecure.\n\tTLSConfig *tls.Config\n\t// Headers are sent with every export request (e.g. an authorization token).\n\tHeaders map[string]string\n\n\t// SampleRate is the fraction of new root traces sampled (0 \u003c rate \u003c= 1).\n\t// Zero selects DefaultSampleRate. Upstream sampling decisions are respected.\n\tSampleRate float64\n\t// AttributeValueLimit caps span attribute value length. Zero selects DefaultAttributeValueLimit.\n\tAttributeValueLimit int\n\t// InitTimeout bounds exporter/resource creation. Zero selects DefaultInitTimeout.\n\tInitTimeout time.Duration\n}\n```\nConfig holds tracing configuration\n\n","path":"github.com/bitechdev/ResolveSpec/pkg/tracing","name":"tracing","synopsis":"","isRedistributable":true}
