Skip to main content
kubit-otel sends OpenTelemetry spans from a Python app to Kubit. It has two entry points: configure() when Kubit is your only exporter, and attach() when your app already creates a TracerProvider. This page covers both, plus the settings to check before production.

Before you start

  • Python 3.9 or later
  • A Kubit API key in KUBIT_API_KEY
Kubit authenticates spans with an ingestion API key, read from the KUBIT_API_KEY environment variable. Each key belongs to one workspace.
Keep the key out of source control. Put it in .env or your secrets manager, and check that .env is in .gitignore.

Prompt for your coding agent

Install

Choose configure() or attach()

Don’t call configure() in a process that already sets a global TracerProvider. Use attach().

You have no OpenTelemetry setup

Create kubit_instrumentation.py and import it first in your entrypoint.
kubit_instrumentation.py
main.py

configure() parameters

You already have a TracerProvider

Call attach() after trace.set_tracer_provider(), in the module that creates the provider:
tracing.py
attach() finds the global provider and adds KubitSpanProcessor to it. Your provider’s resource (service.name, service.version) applies to the spans Kubit receives.

attach() parameters

Availability: attach() must run after trace.set_tracer_provider(). Called earlier, it finds no provider to attach to.

Trace LLM and tool calls

Kubit receives whatever spans your app produces. To get one span per LLM call, add the OpenTelemetry GenAI instrumentor for your client after configure() or attach():
kubit_instrumentation.py
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true puts prompt and response text on the spans. Polaris labels spans from that text. For tool calls, wrap each tool in its own span so it shows up as a step in the execution path:
tools.py
Span attributes lists the keys Atlas reads, including user and session IDs.

Before production

Verify

Send a test span:
Then ask your assistant with the Kubit MCP server connected:
“Show me traces from the last 15 minutes for service support-agent”
The result includes a trace with a root span named hello-kubit.

If it fails

Next steps