-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Proposal] Accept a Set for metric measurement operations #3947
Conversation
2c82e8c
to
6236f2b
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #3947 +/- ##
=====================================
Coverage 81.7% 81.7%
=====================================
Files 171 171
Lines 12951 12949 -2
=====================================
Hits 10592 10592
+ Misses 2136 2134 -2
Partials 223 223
|
Benchmark of counter Add
|
@MrAlias Nice comparison! It would be great to also show the difference when one can keep reusing the attributes set. // Old API
func BenchmarkCounterAddMultiUseAttrs(b *testing.B) {
ctx, _, cntr := benchCounter(b)
attrs := []attribute.KeyValue{attribute.Int("K", i)}
for i := 0; i < b.N; i++ {
cntr.Add(ctx, 1, attrs...)
}
} // New API
func BenchmarkCounterAddMultiUseAttrs(b *testing.B) {
ctx, _, cntr := benchCounter(b)
attrs := attribute.NewSet(attribute.Int("K", i))
for i := 0; i < b.N; i++ {
cntr.Add(ctx, 1, attrs)
}
} |
@merlimat what you describe is the |
thanks! My bad, I couldn't find the updated benchmark code in the PR. |
s := attribute.NewSet( | ||
attribute.Int("", i), | ||
attribute.Int("K", i), | ||
) |
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.
Why are some of the Sets created within the loop and some not?
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.
Some of them depend on the loop variable and others do not.
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.
Prevents data races when a user passes the same attribute slice to multiple measurement operations concurrently.
This doesn't solve the actual underlying cause (NetSet has a datarace in it), but I think that can be solved in a different issue.
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.
After few days of digesting the design and my thoughts, I support this change. I also left a comment in the issue.
Closing in favor of #3971 |
Resolves #3943
attribute.Set
for all measurement methods instead of having each method create its ownattribute.Set
for the same data.Footnotes
https://github.com/open-telemetry/opentelemetry-specification/blob/9352c2524ac03b31f4b845323b351d32ab3adb43/specification/metrics/api.md#concurrency-requirements ↩