Documentation
¶
Overview ¶
Package olly is a portable OpenTelemetry helper for Go services.
Boundary rules:
- No imports of product application packages.
- No product-specific service names, operation names, or metric names.
- Apps own loggers, HTTP wrappers, and business instrumentation.
- olly owns provider lifecycle, optional OTLP export, local failure-trace dumps, and small span error helpers.
Package layout:
- olly: Init, Config, Shutdown, Flush
- olly/dump: SpanProcessor that buffers by trace and writes JSON on envelope ERROR
- olly/errors: span annotation helpers (Record, EndWithStatus, TraceIDs)
Index ¶
- func EnvelopeKind() trace.SpanKind
- func Flush(ctx context.Context) error
- func Init(cfg Config) (func(context.Context) error, error)
- func Provider() *sdktrace.TracerProvider
- func SamplerForRatio(ratio float64) sdktrace.Sampler
- func Shutdown(ctx context.Context) error
- func Tracer(instrumentationName string) trace.Tracer
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnvelopeKind ¶
EnvelopeKind is the default process envelope for failure dumps (SERVER).
func Init ¶
Init installs the global TracerProvider, W3C propagator, optional OTLP exporter, and optional failure-dump processor. Returns a shutdown function.
func Provider ¶
func Provider() *sdktrace.TracerProvider
Provider returns the SDK provider installed by Init, or nil.
func SamplerForRatio ¶
SamplerForRatio returns AlwaysSample for local/full capture (ratio <=0 or >=1). Otherwise ParentBased TraceIDRatioBased for partial export.
Types ¶
type Config ¶
type Config struct {
// Enabled installs a real TracerProvider. When false, Init installs noop.
Enabled bool
// ServiceName is set on the resource as service.name.
ServiceName string
// OTLPEndpoint is host:port for OTLP/gRPC (insecure). Empty skips OTLP;
// dump-only tracing still works when Dump.Dir is set.
OTLPEndpoint string
// OTLPTimeout bounds exporter construction. Zero uses 10s.
OTLPTimeout time.Duration
// BatchTimeout is the OTLP batch export interval. Zero uses 3s.
BatchTimeout time.Duration
// SampleRatio is 0..1. Values <=0 or >=1 use AlwaysSample.
SampleRatio float64
// AllowOTLPFailure continues with dump-only tracing when OTLP setup fails.
// When false, Init returns the exporter error.
AllowOTLPFailure bool
// Dump configures the local failure-trace processor. Empty Dir disables it.
Dump dump.Config
// ExtraProcessors are appended after the dump processor (if any).
ExtraProcessors []sdktrace.SpanProcessor
// ResourceAttributes are merged onto the default resource (service.name wins from ServiceName).
ResourceAttributes map[string]string
// Diagnostics receives dump write/prune messages. Nil uses stderr.
Diagnostics dump.Diagnostics
}
Config controls provider construction.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dump buffers OpenTelemetry spans and writes JSON when a process envelope ends with an ERROR somewhere in the trace.
|
Package dump buffers OpenTelemetry spans and writes JSON when a process envelope ends with an ERROR somewhere in the trace. |
|
Package errors annotates OpenTelemetry spans from Go errors.
|
Package errors annotates OpenTelemetry spans from Go errors. |
Click to show internal directories.
Click to hide internal directories.