Documentation
¶
Overview ¶
Package telemetry is an internal API for observability/instrumentation.
Index ¶
- Variables
- func HandleID() string
- type Attr
- func Binary(k string, v []byte) Attr
- func Bool[T ~bool](k string, v T) Attr
- func Float[T constraints.Float](k string, v T) Attr
- func If(cond bool, attr Attr) Attr
- func Int[T constraints.Integer](k string, v T) Attr
- func String[T ~string](k string, v T) Attr
- func Stringer(k string, v fmt.Stringer) Attr
- func Type[T any](k string, v T) Attr
- type Instrument
- type Provider
- type Recorder
- func (r *Recorder) Counter(name, unit, desc string) Instrument[int64]
- func (r *Recorder) Error(ctx context.Context, event string, err error, attrs ...Attr)
- func (r *Recorder) Histogram(name, unit, desc string) Instrument[int64]
- func (r *Recorder) Info(ctx context.Context, event, message string, attrs ...Attr)
- func (r *Recorder) StartSpan(ctx context.Context, name string, attrs ...Attr) (context.Context, *Span)
- func (r *Recorder) UpDownCounter(name, unit, desc string) Instrument[int64]
- type Span
Constants ¶
This section is empty.
Variables ¶
var ( // ReadDirection is an attribute that indicates a read operation. ReadDirection = String("network.io.direction", "read") // WriteDirection is an attribute that indicates a write operation. WriteDirection = String("network.io.direction", "write") )
Functions ¶
Types ¶
type Attr ¶
type Attr struct {
// contains filtered or unexported fields
}
Attr is a telemetry attribute.
func Binary ¶ added in v0.11.0
Binary returns a string attribute containing v, represented as a Go string (with backslash escaped sequences). If the value is longer than 64 bytes, it is truncated to 64 bytes and the key is suffixed with "_truncated".
type Instrument ¶ added in v0.11.0
Instrument is a function that records a metric value of type T.
type Provider ¶
type Provider struct {
TracerProvider trace.TracerProvider
MeterProvider metric.MeterProvider
LoggerProvider log.LoggerProvider
}
Provider provides Recorder instances scoped to particular subsystems.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder records traces, metrics and logs for a particular subsystem.
func (*Recorder) Counter ¶ added in v0.11.0
func (r *Recorder) Counter(name, unit, desc string) Instrument[int64]
Counter returns a new monotonic counter instrument.
func (*Recorder) Error ¶ added in v0.11.0
Error logs an error message to the log and as a span event.
It marks the span as an error and emits increments the "errors" metric.
func (*Recorder) Histogram ¶ added in v0.11.0
func (r *Recorder) Histogram(name, unit, desc string) Instrument[int64]
Histogram returns a new histogram instrument.
func (*Recorder) Info ¶ added in v0.11.0
Info logs an informational message to the log and as a span event.
func (*Recorder) StartSpan ¶
func (r *Recorder) StartSpan( ctx context.Context, name string, attrs ...Attr, ) (context.Context, *Span)
StartSpan starts a new span and records the operation to the recorder's operation counter and "in-flight" gauge instruments.
func (*Recorder) UpDownCounter ¶ added in v0.11.0
func (r *Recorder) UpDownCounter(name, unit, desc string) Instrument[int64]
UpDownCounter returns a new counter instrument that can increase or decrease.
type Span ¶
type Span struct {
// contains filtered or unexported fields
}
Span represents a single named and timed operation of a workflow.
func (*Span) End ¶
func (s *Span) End()
End completes the span and decrements the "in-flight" gauge instrument.
func (*Span) SetAttributes ¶
SetAttributes adds the given attributes to the underlying OpenTelemetry span and any future log messages.