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

otel

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package otel turns the engine's event stream into OpenTelemetry traces: one trace per run, a span per node and per hook step, and the request attempts as span events. Traces leave as OTLP over HTTP with a JSON body, which every collector accepts; no SDK is involved.

It is off unless Config.Endpoint is set. The Exporter is wired in through engine.Deps.Observe and engine.Deps.Traceparent and never affects a run: Observe does not block, and export failures are logged and reported by Close, nothing more.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Endpoint  string
	Headers   map[string]string // sent with every export (typically a token)
	Propagate bool              // add traceparent to outgoing requests
	Service   string            // service.name; default "flowi"
	Version   string            // service.version
	Timeout   time.Duration     // per export; default 10s
	QueueSize int               // finished traces waiting to be sent; default 64
	Now       func() time.Time  // nil → time.Now
	Client    *http.Client      // nil → a client with Timeout
}

Config configures an Exporter. Endpoint is the collector's base URL ("http://localhost:4318"); "/v1/traces" is appended unless it is there.

func ConfigFrom

func ConfigFrom(r settings.Resolved, version string) (cfg Config, on bool, err error)

ConfigFrom reads the otel.* settings. on is false when no endpoint is set, which is the default: nothing is exported.

type Exporter

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

Exporter builds traces from engine events and sends them to a collector.

Goroutine ownership: New starts one worker that posts queued traces; Close stops accepting traces, lets the worker finish what is queued (or gives up when its context ends) and waits for it. Observe and Traceparent are safe for concurrent use; Observe never blocks.

func New

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

New starts an exporter. An empty or malformed endpoint is an error: callers create an Exporter only when OTEL is switched on.

func (*Exporter) Close

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

Close sends what is queued and stops the worker. It returns the export errors seen so far, or ctx's error when the flush did not finish in time. Traces of runs still open are discarded.

func (*Exporter) Dropped

func (e *Exporter) Dropped() int64

Dropped is the number of traces discarded because the queue was full or too many runs were open.

func (*Exporter) Observe

func (e *Exporter) Observe(ev engine.Event)

Observe folds one engine event into its run's trace and queues the trace when the run ends. It matches engine.Deps.Observe.

func (*Exporter) Traceparent

func (e *Exporter) Traceparent(runID, path string) string

Traceparent is the header value naming the span of the call made by node path ("" for a standalone send) of run runID, or "" when propagation is off. It matches engine.Deps.Traceparent.

Jump to

Keyboard shortcuts

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