fix(redisotel): fix buggy append in reportPoolStats#3122
Merged
ndyakov merged 3 commits intoredis:masterfrom Aug 5, 2025
Merged
fix(redisotel): fix buggy append in reportPoolStats#3122ndyakov merged 3 commits intoredis:masterfrom
ndyakov merged 3 commits intoredis:masterfrom
Conversation
4ff1439 to
fc5be74
Compare
Member
|
Hello @wzy9607, thank you for the contribution. Can you please add a test for that change with the idleAttrs. Interesting bug and nice catch! |
3426c02 to
b9ac847
Compare
Contributor
Author
done. |
Collaborator
|
Yes, it does indeed have flaws and potential risks. |
ndyakov
previously approved these changes
Apr 2, 2025
Member
|
@monkey92t should we merge? |
Contributor
Author
|
I have solved the merge conflicts, can you take a look again? @monkey92t @ndyakov |
Member
|
@wzy9607 i don't see a response from @monkey92t . Feel free to resolve conflicts and we can merge. |
The current append twice to `conf.attrs` approach in `reportPoolStats` may result in unexpected idleAttrs, due to `append` [can mutate](golang/go#29115 (comment)) the underlying array of the original slice, as demonstrated at <https://go.dev/play/p/jwRMofH91eQ?v=goprev>. Also, I replaced `metric.WithAttributes` in `reportPoolStats` with `metric.WithAttributeSet`, since `WithAttributes` is just `WithAttributeSet` with some extra works that are not needed here, see <https://pkg.go.dev/go.opentelemetry.io/otel/metric@v1.22.0#WithAttributes>.
Contributor
Author
Conflicts resolved. |
ofekshenawa
pushed a commit
that referenced
this pull request
Aug 10, 2025
The current append twice to `conf.attrs` approach in `reportPoolStats` may result in unexpected idleAttrs, due to `append` [can mutate](golang/go#29115 (comment)) the underlying array of the original slice, as demonstrated at <https://go.dev/play/p/jwRMofH91eQ?v=goprev>. Also, I replaced `metric.WithAttributes` in `reportPoolStats` with `metric.WithAttributeSet`, since `WithAttributes` is just `WithAttributeSet` with some extra works that are not needed here, see <https://pkg.go.dev/go.opentelemetry.io/otel/metric@v1.22.0#WithAttributes>. Co-authored-by: Nedyalko Dyakov <1547186+ndyakov@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 current append twice to
conf.attrsapproach inreportPoolStatsmay result in unexpected idleAttrs, due toappendcan mutate the underlying array of the original slice, as demonstrated at https://go.dev/play/p/jwRMofH91eQ?v=goprev and below.Also, I replaced
metric.WithAttributesinreportPoolStatswithmetric.WithAttributeSet, sinceWithAttributesis justWithAttributeSetwith some extra works that are not needed here, see https://pkg.go.dev/go.opentelemetry.io/otel/metric@v1.22.0#WithAttributes.demonstration of the bug
outputs
while the intended result in
reportPoolStatsusecase isidle: [{a {4 0 a <nil>}} {b {4 0 b <nil>}} {c {4 0 c <nil>}} {state {4 0 idle <nil>}}].