fix(tracing): apiName determination with event listeners #2651
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PR fixes an issue with incorrect
apiName
determination in tracing when using event listeners. Here's what was happening:When using sync event listeners, the stack trace would include internal implementation details from the
_impl_to_api_mapping
module, which acts as glue between user code and internal code. We expect no other function between the implementation and the user call-side. This caused the API name to be incorrectly determined since these internal frames were being included in the stack analysis.The key changes:
_impl_to_api_mapping
when extracting stack trace informationThe async case worked correctly because async event listeners only schedule
asyncio.Task
s without maintaining the full stack trace.Test Plan:
test_should_correctly_determine_sync_apiname
for both sync and async implementationsall_headers()
andtext()
Fixes #2650