telemetry

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package telemetry provides backend-neutral span carriers and in-memory recording. Ports packages/telemetry/src/index.ts and packages/telemetry/src/noop.ts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttributeValue

type AttributeValue = any

AttributeValue is a string, number, boolean, or slice of those values.

type InMemoryTelemetryContext

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

InMemoryTelemetryContext records spans without an external backend. Its zero value is ready to use.

func (*InMemoryTelemetryContext) GetSpans

func (recorder *InMemoryTelemetryContext) GetSpans() []RecordedTelemetrySpan

GetSpans returns detached snapshots in span-start order.

func (*InMemoryTelemetryContext) StartSpan

func (recorder *InMemoryTelemetryContext) StartSpan(options SpanOptions, callback func(TelemetrySpan) error) error

StartSpan invokes and waits for callback, recording its settlement even when it returns an error or panics.

type RecordedTelemetryEvent

type RecordedTelemetryEvent struct {
	Name       string
	Attributes SpanAttributes
}

RecordedTelemetryEvent is a detached span event snapshot.

type RecordedTelemetrySpan

type RecordedTelemetrySpan struct {
	ID          int
	ParentID    *int
	Name        string
	Attributes  SpanAttributes
	Events      []RecordedTelemetryEvent
	Status      SpanStatus
	Settled     bool
	EndSequence *int
}

RecordedTelemetrySpan is a detached snapshot in span-start order.

type SpanAttributes

type SpanAttributes map[string]AttributeValue

SpanAttributes carries named telemetry values.

type SpanOptions

type SpanOptions struct {
	Name       string
	Attributes SpanAttributes
}

SpanOptions supplies a span's name and initial attributes.

type SpanStatus

type SpanStatus struct {
	Status SpanStatusCode
	Error  *SpanStatusError
}

SpanStatus records success or failure and optional error details.

type SpanStatusCode

type SpanStatusCode string

SpanStatusCode is the final status of a span.

const (
	SpanStatusCodeOK    SpanStatusCode = "ok"
	SpanStatusCodeError SpanStatusCode = "error"
)

type SpanStatusError

type SpanStatusError struct{ Name, Message string }

SpanStatusError describes an optional error status.

type TelemetryContext

type TelemetryContext interface {
	StartSpan(SpanOptions, func(TelemetrySpan) error) error
}

TelemetryContext starts child spans and waits for their callbacks.

type TelemetrySpan

type TelemetrySpan interface {
	TelemetryContext
	AddEvent(string, SpanAttributes)
	SetAttributes(SpanAttributes)
	SetStatus(SpanStatus)
}

TelemetrySpan records attributes, events and status while active.

var NoopTelemetryContext TelemetrySpan = noopTelemetrySpan{}

NoopTelemetryContext is the shared parent used without a recording backend.

Jump to

Keyboard shortcuts

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