telemetry

package
v1.93.4 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AttrMethodKey  = attribute.Key("frame_method")
	AttrPackageKey = attribute.Key("frame_package")
	AttrStatusKey  = attribute.Key("frame_status")
	AttrErrorKey   = attribute.Key("frame_error")
)

Common attribute keys used across the frame.

Functions

func BytesMeasure

func BytesMeasure(pkg string, meterName string, description string) metric.Int64Counter

BytesMeasure creates a counter for bytes measurements.

func CounterView

func CounterView(pkg string, meterName string, description string) []sdkmetric.View

CounterView returns summation views that add up individual measurements the counter takes.

func DimensionlessMeasure

func DimensionlessMeasure(pkg string, meterName string, description string) metric.Int64Counter

DimensionlessMeasure creates a simple counter specifically for dimensionless measurements.

func ErrorCode added in v1.59.3

func ErrorCode(err error) string

func LatencyMeasure

func LatencyMeasure(pkg string) metric.Float64Histogram

LatencyMeasure returns the measure for method call latency used by Go CDK APIs.

func NewTraceContextHandler added in v1.90.2

func NewTraceContextHandler(inner slog.Handler) slog.Handler

NewTraceContextHandler wraps an existing slog.Handler to inject trace context.

func TraceContextHandlerWrapper added in v1.90.2

func TraceContextHandlerWrapper() func(slog.Handler) slog.Handler

TraceContextHandlerWrapper returns a function suitable for util.WithLogHandlerWrapper that wraps any slog.Handler with trace context injection.

func Views

func Views(pkg string) []sdkmetric.View

Types

type Manager added in v1.63.0

type Manager interface {
	Init(ctx context.Context) error
	Disabled() bool
	LogHandler() slog.Handler
}

func NewManager added in v1.63.0

func NewManager(ctx context.Context, cfg config.ConfigurationTelemetry, opts ...Option) Manager

NewManager creates a new telemetry setup manager.

type Option added in v1.63.0

type Option func(ctx context.Context, m *manager)

func WithDisableTracing added in v1.63.0

func WithDisableTracing() Option

WithDisableTracing disable tracing for the service.

func WithMetricsReader added in v1.63.0

func WithMetricsReader(reader sdkmetrics.Reader) Option

WithMetricsReader specifies the metrics reader for the service.

func WithPropagationTextMap added in v1.63.0

func WithPropagationTextMap(carrier propagation.TextMapPropagator) Option

WithPropagationTextMap specifies the trace baggage carrier exporter to use.

func WithServiceEnvironment added in v1.63.0

func WithServiceEnvironment(env string) Option

WithServiceEnvironment sets the service environment for resource tagging.

func WithServiceName added in v1.63.0

func WithServiceName(name string) Option

WithServiceName sets the service name for resource tagging.

func WithServiceVersion added in v1.63.0

func WithServiceVersion(version string) Option

WithServiceVersion sets the service version for resource tagging.

func WithTraceExporter added in v1.63.0

func WithTraceExporter(exporter sdktrace.SpanExporter) Option

WithTraceExporter specifies the trace exporter to use.

func WithTraceLogsExporter added in v1.63.0

func WithTraceLogsExporter(exporter sdklogs.Exporter) Option

WithTraceLogsExporter specifies the trace logs exporter for the service.

func WithTraceSampler added in v1.63.0

func WithTraceSampler(sampler sdktrace.Sampler) Option

WithTraceSampler specifies the trace sampler to use.

type TraceContextHandler added in v1.90.2

type TraceContextHandler struct {
	// contains filtered or unexported fields
}

TraceContextHandler is an slog.Handler that injects trace_id and span_id from the OTel span context into every log record. This enables correlation between stdout/stderr logs and distributed traces in production.

func (*TraceContextHandler) Enabled added in v1.90.2

func (h *TraceContextHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*TraceContextHandler) Handle added in v1.90.2

func (h *TraceContextHandler) Handle(ctx context.Context, r slog.Record) error

func (*TraceContextHandler) WithAttrs added in v1.90.2

func (h *TraceContextHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*TraceContextHandler) WithGroup added in v1.90.2

func (h *TraceContextHandler) WithGroup(name string) slog.Handler

type Tracer

type Tracer interface {
	Start(ctx context.Context, methodName string, options ...trace.SpanStartOption) (context.Context, trace.Span)
	End(ctx context.Context, span trace.Span, err error, options ...trace.SpanEndOption)
}

func NewTracer

func NewTracer(name string, options ...trace.TracerOption) Tracer

NewTracer creates a new tracer for a package.

Jump to

Keyboard shortcuts

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