Registry / observability / opentelemetry-instrumentation-replicate

opentelemetry-instrumentation-replicate

JSON →
library0.62.3pypypi✓ verified 24d ago

OpenTelemetry Replicate instrumentation provides automatic tracing for applications using the Replicate Python client, allowing developers to monitor and observe AI/ML model inferences. It is part of the `openllmetry` project and is currently at version 0.58.0, with frequent releases to keep up with OpenTelemetry semantic conventions and new LLM integrations, typically on a weekly or bi-weekly cadence.

pip install opentelemetry-instrumentation-replicate replicate opentelemetry-sdk
INSTALL
IMPORT
SIG · OPENTELEMETRY-INST
O
opentelemetry-instrumentation-replicate
observabilitypythonv0.62.3
Install
5.3s avg
Import
817ms
Disk
37MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.62.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.846s · 37.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.3s · import 0.788s · 38MB
37MB installed
● package 37MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ReplicateInstrumentor
from opentelemetry.instrumentation.replicate import ReplicateInstrumentor

This quickstart demonstrates how to set up the OpenTelemetry SDK with a console exporter, instrument the Replicate client, and then make calls to Replicate. The console will display the generated traces for the Replicate operations.

import os from opentelemetry import trace from opentelemetry.sdk.resources import Resource from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor from opentelemetry.instrumentation.replicate import ReplicateInstrumentor # 1. Setup OpenTelemetry SDK (for demonstration, using ConsoleSpanExporter) resource = Resource.create({"service.name": "replicate-app"}) provider = TracerProvider(resource=resource) processor = SimpleSpanProcessor(ConsoleSpanExporter()) provider.add_span_processor(processor) trace.set_tracer_provider(provider) # 2. Instrument Replicate ReplicateInstrumentor().instrument() # 3. Use Replicate client (ensure REPLICATE_API_TOKEN is set in environment) # For local testing, you might set a dummy value, but real use requires a valid token. os.environ["REPLICATE_API_TOKEN"] = os.environ.get("REPLICATE_API_TOKEN", "r8_DUMMY_TOKEN_FOR_TESTING") import replicate # Example: List models (this operation will be traced) models = replicate.models.list() print(f"Found {len(models)} Replicate models. First one: {models[0].id if models else 'N/A'}") # Example: Create a prediction (this operation will be traced) # Note: This requires a valid Replicate API token and potentially an actual model ID/version try: model_version_id = "stability-ai/sdxl:39edb22c277335607b222fbc6e31ddadead4ad77a102713f01b34e53d5d71c1f" prediction = replicate.predictions.create( version=model_version_id, input={"prompt": "a photo of an astronaut riding a horse on mars"} ) print(f"Replicate prediction created: {prediction.id}") except Exception as e: print(f"Could not create Replicate prediction (check API token and model ID): {e}") print("Traces should be visible in the console.")
Debug
Known issues
breakingStarting from versions around 0.54.0, `openllmetry` (and thus `opentelemetry-instrumentation-replicate`) began conforming to the OpenTelemetry Generative AI Semantic Conventions (GenAI SemConv) version 0.5.0. This significantly changes the names and structure of attributes on spans related to LLM calls. If you have custom dashboards, alerts, or processing pipelines based on older attribute names, these will likely break.
fix
Review the OpenTelemetry GenAI Semantic Conventions (https://opentelemetry.io/docs/specs/semconv/llm/llm-spans/) and update your OTLP consumers, dashboards, and queries to use the new attribute names. For example, 'llm.request.type' might become 'gen_ai.request.type'.
affects: >=0.54.0
gotchaThis instrumentation only tracks calls made via the `replicate` Python client. It does not automatically capture Replicate API calls made through other means (e.g., direct HTTP requests, other SDKs). Ensure all Replicate interactions you wish to trace go through the instrumented `replicate` package.
fix
Always use the `replicate` Python client after `ReplicateInstrumentor().instrument()` has been called if you want to capture traces.
affects: All
gotchaThe `opentelemetry-instrumentation-replicate` package requires the `replicate` library to be installed separately. It is not bundled as a direct dependency to allow for flexible dependency management.
fix
Ensure `pip install replicate` is run in your environment alongside the instrumentation package. A full install command is `pip install opentelemetry-instrumentation-replicate replicate opentelemetry-sdk`.
affects: All
gotchaFor `replicate.predictions.create` to function correctly and avoid API errors, a valid `REPLICATE_API_TOKEN` environment variable must be set. The instrumentation itself does not handle authentication, only tracing successful or failed API calls.
fix
Set the `REPLICATE_API_TOKEN` environment variable with your actual Replicate API key before making any Replicate client calls.
affects: All
Upgrade
Version history
0.62.3latest on PyPI · released Aug 10, 2026
Audit
Dependencies
replicaterequiredThe library instruments the Replicate Python client.
opentelemetry-apirequiredCore OpenTelemetry API for defining traces.
opentelemetry-sdkrequiredRequired for configuring and exporting OpenTelemetry traces.
Agent activity
19 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
opentelemetry-instrumentation-replicate — pip install opentelemetry-instrumentation-replicate · libregistry