Skip to content

Commit

Permalink
FAAS_ID to CLOUD_RESOURCE_ID, FAAS_EXECUTION to FAAS_INVOCATION_ID
Browse files Browse the repository at this point in the history
  • Loading branch information
tammy-baylis-swi committed Mar 18, 2024
1 parent 71eafe9 commit 391ff2a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ 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 @@ -340,17 +339,17 @@ def _instrumented_lambda_handler_call( # noqa pylint: disable=too-many-branches
if span.is_recording():
lambda_context = args[1]
# NOTE: The specs mention an exception here, allowing the
# `ResourceAttributes.FAAS_ID` attribute to be set as a span
# `SpanAttributes.CLOUD_RESOURCE_ID` attribute to be set as a span
# attribute instead of a resource attribute.
#
# See more:
# https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/faas.md#example
# https://github.com/open-telemetry/semantic-conventions/blob/main/docs/faas/aws-lambda.md#resource-detector
span.set_attribute(
ResourceAttributes.FAAS_ID,
SpanAttributes.CLOUD_RESOURCE_ID,
lambda_context.invoked_function_arn,
)
span.set_attribute(
SpanAttributes.FAAS_EXECUTION,
SpanAttributes.FAAS_INVOCATION_ID,
lambda_context.aws_request_id,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
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 @@ -145,8 +144,8 @@ def test_active_tracing(self):
self.assertSpanHasAttributes(
span,
{
ResourceAttributes.FAAS_ID: MOCK_LAMBDA_CONTEXT.invoked_function_arn,
SpanAttributes.FAAS_EXECUTION: MOCK_LAMBDA_CONTEXT.aws_request_id,
SpanAttributes.CLOUD_RESOURCE_ID: MOCK_LAMBDA_CONTEXT.invoked_function_arn,
SpanAttributes.FAAS_INVOCATION_ID: MOCK_LAMBDA_CONTEXT.aws_request_id,
},
)

Expand Down

0 comments on commit 391ff2a

Please sign in to comment.