-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Describe the bug
When injecting multiple microprofile metrics into a Quarkus managed bean using constructor injection, only the first such metric has the expected "scope=application" tag. Simply changing the bean to use field injection instead of constructor injection works around this bug.
Expected behavior
Microprofile metrics spec states that metrics should include a "scope" tag.
Actual behavior
The first microprofile counter injected into the constructor has the "scope" tag, but subsequent metrics injected this way lack the "scope" tag.
How to Reproduce?
microprofile-metric-tags-ctor-injection.tar.gz
The attached project constructor injects two microprofile counters.
@Path("/hello")
public class GreetingResource {
private final Counter first;
private final Counter second;
@Inject
public GreetingResource(
@Metric(name = "first-counter") final Counter first,
@Metric(name = "second-counter") final Counter second) {
this.first = Objects.requireNonNull(first);
this.second = Objects.requireNonNull(second);
}
the QuarkusTest included in the project fails, because the second counter lacks the "scope" tag.
java.lang.AssertionError: Expected to find a tag with key 'scope' on counter MeterId{name='second-counter', tags=[]}
at org.acme.GreetingResourceTest.lambda$counter_has_expected_tags$2(GreetingResourceTest.java:30)
at java.base/java.util.Optional.ifPresentOrElse(Optional.java:198)
at org.acme.GreetingResourceTest.counter_has_expected_tags(GreetingResourceTest.java:25)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
Output of uname -a
or ver
Darwin pixee-mbp-gilday.localdomain 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64
Output of java -version
openjdk version "17.0.9" 2023-10-17 OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9) OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode)
Quarkus version or git rev
3.6.1
Build tool (ie. output of mvnw --version
or gradlew --version
)
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae) Maven home: /Users/jgilday/.m2/wrapper/dists/apache-maven-3.9.6-bin/3311e1d4/apache-maven-3.9.6 Java version: 17.0.9, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "14.1.2", arch: "aarch64", family: "mac"
Additional information
No response