Skip to content

Commit

Permalink
Merge branch 'main' into no-need-tortoiseorm-instrumentation-for-pyda…
Browse files Browse the repository at this point in the history
…ntic
  • Loading branch information
ocelotl authored Apr 17, 2024
2 parents 1343f65 + 82b0795 commit 1800f0d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,17 +340,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 @@ -145,8 +145,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,
ResourceAttributes.CLOUD_ACCOUNT_ID: MOCK_LAMBDA_CONTEXT.invoked_function_arn.split(
":"
)[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ def test_task_raises(self):

self.assertIn(SpanAttributes.EXCEPTION_STACKTRACE, event.attributes)

self.assertEqual(
event.attributes[SpanAttributes.EXCEPTION_TYPE], "CustomError"
# TODO: use plain assertEqual after 1.25 is released (https://github.com/open-telemetry/opentelemetry-python/pull/3837)
self.assertIn(
"CustomError", event.attributes[SpanAttributes.EXCEPTION_TYPE]
)

self.assertEqual(
Expand Down

0 comments on commit 1800f0d

Please sign in to comment.