Skip to main content

Programmatic Configuration

Call configure() before calling any instrumentor’s .instrument() method.

Parameters

endpoint
string
The OTel Collector gRPC endpoint. Defaults to http://localhost:4317. Use http://otel-collector:4317 when your agent runs inside Docker. The SDK strips the scheme and routes via gRPC; https:// URLs switch the exporter to TLS, anything else uses insecure mode.
service_name
string
The service name attached to all spans. Appears in the service.name resource attribute. Defaults to tracectrl-agent.
api_key
string
Optional API key for authenticated collectors. Sent as a Bearer token in the Authorization header.
fail_silently
boolean
When true, exporter failures are logged as warnings instead of raising exceptions. Defaults to true — your agent never crashes because tracing fails.
configure() accepts only the four kwargs above. Batch tuning (TRACECTRL_BATCH_DELAY_MS, TRACECTRL_MAX_BATCH_SIZE) is environment-only.

Environment Variables

All configuration can also be set via environment variables. Programmatic values take precedence.

Platform Environment Variables

These are used by the TraceCtrl Engine and Docker stack, not the SDK:

Tagging Agents

Most agent frameworks do not emit the system prompt on their OTEL spans. Call tag_agent once per agent so TraceCtrl can attribute spans to a named agent in the dashboard:
tag_agent is idempotent and installs a SystemPromptStamper SpanProcessor on the shared TracerProvider so that every subsequent agent-run span carries tracectrl.agent.system_prompt and a 16-character SHA-256 hash.

TracerProvider

The SDK lazily creates a shared TracerProvider with:
  • An OTLP gRPC exporter pointed at your endpoint
  • A BatchSpanProcessor for async export (configurable batch size and delay)
  • The SystemPromptStamper for agent attribution
If you need to pass a custom TracerProvider, you can skip configure() and pass it directly:
When using a custom TracerProvider, you must manually add the security-enrichment processor to get TraceCtrl span attributes: