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

Add tracing span with request id to the handler #577

Merged
merged 4 commits into from Dec 16, 2022
Merged

Add tracing span with request id to the handler #577

merged 4 commits into from Dec 16, 2022

Conversation

llgerard
Copy link
Contributor

When logging errors, it is very useful to log the request Id (and xray id if available). But, not every one might want it, so we probably don't want to include it by default in every log.

The solution proposed in this PR is to use a span with fields containing the request id and xray id. Then, to get the request id part of the log messages, one has to enable logging spans in the logger setup (using tracing_subscriber for example).

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.

lambda-runtime/src/lib.rs Outdated Show resolved Hide resolved
Tracing filters by default trim events and *spans* according to the level.
This means that entering a span with a level below the threshold will
be a no-op and the current span is not updated.

The lambda request span is a meaningful info one, so bump to INFO level.
@calavera
Copy link
Contributor

@llgerard can you run cargo fmt and push the code properly formatted?

@llgerard
Copy link
Contributor Author

@calavera I had it formatted already. I reran cargo fmt when changing the name (commit just above), but nothing was changed.

Which part looks improperly formatted?

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.

LGTM

@calavera calavera merged commit 181c5d9 into awslabs:main Dec 16, 2022
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.

None yet

2 participants