Help us shape the future of Go! Take the 2026 Go Developer Survey

telemetry

package module
v0.1.0-preview.17 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package telemetry reports what AgentExperience does to OpenTelemetry: the spans and metrics that docs/telemetry.md documents for .NET, under the same source and meter names, span names, instruments, dimensions and attributes, for the operations the Go port performs.

The core and the Agent Framework integration only call a small observer hook (agentexperience.SetObserver) and import no OpenTelemetry. This module is the optional adapter: it depends on the OpenTelemetry API only, configures no SDK and no exporter (the host does, as it does for the .NET library), and is enabled with one call:

disable := telemetry.Enable() // uses the global tracer and meter providers the application configured
defer disable()

A failure in a provider, an exporter or this adapter is recovered and never reaches the agent. Attributes never carry record content, task text, scopes or error messages; a failing operation records its error's type name only.

Index

Constants

View Source
const (
	SpanNamePrefix    = "agentexperience."
	OperationCount    = "agentexperience.operation.count"
	OperationDuration = "agentexperience.operation.duration"
	OperationFailures = "agentexperience.operation.failures"

	// The metric dimensions.
	DimensionOperation  = "operation"
	DimensionOutcome    = "outcome"
	DimensionErrorClass = "error.class"
	DimensionNested     = "nested"

	// The span attributes the adapter writes itself.
	AttributeOperation  = "agentexperience.operation"
	AttributeOutcome    = "agentexperience.outcome"
	AttributeErrorClass = "agentexperience.error.class"
	AttributeErrorType  = "error.type"
)

The names the adapter writes. Tests pin each against docs/telemetry-names.json, which is generated from the .NET definitions.

Variables

This section is empty.

Functions

func Dimensions

func Dimensions() []string

Dimensions are the only metric dimensions.

func Enable

func Enable(options ...Option) (disable func())

Enable registers an observer built from options with the library and returns the function that unregisters it.

func Instruments

func Instruments() [][3]string

Instruments are the three instruments every meter publishes: name, kind and unit.

func SpanAttributes

func SpanAttributes() []string

SpanAttributes is every span attribute the adapter can write.

Types

type Observer

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

Observer is the agentexperience.Observer that reports to OpenTelemetry.

func NewObserver

func NewObserver(options ...Option) *Observer

NewObserver is an observer reporting to the global providers, or to the ones the options name.

func (*Observer) Finish

func (o *Observer) Finish(value any, observation ae.Observation)

Finish records the operation's measurements and closes its span.

func (*Observer) Start

func (o *Observer) Start(ctx context.Context, source, operation string, _ bool) (context.Context, any)

Start opens the operation's span (when it has one) as a child of the span ctx carries, and returns a context carrying it, so the operations it runs are its children.

type Option

type Option func(*Observer)

Option configures an Observer.

func WithMeterProvider

func WithMeterProvider(mp metric.MeterProvider) Option

WithMeterProvider reports metrics to mp instead of the global meter provider.

func WithTracerProvider

func WithTracerProvider(tp trace.TracerProvider) Option

WithTracerProvider reports spans to tp instead of the global tracer provider.

Jump to

Keyboard shortcuts

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