Conversation
Adds HTTPX as a supported instrument, using the existing opentelemetry-instrumentation-httpx package from otel-contrib. - Add HTTPX enum value to Instruments - Add init_httpx_instrumentor() function - Add opentelemetry-instrumentation-httpx dependency Behaves like REQUESTS/URLLIB3 instrumentation - uses excluded_urls to avoid tracing internal otel exporter calls. Fixes traceloop#2283 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds HTTPX instrumentation support: dependency for OpenTelemetry HTTPX instrumentor, a new Changes
Sequence Diagram(s)sequenceDiagram
participant SDK as traceloop-sdk
participant Init as init_instrumentations()
participant HTTPXCheck as httpx installed?
participant OTEL as opentelemetry.instrumentation.httpx
participant HTTPXInstr as HTTPXClientInstrumentor
SDK->>Init: request instrumentation for Instruments.HTTPX
Init->>HTTPXCheck: verify httpx availability
HTTPXCheck-->>Init: httpx present
Init->>OTEL: import HTTPXClientInstrumentor
OTEL-->>Init: class HTTPXClientInstrumentor
Init->>HTTPXInstr: create instrumentor instance
HTTPXInstr-->>Init: instance
Init->>HTTPXInstr: instrument() (if not already instrumented)
HTTPXInstr-->>Init: success / exception
Init-->>SDK: return success status
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Important
Looks good to me! 👍
Reviewed everything up to a1732f3 in 45 seconds. Click for details.
- Reviewed
59lines of code in3files - Skipped
0files when reviewing. - Skipped posting
4draft comments. View those below. - Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/traceloop-sdk/pyproject.toml:18
- Draft comment:
Dependency 'opentelemetry-instrumentation-httpx>=0.59b0' is added correctly and matches the versions used for other instrumentors. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
2. packages/traceloop-sdk/traceloop/sdk/instruments.py:16
- Draft comment:
The HTTPX enum value is added in the correct alphabetical order. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
3. packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py:507
- Draft comment:
The HTTPX branch in init_instrumentations follows the pattern used for other instrumentors. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
4. packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py:741
- Draft comment:
The init_httpx_instrumentor function is implemented consistently with other instrumentors. Consider verifying that the multi-line EXCLUDED_URLS string is correctly handled by HTTPXClientInstrumentor. - Reason this comment was not posted:
Confidence changes required:0%<= threshold50%None
Workflow ID: wflow_hNkK27eB4hVeybzc
You can customize by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/traceloop-sdk/traceloop/sdk/tracing/tracing.py`:
- Around line 741-752: The init_httpx_instrumentor function currently calls
HTTPXClientInstrumentor.instrument(excluded_urls=EXCLUDED_URLS) which will raise
a TypeError because HTTPXClientInstrumentor.instrument does not accept an
excluded_urls parameter; update the call in init_httpx_instrumentor to simply
instrumentor.instrument() and remove the excluded_urls argument (leave
EXCLUDED_URLS unused here and, if URL exclusion is required for httpx, configure
it via the OTEL_PYTHON_HTTPX_EXCLUDED_URLS or OTEL_PYTHON_EXCLUDED_URLS
environment variables).
HTTPXClientInstrumentor.instrument() doesn't accept excluded_urls as a parameter - it reads from OTEL_PYTHON_HTTPX_EXCLUDED_URLS environment variable instead. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The |
Summary
Instruments.HTTPXenum valueinit_httpx_instrumentor()function usingopentelemetry-instrumentation-httpxfrom otel-contribopentelemetry-instrumentation-httpx>=0.59b0This lets users enable httpx tracing the same way they use requests/urllib3:
Behaves like the existing REQUESTS instrumentation - uses
excluded_urlsto avoid tracing internal otel exporter calls.Test plan
Fixes #2283
🤖 Generated with Claude Code
Important
Add HTTPX instrumentation support using OpenTelemetry in the Traceloop SDK.
Instruments.HTTPXenum value ininstruments.py.init_httpx_instrumentor()function intracing.pyto initialize HTTPX instrumentation usingopentelemetry-instrumentation-httpx.excluded_urlsto avoid tracing internal otel exporter calls, similar to REQUESTS instrumentation.opentelemetry-instrumentation-httpx>=0.59b0topyproject.tomldependencies.instruments.py.init_httpx_instrumentor()follows existing pattern for initialization intracing.py.This description was created by
for a1732f3. You can customize this summary. It will automatically update as commits are pushed.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.