Documentation
¶
Overview ¶
Package telemetry provides the local Signals container and coarse boundary helper for github.com/amikos-tech/ami-gin.
Ownership Model ¶
This package is fail-open and caller-owned. The library never mutates global OTel state (no otel.SetTracerProvider, otel.SetMeterProvider, or global.SetLoggerProvider calls). Callers construct Signals, pass them into GINConfig or raw encode/decode options, and own the provider shutdown lifecycle.
Local Providers Only ¶
This package depends only on the OTel API and noop packages (go.opentelemetry.io/otel, go.opentelemetry.io/otel/trace, go.opentelemetry.io/otel/metric). OTLP exporter/bootstrap helpers and the OTel SDK are explicitly out of scope for the root module. CLI bootstrap wiring belongs to a CLI-owned module boundary.
Disabled Path ¶
Disabled() and the zero-value Signals are silent and zero-cost. Noop tracer and meter providers are used for all operations when signals are disabled.
Index ¶
Constants ¶
const ( OperationEvaluate = "query.evaluate" OperationEncode = "serialize.encode" OperationDecode = "serialize.decode" OperationBuildFromParquet = "parquet.build" )
Frozen operation name constants for coarse boundary instrumentation. These are the only operation strings emitted at INFO level. New operation names must be added here; callers must not construct free-form operation strings at call sites.
const ErrorTypeOther = "other"
ErrorTypeOther is the canonical fallback value for the frozen error.type vocabulary. Classifiers in parent packages should reuse this constant rather than declaring their own "other" literal to avoid drift.
Variables ¶
This section is empty.
Functions ¶
func RunBoundaryOperation ¶
func RunBoundaryOperation( ctx context.Context, signals Signals, cfg BoundaryConfig, fn func(context.Context) error, ) error
RunBoundaryOperation runs fn inside one coarse telemetry boundary. The helper owns span start/end, duration recording, and failure counting. fn receives the normalized context (never nil). A nil fn is a no-op call. If fn panics, RunBoundaryOperation finalizes telemetry then re-panics.
Types ¶
type BoundaryConfig ¶
type BoundaryConfig struct {
Scope string
Operation string
ExtraAttrs []attribute.KeyValue
ClassifyError func(error) string
}
BoundaryConfig describes one coarse boundary operation. The shared helper owns lifecycle and generic failure handling only; package-owned success counters and classifier callbacks remain outside it.
type Signals ¶
type Signals struct {
TracerProvider trace.TracerProvider
MeterProvider metric.MeterProvider
// contains filtered or unexported fields
}
Signals carries the local telemetry providers used by coarse boundary APIs. The zero value is fully disabled: providers are nil, Enabled() reports false, and Shutdown() is a no-op.
func Disabled ¶
func Disabled() Signals
Disabled returns the zero-value, fully disabled signal container. It carries nil providers, reports Enabled()==false, and treats Shutdown as a no-op.
func NewSignals ¶
func NewSignals( tracerProvider trace.TracerProvider, meterProvider metric.MeterProvider, shutdown func(context.Context) error, ) Signals
NewSignals constructs a local signal container with optional tracer and meter providers plus an optional shutdown hook. Passing nil providers leaves that signal type inactive but Enabled() still reports true because the caller explicitly chose to construct signals. Use Disabled() to express "no telemetry".
func (Signals) Enabled ¶
Enabled reports whether this Signals container was intentionally constructed via NewSignals. Both the zero value and Disabled() return false.
func (Signals) Meter ¶
Meter returns a meter for the supplied scope, falling back to a package local no-op provider when metrics are disabled.