Skip to content

Commit 8b758b2

Browse files
committed
ref(boto3): move DEFAULT_PORTS to consts.py
1 parent f1a17de commit 8b758b2

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎sentry_sdk/integrations/boto3/_instrumentation.py‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
import sentry_sdk
55
from sentry_sdk.consts import OP, SPANDATA, SPANSTATUS
66
from sentry_sdk.integrations import DidNotEnable
7-
from sentry_sdk.integrations.boto3.consts import AWS_RPC_SYSTEM_NAME, IDENTIFIER, ORIGIN
7+
from sentry_sdk.integrations.boto3.consts import (
8+
AWS_RPC_SYSTEM_NAME,
9+
DEFAULT_PORTS,
10+
IDENTIFIER,
11+
ORIGIN,
12+
)
813
from sentry_sdk.traces import NoOpStreamedSpan, StreamedSpan
914
from sentry_sdk.tracing import BAGGAGE_HEADER_NAME, Span
1015
from sentry_sdk.tracing_utils import (
@@ -47,22 +52,17 @@ def _get_server_attributes(endpoint_url: "Optional[str]") -> "Attributes":
4752
if not endpoint_url:
4853
return {}
4954

50-
default_ports = {
51-
"http": 80,
52-
"https": 443,
53-
}
54-
5555
try:
5656
parsed_url = urlsplit(endpoint_url)
57-
if parsed_url.scheme not in default_ports or not parsed_url.hostname:
57+
if parsed_url.scheme not in DEFAULT_PORTS or not parsed_url.hostname:
5858
return {}
5959

6060
# `server.port` is only defined together with `server.address`.
6161
# Infer the effective port when the configured HTTP(S) endpoint omits it.
6262
# https://opentelemetry.io/docs/specs/semconv/rpc/rpc-spans/
6363
return {
6464
SPANDATA.SERVER_ADDRESS: parsed_url.hostname,
65-
SPANDATA.SERVER_PORT: parsed_url.port or default_ports[parsed_url.scheme],
65+
SPANDATA.SERVER_PORT: parsed_url.port or DEFAULT_PORTS[parsed_url.scheme],
6666
}
6767

6868
except (TypeError, UnicodeError, ValueError):

‎sentry_sdk/integrations/boto3/consts.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@
44
# value is used by `rpc.system` (deprecated in OTel, but we still support it for now) and `rpc.system.name`
55
# https://opentelemetry.io/docs/specs/semconv/cloud-providers/aws-sdk/#aws-sdk-spans
66
AWS_RPC_SYSTEM_NAME = "aws-api"
7+
8+
# default ports for HTTP and HTTPS
9+
DEFAULT_PORTS = {
10+
"http": 80,
11+
"https": 443,
12+
}

0 commit comments

Comments
 (0)