Commit 6ba96f2
fix(llmobs): support HTTPS_PROXY setting [backport 3.18] (#15165)
Backport 7bc20af from #15130 to 3.18.
The built in `http.client` that we use does not support the
HTTP{S}_PROXY environment variable (or proxying in general). AI tells me
that the fix is pretty straightforward by extending the client.
## Testing
I manually validated this solution by installing
[squid](https://www.squid-cache.org/) locally with a small test app:
```
# demonstrate the proxy working locally with curl
(.venv) ~/d/dd-trace-py ❯❯❯ HTTPS_PROXY=http://127.0.0.1:3128 curl https://google.com
(.venv) ~/d/dd-trace-py ❯❯❯ tail -n 1 /opt/homebrew/var/logs/squid/access.log
1762370301.555 185 127.0.0.1 TCP_TUNNEL/200 7488 CONNECT google.com:443 - HIER_DIRECT/142.250.81.238 -
(.venv) ~/d/dd-trace-py ❯❯❯ HTTPS_PROXY=http://127.0.0.1:3128 ddtrace-run python openai-app.py
(.venv) ~/d/dd-trace-py ❯❯❯ tail -n 2 /opt/homebrew/var/logs/squid/access.log
1762370369.733 169 127.0.0.1 TCP_TUNNEL/200 4049 CONNECT llmobs-intake.datadoghq.com:443 - HIER_DIRECT/3.233.158.217 -
1762370369.845 3857 127.0.0.1 TCP_TUNNEL/200 6469 CONNECT api.openai.com:443 - HIER_DIRECT/162.159.140.245 -
```
and confirmed the trace is sent successfully:
<img width="878" height="75" alt="image"
src="https://github.com/user-attachments/assets/0f76b8c0-82a9-410b-af4e-77364a9d7b70"
/>
## Risks
<!-- Note any risks associated with this change, or "None" if no risks
-->
No impact to non-`HTTPS_PROXY` setting usage so risk is pretty limited.
## Additional Notes
<!-- Any other information that would be helpful for reviewers -->
Co-authored-by: kyle <kyle@verhoog.ca>
Co-authored-by: Yun Kim <35776586+Yun-Kim@users.noreply.github.com>
Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com>1 parent 52b01a3 commit 6ba96f2
File tree
3 files changed
+54
-1
lines changed- ddtrace/llmobs
- releasenotes/notes
3 files changed
+54
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | 29 | | |
31 | 30 | | |
32 | 31 | | |
| |||
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments