-
Notifications
You must be signed in to change notification settings - Fork 146
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
refactor(tracer): log warning instead of throwing when segment is not found #1370
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the cleanup it tests 👌, much easier to follow now.
The implications of additional undefined
are bigger than I thought. It tears through many methods, similar to isTracingEnabled
and reminds me of java or golang null checks. But I have no immediate answer to make it cleaner.
Thanks!
Indeed, my attempt at somewhat centralising this behavior was to extract it in the provider class. This is also something I've been meaning to do for a while as it'd help decouple the two and open the door for other providers in the future. |
Description of your changes
As reported in #1356, the current behavior of the Tracer and corresponding middleware is fairly unforgiving when it comes to handling missing segments. Prior to this PR, when calling the
getSegment
method, if a segment is not found, an error would be thrown.This can happen either when users try to retrieve the current segment outside of the context of a function invocation or when the trace data is malformed and the X-Ray SDK is not able to derive the current segment.
This behavior, if not handled properly, can cause a function invocation to fail, which might not be desirable given that for many customers tracing is considered best-effort.
This PR:
captureLambdaHandler
middleware in all stages to be more resilientaws-xray-sdk-node
dependency to the latest versionTracer
class to theProviderService
oneThis PR closes #1356.
How to verify this change
Check the existing tests as well as the newly added ones in the checks under this repo. Check also the results of this successful integration test.
Related issues, RFCs
Issue number: #1356
Checklist
Breaking change checklist
Is it a breaking change?: NO
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.