@kubit-ai/otel sends OpenTelemetry spans from a Node or TypeScript app to Kubit. It has two entry points: configure() when Kubit is your only OpenTelemetry setup, and KubitSpanProcessor when your app already creates a tracer provider or a NodeSDK. This page covers both, the span filter, and the settings to check before production.
Before you start
- Node.js 18 or later
- OpenTelemetry JS SDK v2. Version 1 isn’t supported.
- A Kubit API key in
KUBIT_API_KEY
KUBIT_API_KEY environment variable. Each key belongs to one workspace.
Prompt for your coding agent
Install
Install the package and its OpenTelemetry peer dependencies:Choose configure() or KubitSpanProcessor
@kubit-ai/otel has no attach(), unlike the Python SDK. OpenTelemetry JS SDK v2 takes span processors only when the provider is created, so there’s no way to add one to a provider that’s already running.
You have no OpenTelemetry setup
Createkubit-instrumentation.ts and import it first in your entrypoint, before any LLM client is created:
kubit-instrumentation.ts
index.ts
serviceName, serviceVersion and deployment.environment to match your app. Kubit uses them to tell agents and releases apart.
configure() options
configure() returns the tracer provider it registered.
You already have a tracer provider
PassKubitSpanProcessor in spanProcessors next to your other processors, when you create the provider.
NodeTracerProvider
tracing.ts
NodeSDK
instrumentation.ts
KubitSpanProcessor options
KubitSpanProcessor is an OpenTelemetry BatchSpanProcessor that drops non-LLM spans before they’re queued.
For full control,
KubitExporter is the plain exporter without filtering or batching. Wrap it in your own processor.
Span filtering
By default,KubitSpanProcessor sends only LLM-related spans to Kubit. HTTP, database and framework spans from other auto-instrumentation stay out of your workspace.
A span is sent when any of these is true:
KNOWN_LLM_INSTRUMENTATION_SCOPE_PREFIXES exports the full prefix list.
Keep spans from your own framework
tracing.ts
Send every span
tracing.ts
shouldExportSpan throws, the span is dropped.
Trace LLM and tool calls
Kubit receives whatever spans your app produces. Spans from an LLM instrumentation library pass the default filter. With the Vercel AI SDK, turn on telemetry per call:chat.ts
tools.ts
Before production
@kubit-ai/otel doesn’t read the standard OTEL_EXPORTER_OTLP_ENDPOINT or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT variables. They apply to the whole process and would redirect Kubit’s traces if another OpenTelemetry SDK set them. Use KUBIT_OTEL_ENDPOINT instead.
Verify
Send a test span with debug logging on:send-test-span.ts
Output
Dropped span due to shouldExportSpan filter line for chat.completion means the span passed the filter.
If it fails
Next steps
- Span attributes: the attribute keys Kubit reads.
- Set up with your coding agent: keep Langfuse or Braintrust as your sink and add Kubit next to it.
- Is my data flowing?: step-by-step checks.