tracer: limit the scope of setting the priority when auto dropped #2157
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.
What does this PR do?
Only change the priority of the trace, not the individual span, if it's dropped upon creation. This is a follow up of #2067
Motivation
We only need this because a sampling decision must be made before a chunk is partially flushed. Even though this will create 1 additional allocation, and a ~5% execution time degradation from the current code on main, it will only affect a single span in a trace. Once the decision has been made for the first span in the trace, then that decision will just be used for the remaining spans, so this code won't be reached. Typical use cases wouldn't notice any change in performance. It's also worth noting that this allocation likely would have been created anyway, just later down the line, because the trace priority will be finalized before flushing. Also note that this only creates one more allocation for this benchmark per trace, even though the benchmark makes it look like it's per span, because there is only a single pointer to a float for the entire trace.
Note that this is still better than the original PR, which had a ~10% performance time hit. Though this still probably would have been negligible for users:
Describe how to test/QA your changes
Reviewer's Checklist