Documentation
¶
Overview ¶
Package otel wires OpenTelemetry for an Ohm application.
Setup configures a tracer provider with an OTLP exporter, installs the global tracer provider and text-map propagators, and returns a shutdown function for graceful flushing during server shutdown. Ohm's core and application code use the OpenTelemetry API directly; until Setup runs, that API returns a no-op tracer, so instrumentation can be written unconditionally with no overhead.
Exporter selection follows the standard OpenTelemetry environment variables (for example OTEL_TRACES_EXPORTER, OTEL_EXPORTER_OTLP_ENDPOINT, and OTEL_EXPORTER_OTLP_PROTOCOL), so deployments configure their backend without code changes.
Index ¶
- type Option
- func WithEnvironment(name string) Option
- func WithPropagator(propagator propagation.TextMapPropagator) Option
- func WithResourceAttributes(attrs ...attribute.KeyValue) Option
- func WithSampler(sampler sdktrace.Sampler) Option
- func WithServiceName(name string) Option
- func WithServiceVersion(version string) Option
- type Shutdown
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*config)
Option configures Setup.
func WithEnvironment ¶
WithEnvironment sets the deployment.environment.name resource attribute.
func WithPropagator ¶
func WithPropagator(propagator propagation.TextMapPropagator) Option
WithPropagator overrides the global text-map propagator. The default propagates W3C trace context and baggage.
func WithResourceAttributes ¶
WithResourceAttributes appends additional resource attributes.
func WithSampler ¶
WithSampler overrides the tracer provider sampler.
func WithServiceName ¶
WithServiceName sets the service.name resource attribute.
func WithServiceVersion ¶
WithServiceVersion sets the service.version resource attribute.
type Shutdown ¶
Shutdown flushes and releases telemetry resources. It should be called during graceful server shutdown so buffered spans are exported before exit.
func Setup ¶
Setup installs OpenTelemetry for the process and returns a shutdown function.
Setup is opt-in: applications that never call it keep the no-op tracer and pay no telemetry cost. The returned Shutdown is safe to call once; calling it more than once returns the result of the first call's underlying providers.