telemetry

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: GPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package telemetry exports every tool call as an OpenTelemetry span, over OTLP/HTTP with JSON encoding, so agentgate's decisions show up next to the rest of your traces in Jaeger, Tempo, Honeycomb, Datadog or anything else that speaks OTLP.

Each session is one trace and each call a span in it, named the way the MCP semantic conventions name them ("tools/call write_file") and carrying the GenAI and MCP attributes plus agentgate's own: the decision, the rule and the reason.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Endpoint is the OTLP/HTTP base URL, e.g. http://localhost:4318. Spans
	// are posted to <endpoint>/v1/traces.
	Endpoint string `yaml:"endpoint"`
	// Headers are sent with every export, e.g. an API key.
	Headers map[string]string `yaml:"headers"`
	// ServiceName defaults to agentgate.
	ServiceName string `yaml:"service_name"`
}

Config is where spans go. The OTEL_* environment variables fill in what the config file leaves out, so an existing OpenTelemetry setup works as is.

type Exporter

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

Exporter batches spans and posts them in the background. A slow or dead collector never slows a tool call down: when the buffer is full, spans are dropped and counted.

func New

func New(cfg Config, version string, log *slog.Logger) (*Exporter, error)

New returns an exporter, or nil when no endpoint is configured anywhere.

func (*Exporter) Close

func (e *Exporter) Close(ctx context.Context) error

Close flushes what is queued, waiting at most until ctx is done.

func (*Exporter) Export

func (e *Exporter) Export(s Span)

Export queues a span. It never blocks.

type Span

type Span struct {
	CallID      string
	SessionID   string
	Tool        string
	Upstream    string
	HostName    string
	HostVersion string
	Start       time.Time
	Duration    time.Duration
	Decision    string
	RuleID      string
	Reason      string
	IsError     bool
	Error       string
	Shadow      bool
	Labels      []string
}

Span is one tool call as it is exported.

Jump to

Keyboard shortcuts

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