Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make child-spans work as expected when using the lambda-runtime #896

Merged
merged 1 commit into from
Jun 19, 2024
Merged

Make child-spans work as expected when using the lambda-runtime #896

merged 1 commit into from
Jun 19, 2024

Conversation

TethysSvensson
Copy link
Contributor

Issue #, if available: N/A

Description of changes: Implementing a sub-span directly in the service_fn does not currently set the parent-span in the expected way. Example:

let func = service_fn(move |event: LambdaEvent<T>| {
    let event_span = create_event_span(outer_variable);
    inner_handler(event, state.clone()).instrument(event_span)
});

The problem is, that at the time where the create_event_span() function is called, the span returned by request_span() has not been entered, so it will be not be set as the parent.

The solution is to enter the span before calling the inner service. This also matches e.g. how tower_http does it.

By submitting this pull request

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I confirm that I've made a best effort attempt to update all relevant documentation.

Copy link
Contributor

@calavera calavera 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 fixing this issue!

@calavera calavera merged commit 92cdd74 into awslabs:main Jun 19, 2024
4 checks passed
@TethysSvensson
Copy link
Contributor Author

And thank you for accepting it!

Are you by any chance planning to do a release for this?

I'm asking because if you are, then I would rather wait for your release than create a work-around in our internal code.

@calavera
Copy link
Contributor

I'm asking because if you are, then I would rather wait for your release than create a work-around in our internal code.

Not this week.

@calavera calavera mentioned this pull request Jun 26, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants