Skip to content

Conversation

@herin049
Copy link
Contributor

Description

Fixes bug where the Lambda invocation Span name would be incorrectly set to the name of the Python handler function instead of the function name. Also fixes an issue where the Lambda invocation Span kind would occasionally not be set to SERVER which violates the OpenTelemetry FaaS semantic conventions.

Fixes #3963

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Unit tests have been updated to reflect changing the invocation Span name to the Lambda function name and changing the Span kind to always be SERVER.

Does This PR Require a Core Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added

@herin049 herin049 requested a review from a team as a code owner November 21, 2025 20:03
Copy link
Contributor

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixes and linking the AWS docs in docstring.

@xrmx xrmx moved this to Ready for review in @xrmx's Python PR digest Nov 27, 2025
event_source = lambda_event["Records"][0].get(
"eventSource"
) or lambda_event["Records"][0].get("EventSource")
if event_source in {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are cases where span can be of other kinds:

"The span kind for both types of SQS spans SHOULD be CONSUMER"
https://opentelemetry.io/docs/specs/semconv/faas/aws-lambda/#sqs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xrmx I saw the documentation for SQS events too and I find it a bit ambiguous, but to me it still appears that the parent invocation span type should be SERVER based on the following statement in the spec:

For the SQS event span, if all the messages in the event have the same event source, the name of the span MUST be process. If there are multiple sources in the batch, the name MUST be multiple_sources process. The parent SHOULD be the SERVER span corresponding to the function invocation.

The key phrase being "The parent SHOULD be the SERVER span corresponding to the function invocation."

From what I can tell, both the Java and JavaScript instrumentation libraries always have the initial Span be the SERVER span corresponding to the function invocation, and create additional child Spans for the SQS events.

@xrmx xrmx moved this from Ready for review to Reviewed PRs that need fixes in @xrmx's Python PR digest Nov 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Reviewed PRs that need fixes

Development

Successfully merging this pull request may close these issues.

opentelemetry-instrumentation-aws-lambda: invocation span name and kind do not follow semantic conventions

3 participants