Skip to content

Commit 01a476f

Browse files
committed
port int
1 parent d050c37 commit 01a476f

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

sentry_sdk/integrations/socket.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,14 @@ def getaddrinfo(
118118
span.set_attribute(
119119
SPANDATA.SERVER_ADDRESS, host.decode(errors="replace")
120120
)
121+
121122
if isinstance(port, int):
122123
span.set_attribute(SPANDATA.SERVER_PORT, port)
123-
elif isinstance(port, str):
124-
span.set_attribute(SPANDATA.SERVER_PORT, port)
125-
elif isinstance(port, bytes):
126-
span.set_attribute(
127-
SPANDATA.SERVER_PORT, port.decode(errors="replace")
128-
)
124+
elif port is not None:
125+
try:
126+
span.set_attribute(SPANDATA.SERVER_PORT, int(port))
127+
except (ValueError, TypeError):
128+
pass
129129

130130
return real_getaddrinfo(host, port, family, type, proto, flags)
131131
else:

0 commit comments

Comments
 (0)