Skip to content

Conversation

@sl0thentr0py
Copy link
Member

@sl0thentr0py sl0thentr0py requested a review from a team as a code owner January 13, 2026 15:02
@linear
Copy link

linear bot commented Jan 13, 2026

@sl0thentr0py sl0thentr0py changed the title Handle proxy tunnels in httlib integration feat(stdlib): Handle proxy tunnels in httlib integration Jan 13, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 13, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • feat(asyncio): Add on-demand way to enable AsyncioIntegration by sentrivana in #5288
  • feat(stdlib): Handle proxy tunnels in httlib integration by sl0thentr0py in #5303

Bug Fixes 🐛

  • fix(ai): redact message parts content of type blob by constantinius in #5243
  • fix(clickhouse): Guard against module shadowing by alexander-alderman-webb in #5250
  • fix(gql): Revert signature change of patched gql.Client.execute by alexander-alderman-webb in #5289
  • fix(grpc): Derive interception state from channel fields by alexander-alderman-webb in #5302
  • fix(litellm): Guard against module shadowing by alexander-alderman-webb in #5249
  • fix(pure-eval): Guard against module shadowing by alexander-alderman-webb in #5252
  • fix(ray): Guard against module shadowing by alexander-alderman-webb in #5254
  • fix(threading): Handle channels shadowing by sentrivana in #5299
  • fix(typer): Guard against module shadowing by alexander-alderman-webb in #5253

Documentation 📚

  • docs: Update Python versions banner in README by sentrivana in #5287

Internal Changes 🔧

  • chore(gen_ai): add auto-enablement for google genai by shellmayr in #5295
  • ci(release): Switch from action-prepare-release to Craft by BYK in #5290

🤖 This preview updates automatically when you update the PR.


# Set network peer address and port (the actual connection endpoint)
# for proxies, these point to the proxy host/port
span.set_data(SPANDATA.NETWORK_PEER_ADDRESS, self.host)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are according to otel spec

Comment on lines +76 to +83
tunnel_port = getattr(self, "_tunnel_port", None)
if tunnel_port:
port = tunnel_port
# need to override default_port for correct url recording
if tunnel_port == 443:
default_port = 443
else:
port = self.port

This comment was marked as outdated.

if tunnel_port == 443:
default_port = 443
else:
port = self.port
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proxy port used when tunnel port is unspecified

Low Severity

When _tunnel_host is set but _tunnel_port is None (because set_tunnel was called without specifying a port), the code falls back to self.port which is the proxy port, not the tunnel destination port. This causes incorrect URL recording in the span. For example, if using HTTPConnection("proxy", 8080).set_tunnel("api.example.com") (no port), the recorded URL would incorrectly include :8080. The else branch assumes no tunnel is in use, but _tunnel_host being set indicates tunnel mode where the default port (80/443) is more appropriate than the proxy port.

Fix in Cursor Fix in Web

tunnel_port = getattr(self, "_tunnel_port", None)
if tunnel_port:
port = tunnel_port
# need to override default_port for correct url recording
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest changing the url recording logic instead.

Otherwise, looks good to me!

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.

Wrong host names displayed in "Outbound API Requests" when requests are sent via a proxy.

3 participants