dlmarion commented on code in PR #5021:
URL: https://github.com/apache/accumulo/pull/5021#discussion_r1821658159
##########
server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsInfoImpl.java:
##########
@@ -180,98 +100,75 @@ public void addMetricsProducers(MetricsProducer...
producer) {
"called addMetricsProducers() without providing at least one
producer - this has no effect");
return;
}
- lock.lock();
- try {
- if (composite == null) {
- producers.addAll(Arrays.asList(producer));
- } else {
- Arrays.stream(producer).forEach(p -> p.registerMetrics(composite));
- }
- } finally {
- lock.unlock();
- }
- }
- @Override
- public MeterRegistry getRegistry() {
- lock.lock();
- try {
- if (composite == null) {
- throw new IllegalStateException("metrics have not been initialized,
call init() first");
- }
- } finally {
- lock.unlock();
+ if (commonTags == null) {
+ producers.addAll(Arrays.asList(producer));
+ } else {
+ Arrays.stream(producer).forEach(p ->
p.registerMetrics(Metrics.globalRegistry));
}
- return composite;
}
@Override
- public void init() {
+ public synchronized void init(Collection<Tag> tags) {
Review Comment:
It looks like `addMetricsProducers` is almost always called before `init`. I
wonder if we should just change `init` to `init(Collection<Tag> tags,
MetricsProducer... producers)` and get rid of `addMetricProducers`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]