Documentation
¶
Index ¶
- func RequestIDFromContext(ctx context.Context) string
- func TraceFromContext(ctx context.Context) (traceID, spanID string)
- func WithRequestID(ctx context.Context, requestID string) context.Context
- func WithTrace(ctx context.Context, traceID, spanID string) context.Context
- type Counter
- type Fields
- type Histogram
- type LogEmitter
- type Meter
- type MetricOption
- type NoopLogEmitter
- type NoopMeter
- type NoopRuntime
- type NoopTracer
- type Runtime
- type Severity
- type Span
- type Tracer
- type UpDownCounter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequestIDFromContext ¶
func TraceFromContext ¶
Types ¶
type Fields ¶
Fields is an observability-agnostic key/value hashmap.
func FromPairs ¶
FromPairs creates attributes from key/value pairs. If pairs length is odd, the last key is ignored.
func MergeFields ¶
func OptionalFields ¶
OptionalFields returns the first variadic Fields argument, or nil if none provided.
type LogEmitter ¶
type LogEmitter interface {
Emit(ctx context.Context, severity Severity, message string, fields ...Fields)
}
LogEmitter is the contract for a secondary log sink.
type Meter ¶
type Meter interface {
Counter(name string, options ...MetricOption) Counter
UpDownCounter(name string, options ...MetricOption) UpDownCounter
Histogram(name string, options ...MetricOption) Histogram
}
Meter creates and owns metric instruments for app layers.
type MetricOption ¶
MetricOption configures metric instruments.
type NoopLogEmitter ¶
type NoopLogEmitter struct{}
NoopLogEmitter is a no-op implementation of LogEmitter.
type NoopMeter ¶
type NoopMeter struct{}
NoopMeter is a no-op implementation of Meter.
func (NoopMeter) UpDownCounter ¶
func (NoopMeter) UpDownCounter(string, ...MetricOption) UpDownCounter
type NoopRuntime ¶
type NoopRuntime struct{}
NoopRuntime is a no-op observability facade.
func (NoopRuntime) LogEmitter ¶
func (NoopRuntime) LogEmitter() LogEmitter
func (NoopRuntime) Meter ¶
func (NoopRuntime) Meter() Meter
func (NoopRuntime) Tracer ¶
func (NoopRuntime) Tracer() Tracer
type NoopTracer ¶
type NoopTracer struct{}
func (NoopTracer) ExtractHTTP ¶
type Runtime ¶
type Runtime interface {
LogEmitter() LogEmitter
Tracer() Tracer
Meter() Meter
Shutdown(ctx context.Context) error
}
Runtime is the observability facade exposed to app wiring.
type Span ¶
type Span interface {
SetAttributes(fields ...Fields)
Finish(err error, description ...string)
IDs() (traceID, spanID string, ok bool)
}
Span is an observability-agnostic span contract for app layers.
type Tracer ¶
type Tracer interface {
Start(ctx context.Context, scope, spanName string, fields ...Fields) (context.Context, Span)
StartServer(ctx context.Context, scope, spanName string, fields ...Fields) (context.Context, Span)
ExtractHTTP(ctx context.Context, headers http.Header) context.Context
}
Tracer is injected into app layers to avoid direct OTel dependency.