telemetry

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package telemetry is an internal API for observability/instrumentation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ReadDirection is an attribute that indicates a read operation.
	ReadDirection = metric.WithAttributeSet(
		attribute.NewSet(
			attribute.String("direction", "read"),
		),
	)

	// WriteDirection is an attribute that indicates a write operation.
	WriteDirection = metric.WithAttributeSet(
		attribute.NewSet(
			attribute.String("direction", "write"),
		),
	)
)

Functions

func HandleID

func HandleID() string

HandleID returns a unique identifier for an open instance of a journal or keyspace.

It includes a counter component for easy visual identification by humans, and a UUID component for global correlation in observability tools.

Types

type Attr

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

Attr is a telemetry attribute.

func Bool

func Bool[T ~bool](k string, v T) Attr

Bool returns a boolean attribute.

func Float

func Float[T constraints.Float](k string, v T) Attr

Float returns a float64 attribute.

func If

func If(cond bool, attr Attr) Attr

If conditionally includes an attribute.

func Int

func Int[T constraints.Integer](k string, v T) Attr

Int returns an int64 attribute.

func String

func String[T ~string](k string, v T) Attr

String returns a string attribute.

func Stringer

func Stringer(k string, v fmt.Stringer) Attr

Stringer returns a string attribute. The value is the result of calling v.String().

func Type

func Type[T any](k string, v T) Attr

Type returns a string attribute set to the name of T.

type Provider

type Provider struct {
	TracerProvider trace.TracerProvider
	MeterProvider  metric.MeterProvider
	Logger         *slog.Logger
	Attrs          []Attr
}

Provider provides Recorder instances scoped to particular subsystems.

func (*Provider) Recorder

func (p *Provider) Recorder(pkg, name string, attrs ...Attr) *Recorder

Recorder returns a new Recorder instance.

pkg is the path to the Go package that is performing the instrumentation. If it is an internal package, use the package path of the public parent package instead.

name is the one-word name of the subsystem that the recorder is for, for example "journal" or "aggregate".

type Recorder

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

Recorder records traces, metrics and logs for a particular subsystem.

func (*Recorder) Float64Counter

func (r *Recorder) Float64Counter(name string, options ...metric.Float64CounterOption) metric.Float64Counter

Float64Counter returns a new Float64Counter instrument.

func (*Recorder) Float64Histogram

func (r *Recorder) Float64Histogram(name string, options ...metric.Float64HistogramOption) metric.Float64Histogram

Float64Histogram returns a new Float64Histogram instrument.

func (*Recorder) Float64UpDownCounter

func (r *Recorder) Float64UpDownCounter(name string, options ...metric.Float64UpDownCounterOption) metric.Float64UpDownCounter

Float64UpDownCounter returns a new Float64UpDownCounter instrument.

func (*Recorder) Int64Counter

func (r *Recorder) Int64Counter(name string, options ...metric.Int64CounterOption) metric.Int64Counter

Int64Counter returns a new Int64Counter instrument.

func (*Recorder) Int64Histogram

func (r *Recorder) Int64Histogram(name string, options ...metric.Int64HistogramOption) metric.Int64Histogram

Int64Histogram returns a new Int64Histogram instrument.

func (*Recorder) Int64UpDownCounter

func (r *Recorder) Int64UpDownCounter(name string, options ...metric.Int64UpDownCounterOption) metric.Int64UpDownCounter

Int64UpDownCounter returns a new Int64UpDownCounter instrument.

func (*Recorder) StartSpan

func (r *Recorder) StartSpan(
	ctx context.Context,
	name string,
	attrs ...Attr,
) (context.Context, *Span)

StartSpan starts a new span.

type Span

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

Span represents a single named and timed operation of a workflow.

func (*Span) Debug

func (s *Span) Debug(message string, attrs ...Attr)

Debug logs a debug message to the log and as a span event.

func (*Span) End

func (s *Span) End()

End completes the span.

func (*Span) Error

func (s *Span) Error(message string, err error, attrs ...Attr)

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 (*Span) Info

func (s *Span) Info(message string, attrs ...Attr)

Info logs an informational message to the log and as a span event.

func (*Span) SetAttributes

func (s *Span) SetAttributes(attrs ...Attr)

SetAttributes adds the given attributes to the underlying OpenTelemetry span and any future log messages.

func (*Span) Warn

func (s *Span) Warn(message string, attrs ...Attr)

Warn logs a warning message to the log and as a span event.

Jump to

Keyboard shortcuts

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