Skip to content

Commit 79535e6

Browse files
committed
only add span attrs for proxies
1 parent 63034d6 commit 79535e6

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

sentry_sdk/integrations/stdlib.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def putrequest(
7070
self: "HTTPConnection", method: str, url: str, *args: "Any", **kwargs: "Any"
7171
) -> "Any":
7272
# proxy info is in _tunnel_host/_tunnel_port
73-
host = getattr(self, "_tunnel_host", None) or self.host
73+
tunnel_host = getattr(self, "_tunnel_host", None)
74+
host = tunnel_host or self.host
7475

7576
default_port = self.default_port
7677
tunnel_port = getattr(self, "_tunnel_port", None)
@@ -113,10 +114,10 @@ def putrequest(
113114
span.set_data(SPANDATA.HTTP_QUERY, parsed_url.query)
114115
span.set_data(SPANDATA.HTTP_FRAGMENT, parsed_url.fragment)
115116

116-
# Set network peer address and port (the actual connection endpoint)
117-
# for proxies, these point to the proxy host/port
118-
span.set_data(SPANDATA.NETWORK_PEER_ADDRESS, self.host)
119-
span.set_data(SPANDATA.NETWORK_PEER_PORT, self.port)
117+
if tunnel_host:
118+
# for proxies, these point to the proxy host/port
119+
span.set_data(SPANDATA.NETWORK_PEER_ADDRESS, self.host)
120+
span.set_data(SPANDATA.NETWORK_PEER_PORT, self.port)
120121

121122
rv = real_putrequest(self, method, url, *args, **kwargs)
122123

0 commit comments

Comments
 (0)