Skip to main content

OpenTelemetry exporter for Kubit analytics.

Project description

kubit-otel

OpenTelemetry exporter for Kubit analytics. A thin convenience wrapper around the stock OTLP/HTTP exporter, preconfigured to ship spans to the Kubit collector.

Install

pip install kubit-otel

Quick start

from kubit_otel import configure
from opentelemetry import trace

configure(api_key="rg.v1.xxx", service_name="my-app")
tracer = trace.get_tracer("my-app")

with tracer.start_as_current_span("chat.completion") as span:
    span.set_attribute("gen_ai.request.model", "gpt-4o")
    span.set_attribute("gen_ai.prompt", "Hello, world!")
    span.set_attribute("gen_ai.completion", "Hi there!")
    span.set_attribute("gen_ai.usage.input_tokens", 10)
    span.set_attribute("gen_ai.usage.output_tokens", 5)

Spans are sent as standard OTLP/HTTP protobuf to the Kubit collector, which normalizes them across LLM frameworks (OTel GenAI semconv, OpenInference, Langfuse, Vercel AI, Braintrust, Logfire, OpenLLMetry/Traceloop, Mastra, OpenAI Agents, Pydantic AI) into the canonical Kubit schema and routes them to your workspace.

Configuration

Option (kwarg) Env var Default
api_key required
endpoint KUBIT_OTEL_ENDPOINT https://otel.kubit.ai/v1/traces
service_name default
service_version unset
resource_attributes {}

KUBIT_OTEL_LOG_LEVEL (debug | info | warn | error) controls the SDK's internal logger.

The standard OTEL_EXPORTER_OTLP_TRACES_ENDPOINT / OTEL_EXPORTER_OTLP_ENDPOINT env vars are intentionally not consulted — they are process-wide and would silently redirect Kubit traces if another OTel-based SDK in the same process sets them. Use KUBIT_OTEL_ENDPOINT to override.

Works alongside other OTel-based SDKs

configure() detects whether a real TracerProvider is already installed as the global OTel provider. If so, it attaches KubitSpanProcessor to that provider and merges in your resource attributes — it does not replace the existing provider. You can call configure() before or after other OTel-based libraries (Langfuse, OpenLLMetry, an OTel distro, …) and every span will reach both sinks.

If you want explicit "attach only, never register" behavior, use attach():

from kubit_otel import attach

# Must be called after another library has installed a real provider.
attach(api_key="rg.v1.xxx")

Span filtering

By default, only LLM-relevant spans are forwarded to Kubit. A span is exported if it:

  • was created by the Kubit SDK tracer (kubit-sdk),
  • carries any gen_ai.* semantic-convention attribute, or
  • comes from a known LLM instrumentation scope (OpenInference, Langfuse, Vercel AI SDK, Braintrust, Logfire, OpenLLMetry/Traceloop, Mastra, OpenAI Agents, …).

This keeps HTTP/DB/framework auto-instrumentation noise out of your Kubit workspace without extra configuration.

Extend the default filter

from kubit_otel import configure, is_default_export_span

configure(
    api_key="rg.v1.xxx",
    should_export_span=lambda span: (
        is_default_export_span(span)
        or (
            span.instrumentation_scope is not None
            and span.instrumentation_scope.name.startswith("my_framework")
        )
    ),
)

Full override

configure(
    api_key="rg.v1.xxx",
    should_export_span=lambda span: span.name.startswith("llm."),
)

Export everything

configure(api_key="rg.v1.xxx", should_export_span=lambda _span: True)

Python compatibility

Python 3.9+

License

Proprietary — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kubit_otel-0.7.2rc1.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kubit_otel-0.7.2rc1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file kubit_otel-0.7.2rc1.tar.gz.

File metadata

  • Download URL: kubit_otel-0.7.2rc1.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for kubit_otel-0.7.2rc1.tar.gz
Algorithm Hash digest
SHA256 1e6f575030b72606ea0b18c915cd63e93f4c3d6cd2afe9608e0aada54a80bb98
MD5 fd83afe7026ffb0522a3ff2531684891
BLAKE2b-256 65c7c95feae998f9b9f19f09437cf80cfadaa0f5d94728c064eabda62c5b4b7e

See more details on using hashes here.

File details

Details for the file kubit_otel-0.7.2rc1-py3-none-any.whl.

File metadata

  • Download URL: kubit_otel-0.7.2rc1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for kubit_otel-0.7.2rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1a4843e77010bec7c6563b718ab96a4289357b002d14795dc90f91185c23dfe
MD5 175e8eff64b235e7d770d40e75f0b90c
BLAKE2b-256 bfdf0c11acf92515ecc54b963e015a98e5351ce15b2b51c4b8b13da0339ee72b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page