feat: Allow users to register the same Meter multiple times without exception #2017
feat: Allow users to register the same Meter multiple times without exception #2017
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2017 +/- ##
============================================
+ Coverage 83.11% 83.11% +<.01%
- Complexity 2249 2252 +3
============================================
Files 319 319
Lines 10527 10529 +2
Branches 1047 1048 +1
============================================
+ Hits 8749 8751 +2
- Misses 1438 1440 +2
+ Partials 340 338 -2
Continue to review full report at Codecov.
|
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.
LGTM except for one minor comment.
impl_core/src/test/java/io/opencensus/implcore/metrics/MetricRegistryImplTest.java
Outdated
Show resolved
Hide resolved
As discussed, please add test for
|
impl_core/src/test/java/io/opencensus/implcore/metrics/MetricRegistryImplTest.java
Show resolved
Hide resolved
@rghetia please review and approve when you get a chance, thank you :) |
throw new IllegalArgumentException( | ||
"A different metric with the same name already registered."); | ||
if (!existingMeter.getMetricDescriptor().equals(meter.getMetricDescriptor())) { | ||
throw new IllegalArgumentException( |
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.
(Note, this comment is not relevant for this PR, and is only intended for discussing whether this fix would also fix this specific issue for the Spanner client library).
@mayurkale22 Can you confirm that registering multiple metrics with different label values (but equal label keys) will not go down this code path?
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.
Can you confirm that registering multiple metrics with different label values (but equal label keys) will not go down this code path?
Yes, it is normal to have different label values - those will be represented as individual TimeSeries in the metric. i.e:
Metric:
{name, label_keys, description, unit, type, ...}
TimeSeries
[{labels_values1, value1}, {labels_values2, value2}, ...]
The exception will be raised only when you use the same metric name but with a different type or unit or label_keys.
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.
That sounds good 👍 Thanks for looking into this.
I think this fix is better than what I added to the Spanner client library, so I'll close the PR.
The only concern that I still have is what it looks like in the dashboards when there are multiple different instances of a SessionPool
with the same label values. I understand that it won't cause any errors in the client library, but how is it presented to the user? This situation would occur when an application is opening two connections to the same database with different SessionPoolOptions
. This would also mean different values for constant metrics like MaxSessions
.
No description provided.