opentelemetry-instrumentation-transformers
OpenTelemetry transformers instrumentation
What it is and what it does
This package wraps HuggingFace Transformers library calls with OpenTelemetry instrumentation, automatically capturing text generation and embedding operations as distributed traces. Once initialized with a single call to `TransformersInstrumentor().instrument()`, it intercepts Transformers API calls and records them as spans containing prompts, completions, and embeddings—useful for debugging model behavior, tracking inference patterns, and correlating LLM calls with the rest of your application's trace data.
By default, all content (prompts and outputs) is logged to span attributes for full visibility. For privacy-sensitive applications or to reduce trace size, you can disable content logging via the `TRACELOOP_TRACE_CONTENT` environment variable. The package requires Python 3.10 or later and depends on opentelemetry-api, opentelemetry-instrumentation, opentelemetry-semantic-conventions-ai, and opentelemetry-semantic-conventions.
Use it for:
- Debug LLM application behavior by inspecting prompts and completions in distributed traces
- Monitor text generation performance and latency across your application infrastructure
- Correlate Transformers calls with upstream requests and downstream database operations in end-to-end traces
- Audit model inputs and outputs for compliance or quality evaluation in production systems
- Reduce trace verbosity in privacy-critical deployments by disabling content logging
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Adds distributed tracing to HuggingFace Transformers library calls, capturing prompts, completions, and embeddings as OpenTelemetry spans for observability and debugging.
Yes, if you use HuggingFace Transformers and already have OpenTelemetry infrastructure in place. The package is actively maintained, has no known vulnerabilities, installs with low friction, and solves a real observability gap for LLM applications. Start with it if you need visibility into Transformers calls; skip it if you have no tracing backend or don't use Transformers.
Install
opentelemetry-instrumentation-transformers on PyPI
pip
pip install opentelemetry-instrumentation-transformersuv
uv add opentelemetry-instrumentation-transformerspoetry
poetry add opentelemetry-instrumentation-transformersInstalling opentelemetry-instrumentation-transformers
Before you install
Low friction install with four runtime dependencies on OpenTelemetry core packages. Actively maintained with a release 4 days old and recent commits; part of a well-starred observability project.
License in practice
Apache-2.0 permissive license allows use in most commercial and open-source projects without significant restrictions.
Quickstart
pip install opentelemetry-instrumentation-transformers
from opentelemetry.instrumentation.transformers import TransformersInstrumentor
TransformersInstrumentor().instrument()
Requires Python 3.10 or later; requires an active OpenTelemetry tracing backend to export spans.
Verify before relying
- Which specific Transformers library versions are compatible with this instrumentation
- Whether instrumentation works with both local and remote model inference
- Performance overhead of tracing on typical inference workloads
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (<4,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 4 — opentelemetry-api, opentelemetry-instrumentation, opentelemetry-semantic-conventions-ai, opentelemetry-semantic-conventions |
| Maintenance | actively maintained — 4 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,847,828/month — #1,835 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: opentelemetry_instrumentation_transformers-0.62.3-py3-none-any.whl
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
opentelemetry-instrumentation-langchainAdds distributed tracing to Langchain LLM…
permissive · top 5,000 on PyPI
openfeature-hooks-opentelemetryAutomatically captures feature flag evaluations…
permissive · top 15,000 on PyPI
opentelemetry-instrumentation-bedrockAdds distributed tracing to AWS Bedrock API…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-watsonxAutomatically captures and traces IBM Watsonx…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-llamaindexAdds distributed tracing to LlamaIndex…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-openaiCaptures traces of OpenAI API calls (prompts,…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-haystackAdds distributed tracing to Haystack LLM…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-replicateAdds OpenTelemetry tracing to Replicate API…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-google-generativeaiAutomatically traces prompts, completions, and…
permissive · top 5,000 on PyPI
opentelemetry-instrumentation-litellmAdds OpenTelemetry tracing to LiteLLM,…
permissive · top 15,000 on PyPI