Documentation
¶
Overview ¶
Package observability provides minimal-overhead OpenTelemetry bootstrap with a strict split between DEV (stdout+sync) and PROD (OTLP+batch). - DEV (exporter=stdout): WithSyncer(exp) prints immediately on span.End(). - PROD (exporter=grpc|http): WithBatcher(exp, ...) to reduce I/O overhead. Hot path remains lean: a single atomic toggle + dynamic Tracer fetch. No schema conflicts: resource is schemaless (plain attributes).
Index ¶
- Constants
- Variables
- func Apply(ctx context.Context, cfg *config.Observability) func(context.Context) error
- func DisableTracing()
- func EnableTracing()
- func Extract(rCtx *fasthttp.RequestCtx) context.Context
- func Inject(parentTraceCtx context.Context, req *fasthttp.Request)
- func IsActiveTracing() bool
- func SafeSetString(sp trace.Span, key, val string)
- func SetBoolAttr(sp trace.Span, key string, v bool)
- func SetBytesAttr(sp trace.Span, key string, b []byte)
- func SetIntAttr(sp trace.Span, key string, v int)
- func Start(ctx context.Context, name string, kind trace.SpanKind) (context.Context, trace.Span, func(...trace.SpanEndOption))
Constants ¶
const ( AttrHTTPPathKey = "http.path" AttrHTTPRequest = "http.request" AttrReqID = "http.request_id" AttrReqGUID = "http.request_guid" AttrHTTPStatusCodeKey = "http.status_code" AttrHTTPResponseSizeKey = "http.response_size" AttrCacheProxy = "cache.proxy" AttrCacheHit = "cache.hit" AttrCacheKey = "cache.key" AttrXTenantScope = "X_Scope_OTEL_Tenant" )
const ( XRequestIDHeader = "X-Request-Id" XRequestGUIDHeader = "X-Request-Guid" )
Variables ¶
Functions ¶
func Apply ¶
Apply (re)installs a TracerProvider based on cfg and returns its shutdown func. - When disabled: installs a tiny provider with NeverSample (fast noop). - When enabled: stdout -> WithSyncer; grpc/http -> WithBatcher. It hot-swaps providers atomically and gracefully shuts down the previous one.
func DisableTracing ¶
func DisableTracing()
func EnableTracing ¶
func EnableTracing()
func Extract ¶
func Extract(rCtx *fasthttp.RequestCtx) context.Context
Extract pulls trace context from incoming request headers.
func IsActiveTracing ¶
func IsActiveTracing() bool
IsActiveTracing returns a fast-path toggle for hot code.
func SafeSetString ¶
SafeSetString avoids work when span is not recording.
func SetIntAttr ¶
SetIntAttr avoids work when span is not recording.
func Start ¶
func Start(ctx context.Context, name string, kind trace.SpanKind) (context.Context, trace.Span, func(...trace.SpanEndOption))
Start returns (ctx, span, endFn) with minimal overhead. It dynamically fetches a Tracer from the CURRENT global provider, avoiding stale (noop) tracers and eliminating global caches.
Types ¶
This section is empty.