The repository or configuration that created this release differ from a previous release. View details.
genkit-otel
OpenTelemetry instrumentation and backend for Genkit.
It provides GenAiInstrumentation: OpenTelemetry GenAI semantic-conventions instrumentation emitting gen_ai.* spans and metrics.
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:
uv add 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.
Flushing before exit
BatchSpanProcessor and periodic metric readers buffer exports. A
serverless handler or a short script can return before they're sent. Call
flush_instrumentations() before the process freezes. It force-flushes the
global OTel tracer, meter, and logger providers. If a flush fails, it logs a
warning and doesn't raise:
import asyncio
from genkit.telemetry import flush_instrumentations
# 1. Handle the request
response = await ai.generate(prompt='Suggest a dish for a peanut allergy.')
# 2. Drain buffered spans, metrics, and log events before returning
await asyncio.to_thread(flush_instrumentations)
If you passed tracer, meter, or otel_logger explicitly, flush the
provider you built them from. GenAiInstrumentation can't reach it.
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:
NO_CONTENT(default): not captured.SPAN_ONLY: span attributes (gen_ai.*.messages) as JSON strings.EVENT_ONLY: agen_ai.client.inference.operation.detailslog 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
content_capturing_mode(env var, elseNO_CONTENT): where spec-shapedgen_ai.*message content is recorded.capture_action_io(False): records raw Genkit input/output asgenkit.input/genkit.outputon every span (debugging / Dev UI).emit_metrics(True): emits token-usage and operation-duration metrics.emit_tool_spans(False): emitsexecute_toolspans for tool actions.scope_name(genkit-genai): instrumentation scope for the tracer, meter and logger.tracer/meter/otel_logger(resolved lazily): explicit instances to use instead of the process-global ones.
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.14.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Change of provenance
The repository or configuration that created these release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| genkit_otel-0.14.0.tar.gz | 29.8 kB | With provenance | Details for genkit_otel-0.14.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| genkit_otel-0.14.0-py3-none-any.whl | Python 3 | none | any | Details for genkit_otel-0.14.0-py3-none-any.whl |
Total release size: 52.0 kB
Release files / genkit_otel-0.14.0.tar.gz
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | genkit_otel-0.14.0.tar.gz |
|---|---|
| Size | 29.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03970136af0cfeb1988aa40d4816a5fc9dd0a5d41b283e1fc9a8a5cc7b8d1a9c
|
|
BLAKE2b-256 checksum How to use checksums |
5d29bed6314ad54ad14c4b25086acc894a24bd2516a20781497ea8703e16bded
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 19, 2026.
Transparency logRelease files / genkit_otel-0.14.0-py3-none-any.whl
Change of provenance
This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.
We recommend inspecting the repository and configuration before proceeding. View details.
| Download URL | genkit_otel-0.14.0-py3-none-any.whl |
|---|---|
| Size | 22.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6811bae653c1739e0c8100fd2df41a219825df65d2d11c296dc3c8236666b8d0
|
|
BLAKE2b-256 checksum How to use checksums |
01c52cd44058300734d93017d40cd486ea2311fb1c7a4a42042125dac5a50ce8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 19, 2026.
Transparency logSecurity for genkit-otel 0.14.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.
Change of provenance
The repository and configuration that created this release differ from a previous release.
While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.
Repository
- Removed 0.13.0 github.com/genkit-ai/genkit
- Added 0.14.0 github.com/genkit-ai/genkit-python
Attestation for genkit_otel-0.14.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 19, 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.