Documentation
¶
Overview ¶
Package telemetry exports runs as OpenTelemetry traces over OTLP/HTTP. The Exporter is an eventlog.Sink: it builds spans from the same events as --json and --log-db, and sends them with a stdlib-only OTLP encoder (protobuf or JSON).
Index ¶
Constants ¶
const ( // DefaultEndpoint is the OTLP/HTTP traces URL used when nothing is set. DefaultEndpoint = "http://localhost:4318/v1/traces" // DefaultTimeout bounds each export and the final flush. DefaultTimeout = 10 * time.Second // DefaultMaxAttributeBytes caps each content attribute. DefaultMaxAttributeBytes = 4096 // DefaultServiceName is the resource service.name. DefaultServiceName = "tinyagent" )
Variables ¶
This section is empty.
Functions ¶
func ErrorStatus ¶
ErrorStatus reports whether a run status marks the root span as an error: every status except Submitted, Completed and NeedsInput.
Types ¶
type Exporter ¶
type Exporter struct {
// contains filtered or unexported fields
}
Exporter turns one invocation's events into a trace: an invoke_agent root span with chat, execute_tool, hook and subagent spans under it. It is an eventlog.Sink. Spans are buffered and sent in the background in batches and at Close; export problems are only reported by Close.
func New ¶
New starts the root span and the background sender. The returned warning is non-empty when TraceParent was set but malformed; the trace then starts fresh.
func (*Exporter) Close ¶
Close ends any open spans, sends what is left and waits at most the timeout. It returns one warning describing every export failure, or "".
type Options ¶
type Options struct {
Settings Settings
// Model is the provider/model spec the run starts with.
Model string
Task string
ReadOnly bool
Resumed bool
Version string
// Redactor masks secrets in exported text; nil masks token shapes only.
Redactor *eventlog.Redactor
// TraceParent and TraceState are the inbound W3C trace context, if any.
TraceParent, TraceState string
// Client sends the exports; nil means a default client.
Client *http.Client
}
Options describes one invocation to trace.
type Settings ¶
type Settings struct {
// Endpoint is the full URL spans are POSTed to.
Endpoint string
// Protocol is http/protobuf or http/json.
Protocol string
// Headers are sent with every export. Their values are secrets: they
// are never printed.
Headers map[string]string
Timeout time.Duration
ServiceName string
// Resource holds OTEL_RESOURCE_ATTRIBUTES other than service.name.
Resource map[string]string
Content bool
MaxAttributeBytes int
}
Settings is the resolved exporter configuration.
func Resolve ¶
Resolve combines the otel config with the standard OTEL_EXPORTER_OTLP_*, OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES variables read through getenv. Config values win; a per-signal (TRACES) variable wins over the generic one. Errors never contain header values.
func (Settings) HeaderValues ¶
HeaderValues returns the header values, for redaction.