genkit-otel
OpenTelemetry instrumentation and backend for Genkit.
It provides GenAiInstrumentation: OpenTelemetry GenAI semantic-conventions instrumentation emitting gen_ai.* spans and metrics.
Pass tracer to mint on that tracer instead of the process-global one.
GenAI Semantic Conventions Instrumentation
Plugs into Genkit's pluggable instrumentation system and emits telemetry that follows the OTel GenAI semantic conventions:
gen_ai.*client spans for model operations (chat <model>), with request config, token usage, and finish reasons.- The GenAI client metrics
gen_ai.client.token.usage(split bygen_ai.token.type) andgen_ai.client.operation.duration. - Optional message-content capture, either as span attributes or a dedicated
gen_ai.client.inference.operation.detailsevent. - Optional
execute_toolspans, and generic spans for other Genkit action types so the trace tree stays connected.
Usage
The application owns the OpenTelemetry SDK and picks its exporter. Install them alongside this package:
pip install genkit-otel opentelemetry-sdk opentelemetry-exporter-otlp
Initialize the SDK, then register the provider before creating Genkit:
from opentelemetry import trace
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from genkit import Genkit
from genkit.telemetry import configure_instrumentation
from genkit_otel import GenAiInstrumentation
resource = Resource.create({SERVICE_NAME: 'my-service'})
provider = TracerProvider(resource=resource)
provider.add_span_processor(BatchSpanProcessor(OTLPSpanExporter()))
trace.set_tracer_provider(provider)
configure_instrumentation(GenAiInstrumentation())
ai = Genkit()
When the SDK is not initialized, the provider is effectively a no-op.
Content capture (PII)
Prompt and response content may contain PII, so capture is off by default.
content_capturing_mode is one of the spec tokens:
| Mode | Where content goes |
|---|---|
NO_CONTENT (default) |
not captured |
SPAN_ONLY |
span attributes (gen_ai.*.messages) as JSON strings |
EVENT_ONLY |
a gen_ai.client.inference.operation.details log event |
SPAN_AND_EVENT |
both |
from genkit_otel import GenAiInstrumentation
GenAiInstrumentation(content_capturing_mode='SPAN_ONLY')
Or omit the token and set the env. Same four tokens. Same result:
export OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=SPAN_ONLY
GenAiInstrumentation()
A token on the constructor wins over the env var, including an explicit
NO_CONTENT. Garbage in the env var warns and stays NO_CONTENT.
To annotate a config field or variable, import the type:
from genkit_otel import ContentCapturingMode
mode: ContentCapturingMode = 'SPAN_ONLY'
EVENT_ONLYemits content on the OpenTelemetry logs signal (agen_ai.client.inference.operation.detailslog record), not on the span. Trace-only backends like Jaeger cannot display it (its GenAI tab reads span attributes; its "Trace Logs" tab reads span events, neither is the logs signal). UseSPAN_ONLYorSPAN_AND_EVENTfor Jaeger, or a logs backend (e.g. Loki, Elasticsearch/OpenSearch) forEVENT_ONLY.
Options
| Option | Default | Description |
|---|---|---|
content_capturing_mode |
env var, else NO_CONTENT |
Where spec-shaped gen_ai.* message content is recorded. |
capture_action_io |
False |
Capture raw Genkit input/output as genkit.input/genkit.output on every span (debugging / Dev UI). |
emit_metrics |
True |
Emit token-usage and operation-duration metrics. |
emit_tool_spans |
False |
Emit execute_tool spans for tool actions. |
scope_name |
genkit-genai |
Instrumentation scope for tracer/meter/logger. |
tracer / meter / otel_logger |
resolved lazily | Escape hatches to inject explicit instances. |
Example
See samples/otel-jaeger for a runnable sample
that exports traces to Jaeger and metrics to a local collector. ./tool/telemetry.sh
downloads Jaeger and otelcol-contrib and keeps them running.
Metadata
Release files for genkit-otel 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| genkit_otel-0.13.0.tar.gz | 25.6 kB | With provenance | Details for genkit_otel-0.13.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genkit_otel-0.13.0-py3-none-any.whl | Python 3 | none | any | Details for genkit_otel-0.13.0-py3-none-any.whl |
Total release size: 46.6 kB
Release files / genkit_otel-0.13.0.tar.gz
| Download URL | genkit_otel-0.13.0.tar.gz |
|---|---|
| Size | 25.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9790c6c4cd5c3d46cef8fce62e5c84d67769c84ed5592a1488a99fe653707798
|
|
BLAKE2b-256 checksum How to use checksums |
5e84c43a996c811c9b13db0ffcb3d7b036163d1cc9d025c77a32205c95423d2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / genkit_otel-0.13.0-py3-none-any.whl
| Download URL | genkit_otel-0.13.0-py3-none-any.whl |
|---|---|
| Size | 20.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
203e3919198cc2553e6a39aa56e31ee7a92aafc9a09c6fd660ff25b50bef6404
|
|
BLAKE2b-256 checksum How to use checksums |
e57fd5c79cdda9416bf8a6188ad1b2b580e228ff9ba1ae55476899b952e2cf53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for genkit-otel 0.13.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for genkit_otel-0.13.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.