OpenTelemetry Instrumentation for Requests

Automatic distributed tracing for Python's requests HTTP library

Library
PyPI
v0.66b0
1,102 stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
94 /100 Excellent
Development Activity 96
Maintenance 100
Community 80
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
79 /100 Good
Architecture 82
Code Quality 87
Innovation 70
Learning Curve 76

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 RequestsInstrumentor that patches requests.Session globally 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

Python
68%
Other

Baserow

Databases · No Code Platforms

6,012

Open-source no-code platform to build databases, apps, automations, and AI agents — self-hosted or cloud, with full data ownership.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Python 68%
JavaScript 16%
Vue 11%
Updated 1 weeks ago
TypeScript
91%
Apache 2.0

Helicone

AI Development · Analytics · Monitoring

6,182

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.

View details
70
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 91%
Updated 3 weeks ago
TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,378

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
67
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 months ago
Python
64%
Other

Keep

Automation · Devops · Monitoring

12,359

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.

View details
89
Repo Health
79
Technical
66
Dependency
Built with
Python 64%
TypeScript 36%
Updated 2 weeks ago
Python
69%
MIT

Langflow

AI Agents · AI Development

155,319

Build, test, and deploy AI agents and RAG workflows visually with native API and MCP server export.

View details
90
Repo Health
85
Technical
65
Dependency
Built with
Python 69%
TypeScript 22%
Updated 1 weeks ago
Python
37%
Other

Open WebUI

AI Agents · AI Assistants

153,390

The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.

View details
91
Repo Health
75
Technical
66
Dependency
Built with
Python 37%
Svelte 34%
JavaScript 21%
Updated 1 weeks ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

39,975

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.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 1 weeks ago
Python
91%
GPL 3.0

Weblate

Developer Tools

6,094

Continuous localization platform that commits translations directly into your version control system with full translator attribution.

View details
95
Repo Health
86
Technical
67
Dependency
Built with
Python 91%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers