Skip to main content

SET UP OPENTELEMETRY

Prerequisites: Swamp installed.

Enable console tracing for local debugging

Set the OTEL_TRACES_EXPORTER environment variable to console before running a command:

OTEL_TRACES_EXPORTER=console swamp model method run my-greeter execute --input 'run=echo hello'

Span data prints to stdout alongside normal command output. Do not combine OTEL_TRACES_EXPORTER=console with --json in pipelines — trace objects interleave with the JSON output and corrupt parseable output. This exporter is useful for verifying that tracing is working without setting up a collector.

Send traces to a collector

Point Swamp at an OpenTelemetry collector endpoint:

OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317 swamp model method run my-greeter execute --input 'run=echo hello'

Configure the service name

OTEL_SERVICE_NAME=my-infra swamp model method run my-greeter execute --input 'run=echo hello'

Add vendor-specific headers

For Honeycomb:

OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=your-api-key" \
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io \
  swamp model method run my-greeter execute --input 'run=echo hello'

For Axiom:

OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer your-token,X-Axiom-Dataset=my-dataset" \
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.axiom.co \
  swamp model method run my-greeter execute --input 'run=echo hello'

Multiple headers are comma-separated in key=value format.

Disable tracing

To suppress OTel trace export, set the exporter to none:

OTEL_TRACES_EXPORTER=none swamp model method run my-greeter execute --input 'run=echo hello'

SWAMP_NO_TELEMETRY=true controls Swamp's own telemetry but does not suppress OTel trace export.

For the full list of supported environment variables, see the OpenTelemetry reference.