-
Notifications
You must be signed in to change notification settings - Fork 827
feature: hydrate AsyncPG span attributes at creation (#3643) #3841
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
base: main
Are you sure you want to change the base?
feature: hydrate AsyncPG span attributes at creation (#3643) #3841
Conversation
4a779d1 to
881bc76
Compare
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.
Which attributes do you need for sampling decisions? If the tests don't fail it looks like we don't have tests for not recording :)
And we need a changelog entry.
The sampler now receives DB system/name/user, DB statement (and parameters when capture_parameters is on), and peer host/port/transport because we hydrate attributes before start_as_current_span. Added tests covering execute and cursor paths with non-recording spans to ensure those attributes are present for sampling decisions, and added a changelog entry |
|
Thanks for contributing! Please also have a look at the docker-tests, and do a |
Hi! Thanks for the feedback — I’ve addressed the formatting issues and updated the docker tests as requested. |
Description
This change enables filtering of AsyncPG spans by moving attribute hydration from inside the span context to before span creation. Previously, spans were created with no attributes and attributes were added after span creation using
span.set_attribute(), which prevented samplers from filtering based on request attributes.The fix moves the
_hydrate_span_from_args()call outside the span context and passes the hydrated attributes directly tostart_as_current_span()using theattributesparameter. This ensures that database attributes (system, name, user, statement, network info) are available during span creation for sampling decisions.Fixes #3643
Type of change
How Has This Been Tested?
The changes were tested by:
attributesparameter is properly passed tostart_as_current_span()in both_do_executeand_do_cursor_executemethodsThe implementation maintains backward compatibility and does not change the external API.
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.