telemetry

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func (s Signals) Enabled() bool

Enabled reports whether this Signals container was intentionally constructed via NewSignals. Both the zero value and Disabled() return false.

func (Signals) Meter

func (s Signals) Meter(scope string) metric.Meter

Meter returns a meter for the supplied scope, falling back to a package local no-op provider when metrics are disabled.

func (Signals) Shutdown

func (s Signals) Shutdown(ctx context.Context) error

Shutdown flushes and closes configured providers when a shutdown hook exists. Nil contexts are normalized to context.Background(), and zero-value or Disabled signal containers return nil without doing any work.

func (Signals) Tracer

func (s Signals) Tracer(scope string) trace.Tracer

Tracer returns a tracer for the supplied scope, falling back to a package local no-op provider when tracing is disabled.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL