Skip to content

Commit

Permalink
Use ResourceAttributes.CLOUD_ACCOUNT_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Mar 21, 2024
1 parent f3421b6 commit 118f91c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def custom_event_context_extractor(lambda_event):
TRACE_HEADER_KEY,
AwsXRayPropagator,
)
from opentelemetry.semconv.resource import ResourceAttributes
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import (
Span,
Expand Down Expand Up @@ -358,11 +359,8 @@ def _instrumented_lambda_handler_call( # noqa pylint: disable=too-many-branches
# See more:
# https://github.com/open-telemetry/semantic-conventions/blob/main/docs/faas/aws-lambda.md#all-triggers
account_id = lambda_context.invoked_function_arn.split(":")[4]

# TODO: Update key with semconvgen 1.23.0
# https://github.com/open-telemetry/semantic-conventions/issues/551
span.set_attribute(
"cloud.account.id",
ResourceAttributes.CLOUD_ACCOUNT_ID,
account_id,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
TRACE_ID_FIRST_PART_LENGTH,
TRACE_ID_VERSION,
)
from opentelemetry.semconv.resource import ResourceAttributes
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import NoOpTracerProvider, SpanKind, StatusCode
Expand Down Expand Up @@ -146,7 +147,7 @@ def test_active_tracing(self):
{
SpanAttributes.CLOUD_RESOURCE_ID: MOCK_LAMBDA_CONTEXT.invoked_function_arn,
SpanAttributes.FAAS_INVOCATION_ID: MOCK_LAMBDA_CONTEXT.aws_request_id,
"cloud.account.id": MOCK_LAMBDA_CONTEXT.invoked_function_arn.split(":")[4],
ResourceAttributes.CLOUD_ACCOUNT_ID: MOCK_LAMBDA_CONTEXT.invoked_function_arn.split(":")[4],
},
)

Expand Down

0 comments on commit 118f91c

Please sign in to comment.