metrics: Remove labels from gauge metrics#4606
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4606 +/- ##
==========================================
+ Coverage 54.20% 54.23% +0.03%
==========================================
Files 402 402
Lines 51830 51789 -41
==========================================
- Hits 28096 28090 -6
+ Misses 21370 21339 -31
+ Partials 2364 2360 -4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Implemented a PR as suggested in the issue with removing labels functionality from gauges but not convinced that this is the right approach. This issue was filed as tech debt following #2508 which removed expiration functionality from gauges which could trigger memory leaks if used with unbound label dataset but the same functionality exists and is actually used in My suggestion is to discard the issue and file a new one which would deal with both potential sources of memory leaks in a manner that doesn't remove functionality. |
Gauges had optional, unusued, arguments allowing user to set labels on multiple values per single gauge struct. This had potential to leak memory if unbound datasets were used as labels.
2a4adc1 to
8436b1c
Compare
|
Perhaps a better solution would be to allow labels but require labels to be associated with a enum bitmask so that no unbounded labels are allowed across both gauges and counters? |
winder
left a comment
There was a problem hiding this comment.
Seems fine to me. I tagged Brian, since he's actually using these gauges.
brianolson
left a comment
There was a problem hiding this comment.
Yes! For bonus points, note that all calls to Set() (there are no calls to Add()) are casting to float64 and that's weird. If they took int64 or uint64 we could use sync/atomic which is faster than mutex.Lock()/Unlock()
I can do it but |
|
I think the bonus round of making gauges faster through sync/atomic should wait for a second PR and this one should just go in as is. |
Summary
Gauges have optional, currently unused, arguments allowing user to set labels on multiple values per single gauge struct. This has potential to leak memory if unbound datasets were used as labels.
Closes #3040
Test Plan
Current tests pass as well as the new modified one. The format of a line of output from
WriteMetricis the same except for the labels added by the test:old:
metric_test_name1{pid="5824",host="algo-suvak-mbp.lan",host_name="host_one",session_id="AFX-229",pid="123",data_host="host0"}:150new
gauge_0{host_name="host_one",session_id="AFX-229",pid="5229",host="algo-suvak-mbp.lan"}:606