Skip to content

Commit 07318bd

Browse files
Change AwsLambdaInstrumentor span attrs to meet faas semconv (#2372)
1 parent 99678cc commit 07318bd

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414

1515
- Rename `type` attribute to `asgi.event.type` in `opentelemetry-instrumentation-asgi`
1616
([#2300](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2300))
17+
- Rename AwsLambdaInstrumentor span attributes `faas.id` to `cloud.resource_id`, `faas.execution` to `faas.invocation_id`
18+
([#2372](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2372))
1719

1820
### Added
1921

instrumentation/opentelemetry-instrumentation-aws-lambda/src/opentelemetry/instrumentation/aws_lambda/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,17 @@ def _instrumented_lambda_handler_call( # noqa pylint: disable=too-many-branches
340340
if span.is_recording():
341341
lambda_context = args[1]
342342
# NOTE: The specs mention an exception here, allowing the
343-
# `ResourceAttributes.FAAS_ID` attribute to be set as a span
343+
# `SpanAttributes.CLOUD_RESOURCE_ID` attribute to be set as a span
344344
# attribute instead of a resource attribute.
345345
#
346346
# See more:
347-
# https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/semantic_conventions/faas.md#example
347+
# https://github.com/open-telemetry/semantic-conventions/blob/main/docs/faas/aws-lambda.md#resource-detector
348348
span.set_attribute(
349-
ResourceAttributes.FAAS_ID,
349+
SpanAttributes.CLOUD_RESOURCE_ID,
350350
lambda_context.invoked_function_arn,
351351
)
352352
span.set_attribute(
353-
SpanAttributes.FAAS_EXECUTION,
353+
SpanAttributes.FAAS_INVOCATION_ID,
354354
lambda_context.aws_request_id,
355355
)
356356

instrumentation/opentelemetry-instrumentation-aws-lambda/tests/test_aws_lambda_instrumentation_manual.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def test_active_tracing(self):
145145
self.assertSpanHasAttributes(
146146
span,
147147
{
148-
ResourceAttributes.FAAS_ID: MOCK_LAMBDA_CONTEXT.invoked_function_arn,
149-
SpanAttributes.FAAS_EXECUTION: MOCK_LAMBDA_CONTEXT.aws_request_id,
148+
SpanAttributes.CLOUD_RESOURCE_ID: MOCK_LAMBDA_CONTEXT.invoked_function_arn,
149+
SpanAttributes.FAAS_INVOCATION_ID: MOCK_LAMBDA_CONTEXT.aws_request_id,
150150
ResourceAttributes.CLOUD_ACCOUNT_ID: MOCK_LAMBDA_CONTEXT.invoked_function_arn.split(
151151
":"
152152
)[

0 commit comments

Comments
 (0)