diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index 231e87a2c3..5325b6f281 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -393,6 +393,13 @@ class SPANDATA: Example: "10.1.2.80" """ + CLOUD_PROVIDER = "cloud.provider" + """ + Name of the cloud provider. + + Example: "aws" + """ + CLOUD_REGION = "cloud.region" """ The geographical region the resource is running. diff --git a/sentry_sdk/integrations/boto3/_instrumentation.py b/sentry_sdk/integrations/boto3/_instrumentation.py index b56540e5bb..8a05e3c544 100644 --- a/sentry_sdk/integrations/boto3/_instrumentation.py +++ b/sentry_sdk/integrations/boto3/_instrumentation.py @@ -6,6 +6,7 @@ from sentry_sdk.integrations import DidNotEnable from sentry_sdk.integrations.boto3.consts import ( AWS_RPC_SYSTEM_NAME, + CLOUD_PROVIDER, DEFAULT_PORTS, IDENTIFIER, ORIGIN, @@ -156,6 +157,7 @@ def _start_client_span( service_name = ctx.service_id or "unknown" span_name = f"{service_name}.{ctx.operation_name}" attributes: "Attributes" = { + SPANDATA.CLOUD_PROVIDER: CLOUD_PROVIDER, SPANDATA.RPC_METHOD: ctx.operation_name, SPANDATA.RPC_SYSTEM_NAME: AWS_RPC_SYSTEM_NAME, # all client call spans are by default "client" spans. diff --git a/sentry_sdk/integrations/boto3/consts.py b/sentry_sdk/integrations/boto3/consts.py index 7d0d441257..29d5cc6dbb 100644 --- a/sentry_sdk/integrations/boto3/consts.py +++ b/sentry_sdk/integrations/boto3/consts.py @@ -1,5 +1,6 @@ IDENTIFIER = "boto3" ORIGIN = f"auto.http.{IDENTIFIER}" +CLOUD_PROVIDER = "aws" # value is used by `rpc.system` (deprecated in OTel, but we still support it for now) and `rpc.system.name` # https://opentelemetry.io/docs/specs/semconv/cloud-providers/aws-sdk/#aws-sdk-spans diff --git a/tests/integrations/boto3/test_client.py b/tests/integrations/boto3/test_client.py index 9d20c192ca..1113833a80 100644 --- a/tests/integrations/boto3/test_client.py +++ b/tests/integrations/boto3/test_client.py @@ -14,7 +14,11 @@ from sentry_sdk.integrations.boto3 import Boto3Integration from sentry_sdk.integrations.boto3._services.base import _ServiceExtension from sentry_sdk.integrations.boto3._services.registry import _SERVICE_EXTENSIONS -from sentry_sdk.integrations.boto3.consts import AWS_RPC_SYSTEM_NAME, ORIGIN +from sentry_sdk.integrations.boto3.consts import ( + AWS_RPC_SYSTEM_NAME, + CLOUD_PROVIDER, + ORIGIN, +) from sentry_sdk.integrations.stdlib import StdlibIntegration from sentry_sdk.traces import Span from tests.integrations.boto3.aws_mock import Body, MockResponse @@ -432,6 +436,7 @@ def test_client_call_has_common_attributes( assert attributes[SPANDATA.RPC_SYSTEM_NAME] == AWS_RPC_SYSTEM_NAME assert attributes[SPANDATA.SENTRY_KIND] == "client" assert attributes[SPANDATA.CLOUD_REGION] == "eu-north-1" + assert attributes[SPANDATA.CLOUD_PROVIDER] == CLOUD_PROVIDER assert attributes[SPANDATA.SERVER_ADDRESS] == server_address assert attributes[SPANDATA.SERVER_PORT] == server_port assert attributes[SPANDATA.HTTP_STATUS_CODE] == 200 @@ -452,6 +457,7 @@ def test_client_call_attributes_are_available_at_span_creation( ignore_spans=[ { "attributes": { + SPANDATA.CLOUD_PROVIDER: CLOUD_PROVIDER, SPANDATA.RPC_METHOD: "HeadObject", SPANDATA.RPC_SERVICE: "S3", SPANDATA.RPC_SYSTEM_NAME: AWS_RPC_SYSTEM_NAME,