Repository: micrometer-metrics/micrometer

Issue #978: Tag deduplication adds extra duplicate tag
Created: 2018-10-30T20:34:37Z
This test run against Micrometer 1.1.0:
@Test
public void tagDeduplication() {
	Tags tags = Tags.of(Tag.of("a",  "alpha"), Tag.of("a",  "alpha"), Tag.of("b", "bravo"));
	assertThat(tags.stream()).hasSize(2);
}
Fails due to the stream containing three tags, two of which are b=bravo:
java.lang.AssertionError: 
Expected size:<2> but was:<3> in:
<[tag(a=alpha), tag(b=bravo), tag(b=bravo)]>
	at test.SomeTests.tagDeduplication(SomeTests.java:20)
	…

Duplicate issue #1010: Metric registerd twice by binder when using spring-legacy
Created: 2018-11-15T09:56:37Z
I am using the micrometer-spring-legacy package and have an issue when using MeterRegistryCustomizers together with the graphite registry. When booting up the application there is a really long stack trace. The root cause can be seen below.
The problem disappears if I remove the MeterRegistryCustomizer from my configuration. Another work around is to configure the GraphiteMeterRegistry and PrometheusMeterRegistry directly with the MeterRegistryCustomizer instead of the MeterRegistry.
My suspicion is that the MeterRegistryConfigurer adds all default binders one to the Graphite MeterRegistry and once to the CompositeRegistry, which seems than to lead to name clashes in the dropwizards MetricRegistry. What I don't understand: Why it doesn't occur when I am not using the MeterRegistryConfigurer.
I have created a minimal spring project to reproduce the problem: slomo/micrometer-graphite-issue-example
I would also fix it myself, given any hint towards the best solution here. Maybe the CombinedMeterRegistry should be exempt from the MeterRegistryConfigurer?
Caused by: java.lang.IllegalArgumentException: A metric named jvmGcMaxDataSize.application.my_application already exists
	at com.codahale.metrics.MetricRegistry.register(MetricRegistry.java:91) ~[metrics-core-3.1.5.jar:3.1.5]
	at io.micrometer.core.instrument.dropwizard.DropwizardMeterRegistry.newGauge(DropwizardMeterRegistry.java:75) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.lambda$gauge$1(MeterRegistry.java:258) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.lambda$registerMeterIfNecessary$5(MeterRegistry.java:528) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.getOrCreateMeter(MeterRegistry.java:580) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:543) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:528) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.gauge(MeterRegistry.java:258) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.Gauge$Builder.register(Gauge.java:190) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.composite.CompositeGauge.registerNewMeter(CompositeGauge.java:58) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.composite.CompositeGauge.registerNewMeter(CompositeGauge.java:27) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.composite.AbstractCompositeMeter.add(AbstractCompositeMeter.java:66) ~[micrometer-core-1.1.0.jar:1.1.0]
	at java.lang.Iterable.forEach(Iterable.java:75) ~[na:1.8.0_181]
	at java.util.Collections$SetFromMap.forEach(Collections.java:5476) ~[na:1.8.0_181]
	at io.micrometer.core.instrument.composite.CompositeMeterRegistry.lambda$null$0(CompositeMeterRegistry.java:65) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.composite.CompositeMeterRegistry.lock(CompositeMeterRegistry.java:184) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.composite.CompositeMeterRegistry.lambda$new$1(CompositeMeterRegistry.java:65) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.getOrCreateMeter(MeterRegistry.java:590) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:543) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.registerMeterIfNecessary(MeterRegistry.java:528) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.MeterRegistry.gauge(MeterRegistry.java:258) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.Gauge$Builder.register(Gauge.java:190) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.core.instrument.binder.jvm.JvmGcMetrics.bindTo(JvmGcMetrics.java:110) ~[micrometer-core-1.1.0.jar:1.1.0]
	at io.micrometer.spring.autoconfigure.MeterRegistryConfigurer.lambda$addBinders$0(MeterRegistryConfigurer.java:85) ~[micrometer-spring-legacy-1.1.0.jar:1.1.0]
	at java.util.ArrayList.forEach(ArrayList.java:1257) ~[na:1.8.0_181]
	at io.micrometer.spring.autoconfigure.MeterRegistryConfigurer.addBinders(MeterRegistryConfigurer.java:85) ~[micrometer-spring-legacy-1.1.0.jar:1.1.0]
	at io.micrometer.spring.autoconfigure.MeterRegistryConfigurer.configure(MeterRegistryConfigurer.java:59) ~[micrometer-spring-legacy-1.1.0.jar:1.1.0]
	at io.micrometer.spring.autoconfigure.MeterRegistryPostProcessor.postProcessAfterInitialization(MeterRegistryPostProcessor.java:67) ~[micrometer-spring-legacy-1.1.0.jar:1.1.0]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-4.3.14.RELEASE.jar:4.3.14.RELEASE]
	... 37 common frames omitted

Closing comment (2018-11-15T19:05:23Z): Actually a snapshot from the current master already works for it. I guess that #978 fixed it and the bug I mentioned above is a separate one.
Duplicate of #978