Documentation
¶
Index ¶
- Variables
- func BytesMeasure(pkg string, meterName string, description string) metric.Int64Counter
- func CounterView(pkg string, meterName string, description string) []sdkmetric.View
- func DimensionlessMeasure(pkg string, meterName string, description string) metric.Int64Counter
- func ErrorCode(err error) string
- func LatencyMeasure(pkg string) metric.Float64Histogram
- func NewTraceContextHandler(inner slog.Handler) slog.Handler
- func TenantAttributes(ctx context.Context) []attribute.KeyValue
- func TraceContextHandlerWrapper() func(slog.Handler) slog.Handler
- func Views(pkg string) []sdkmetric.View
- func WithTenantAttributes(ctx context.Context) metric.MeasurementOption
- type Manager
- type Option
- func WithDisableTracing() Option
- func WithMetricsReader(reader sdkmetrics.Reader) Option
- func WithPropagationTextMap(carrier propagation.TextMapPropagator) Option
- func WithServiceEnvironment(env string) Option
- func WithServiceName(name string) Option
- func WithServiceVersion(version string) Option
- func WithTraceExporter(exporter sdktrace.SpanExporter) Option
- func WithTraceLogsExporter(exporter sdklogs.Exporter) Option
- func WithTraceSampler(sampler sdktrace.Sampler) Option
- type TraceContextHandler
- type Tracer
Constants ¶
This section is empty.
Variables ¶
var ( AttrTenantKey = attribute.Key("tenant_id") AttrPartitionKey = attribute.Key("partition_id") )
Attribute keys for multi-tenant context.
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 ¶
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 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
NewTraceContextHandler wraps an existing slog.Handler to inject trace context.
func TenantAttributes ¶ added in v1.94.0
TenantAttributes extracts tenant_id and partition_id from the context's security claims and returns them as OpenTelemetry attributes. When claims are absent or fields are empty, those attributes are omitted rather than recorded as blank strings. This makes the function safe to call unconditionally — unauthenticated or pre-auth code paths simply get an empty slice.
func TraceContextHandlerWrapper ¶ added in v1.90.2
TraceContextHandlerWrapper returns a function suitable for util.WithLogHandlerWrapper that wraps any slog.Handler with trace context injection.
func WithTenantAttributes ¶ added in v1.94.0
func WithTenantAttributes(ctx context.Context) metric.MeasurementOption
WithTenantAttributes returns a metric.MeasurementOption that attaches tenant_id and partition_id from the context. Services use this when recording custom product metrics so every data point is automatically attributed to the correct tenant and partition.
Usage:
counter.Add(ctx, 1,
telemetry.WithTenantAttributes(ctx),
metric.WithAttributes(attribute.String("login_method", "email")),
)
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
NewManager creates a new telemetry setup manager.
type Option ¶ added in v1.63.0
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
WithServiceEnvironment sets the service environment for resource tagging.
func WithServiceName ¶ added in v1.63.0
WithServiceName sets the service name for resource tagging.
func WithServiceVersion ¶ added in v1.63.0
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
WithTraceLogsExporter specifies the trace logs exporter for the service.
func WithTraceSampler ¶ added in v1.63.0
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.