OpenTelemetry Instrumentation for Requests
Automatic distributed tracing for Python's requests HTTP library
Repository Health
Technical Analysis
opentelemetry-instrumentation-requests automatically wraps the popular requests HTTP client library so every outbound HTTP call creates an OpenTelemetry span, with no changes needed at each call site. It captures HTTP method, URL, status code, and (optionally) request/response headers as span attributes following OpenTelemetry’s HTTP semantic conventions.
The instrumentation supports request/response hooks for adding custom span attributes, configurable header capture via environment variables, IP address recording, and User-Agent synthetic-request filtering — making it a drop-in way to get distributed tracing across services that call out over HTTP via requests.
What You Get
- A
RequestsInstrumentorthat patchesrequests.Sessionglobally with one.instrument()call - Automatic HTTP client spans with method, URL, and status code attributes
- Request/response hooks for adding custom span attributes per call
- Configurable capture of specific request/response headers via environment variables
- Support for excluding URLs from tracing and recording client IP addresses
Common Use Cases
- Adding distributed tracing to any service that calls external APIs via
requests - Correlating outbound HTTP calls with the rest of a request’s trace in a microservices architecture
- Auditing and debugging slow or failing third-party API calls with span-level timing
- Capturing custom request/response metadata (headers, hooks) for domain-specific observability needs
Under The Hood
Architecture — the instrumentor subclasses BaseInstrumentor and, on _instrument(), wraps requests.Session.send (the single choke point every requests API funnels through) with a traced version that starts a client span, injects trace context into outgoing headers via the configured propagator, records HTTP semantic-convention attributes, invokes optional request/response hooks, and records the span status from the HTTP response code, restoring the original send on _uninstrument(). Tech Stack — pure Python (src/opentelemetry/instrumentation/requests/__init__.py, ~630 lines), depending on opentelemetry-api, opentelemetry-instrumentation, opentelemetry-semantic-conventions, and opentelemetry-util-http from the same monorepo, plus requests itself as the instrumented target; built with hatchling. Code Quality — extensively tested with over 1,400 lines across three test files (test_requests_integration.py, test_requests_ip_support.py, test_user_agent_synthetic.py) covering header capture, IP recording, and synthetic User-Agent filtering, plus a benchmarks/ suite measuring instrumentation overhead. API Design — a single RequestsInstrumentor().instrument() call instruments every requests call in the process; request/response hooks and header-capture environment variables let teams add custom attributes without subclassing or wrapping the instrumentor.
Used by 8 apps in this directory
Baserow
No Code Platforms · Databases
Open-source no-code platform to build databases, apps, automations, and AI agents — self-hosted or cloud, with full data ownership.
Helicone
Monitoring · AI Development · Analytics
An open-source AI gateway and LLM observability platform that routes requests to 100+ models while logging cost, latency, and full traces for every call.
highlight.io
Developer Tools · Analytics · Monitoring
Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.
Keep
Devops · Automation · Monitoring
The open-source AIOps and alert management platform that unifies 130+ monitoring tools into a single pane of glass with AI-powered correlation, deduplication, and workflow automation.
Langflow
AI Agents · AI Development
Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.
Open WebUI
AI Assistants · AI Agents
The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.
PostHog
Analytics · Monitoring · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
Weblate
Developer Tools
Continuous localization platform that commits translations directly into your version control system with full translator attribution.