-
Notifications
You must be signed in to change notification settings - Fork 959
fix micrometer bridge auto configuration annotation #13083
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
Changes from 7 commits
293532b
b16bd81
ebb1ec1
d9dd0c0
e1da70e
a5b122b
84abdcc
e0e55bf
ad052db
0061864
57e3ef9
5d67753
3c5d708
01acb0d
b9ae5d1
c24dcb2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,16 @@ dependencies { | |
latestDepTestLibrary("ch.qos.logback:logback-classic:+") | ||
} | ||
|
||
testing { | ||
suites { | ||
val testPrometheus by registering(JvmTestSuite::class) { | ||
dependencies { | ||
runtimeOnly("io.micrometer:micrometer-registry-prometheus:1.14.3") | ||
} | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since there are no source for this suite it won't run any tests as far as I can tell There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK - I had to test this by adding used the setup for stable semconv now |
||
|
||
tasks.withType<Test>().configureEach { | ||
// required on jdk17 | ||
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED") | ||
|
@@ -49,3 +59,9 @@ if (!latestDepTest) { | |
} | ||
} | ||
} | ||
|
||
tasks { | ||
check { | ||
dependsOn(testing.suites) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -7,7 +7,15 @@ | |||
|
||||
import io.micrometer.core.instrument.Clock; | ||||
import io.micrometer.core.instrument.MeterRegistry; | ||||
import io.micrometer.core.instrument.composite.CompositeMeterRegistry; | ||||
import io.opentelemetry.javaagent.instrumentation.micrometer.v1_5.MicrometerSingletons; | ||||
import java.util.ArrayList; | ||||
import java.util.Collections; | ||||
import java.util.Comparator; | ||||
import java.util.LinkedHashSet; | ||||
import java.util.List; | ||||
import java.util.Set; | ||||
import org.springframework.beans.factory.config.BeanPostProcessor; | ||||
import org.springframework.boot.actuate.autoconfigure.metrics.CompositeMeterRegistryAutoConfiguration; | ||||
import org.springframework.boot.actuate.autoconfigure.metrics.export.simple.SimpleMetricsExportAutoConfiguration; | ||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||||
|
@@ -32,4 +40,30 @@ public class OpenTelemetryMeterRegistryAutoConfiguration { | |||
public MeterRegistry otelMeterRegistry() { | ||||
return MicrometerSingletons.meterRegistry(); | ||||
} | ||||
|
||||
@Bean | ||||
static BeanPostProcessor postProcessCompositeMeterRegistry() { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we have a convention of making these methods There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the other bean post processor is also static: Line 34 in 428aa28
|
||||
return new BeanPostProcessor() { | ||||
@Override | ||||
public Object postProcessAfterInitialization(Object bean, String beanName) { | ||||
if (bean instanceof CompositeMeterRegistry) { | ||||
CompositeMeterRegistry original = (CompositeMeterRegistry) bean; | ||||
List<MeterRegistry> list = new ArrayList<>(original.getRegistries()); | ||||
// sort otel registry last | ||||
zeitlinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
list.sort( | ||||
Comparator.comparingInt( | ||||
value -> value == MicrometerSingletons.meterRegistry() ? 1 : 0)); | ||||
Set<MeterRegistry> registries = new LinkedHashSet<>(list); | ||||
return new CompositeMeterRegistry( | ||||
original.config().clock(), Collections.singletonList(original)) { | ||||
@Override | ||||
public Set<MeterRegistry> getRegistries() { | ||||
return registries; | ||||
} | ||||
}; | ||||
} | ||||
return bean; | ||||
} | ||||
}; | ||||
} | ||||
} |
Uh oh!
There was an error while loading. Please reload this page.