Skip to content

feat(traceloop-sdk): add HTTPX instrumentation support#4351

Open
abhi-0203 wants to merge 1 commit into
traceloop:mainfrom
abhi-0203:feature/httpx-instrumentation
Open

feat(traceloop-sdk): add HTTPX instrumentation support#4351
abhi-0203 wants to merge 1 commit into
traceloop:mainfrom
abhi-0203:feature/httpx-instrumentation

Conversation

@abhi-0203

@abhi-0203 abhi-0203 commented Jul 7, 2026

Copy link
Copy Markdown

Summary

Adds HTTPX client instrumentation support to OpenLLMetry, implementing feature request from issue #2283.

Changes

  • Added Instruments.HTTPCLIENT = 'httpclient' to the Instruments enum
  • Added init_httpclient_instrumentor() function that initializes HTTPXClientInstrumentor
  • Added httpx instrumentation init in the _initialize_instrument() dispatcher
  • Added opentelemetry-instrumentation-httpx>=0.59b0 as a dependency in pyproject.toml

Usage

from traceloop.sdk import Traceloop
from traceloop.sdk.instruments import Instruments

Traceloop.init(
    app_name="my-app",
    instruments={Instruments.HTTPCLIENT},
)

Closes

Closes #2283

Summary by CodeRabbit

  • New Features
    • Added support for HTTP client tracing, expanding the app’s instrumentation options.
    • Improved automatic detection and setup so HTTP client requests can be traced when the relevant package is available.

Adds Instruments.HTTPCLIENT to enable httpx client tracing via
opentelemetry-instrumentation-httpx.

This implements feature request from issue traceloop#2283.

Changes:
- Add HTTPCLIENT = 'httpclient' to Instruments enum
- Add init_httpclient_instrumentor() function
- Add httpx instrumentation init in _initialize_instrument()
- Add opentelemetry-instrumentation-httpx as a dependency

Closes traceloop#2283
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Abhiram seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6388fd1c-ea2e-47f7-9e6c-b7c6147531c8

📥 Commits

Reviewing files that changed from the base of the PR and between 93429cf and d7e0e85.

📒 Files selected for processing (3)
  • packages/traceloop-sdk/pyproject.toml
  • packages/traceloop-sdk/traceloop/sdk/instruments.py
  • packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py

📝 Walkthrough

Walkthrough

This PR adds HTTPX client instrumentation support to the traceloop-sdk. A new HTTPCLIENT enum member is added to Instruments, a new dependency on opentelemetry-instrumentation-httpx is declared, and a new init_httpclient_instrumentor() function is wired into init_instrumentations.

Changes

HTTPX Instrumentation Support

Layer / File(s) Summary
Instrument enum and dependency declaration
packages/traceloop-sdk/traceloop/sdk/instruments.py, packages/traceloop-sdk/pyproject.toml
Adds HTTPCLIENT = "httpclient" to the Instruments enum and declares opentelemetry-instrumentation-httpx>=0.59b0 as a required dependency.
HTTPX instrumentor initialization and wiring
packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py
Adds init_httpclient_instrumentor() which instruments httpx via HTTPXClientInstrumentor when available and not already instrumented, and wires it into init_instrumentations via a new elif branch for Instruments.HTTPCLIENT.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant init_instrumentations
  participant init_httpclient_instrumentor
  participant HTTPXClientInstrumentor

  Caller->>init_instrumentations: Instruments.HTTPCLIENT
  init_instrumentations->>init_httpclient_instrumentor: call
  init_httpclient_instrumentor->>HTTPXClientInstrumentor: instrument()
  HTTPXClientInstrumentor-->>init_httpclient_instrumentor: success/failure
  init_httpclient_instrumentor-->>init_instrumentations: return True/False
Loading

Related issues: #2283 – requests support for httpx instrumentation, addressed by adding Instruments.HTTPCLIENT.

Suggested labels: enhancement, feature

Suggested reviewers: nirga

🐰 A rabbit hopped through httpx's door, Instrumented calls it never wired before, An enum grew, a package too, Tracing now sees requests anew, Hop, hop, hooray — one dependency more!
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding HTTPX instrumentation support to traceloop-sdk.
Linked Issues check ✅ Passed The PR adds the enum, dependency, and initializer needed for HTTPX support as requested in #2283.
Out of Scope Changes check ✅ Passed The changes stay focused on HTTPX instrumentation support and related dependency wiring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 Feature: Add instruments support for httpx

2 participants