Skip to content

Commit

Permalink
Micrometer: use method for generated mp gauge obj
Browse files Browse the repository at this point in the history
  • Loading branch information
ebullient committed Sep 16, 2021
1 parent 67b5f67 commit 726327e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ static void processAnnotatedGauges(IndexView index, ClassOutput classOutput) {
verifyGaugeScope(target, classInfo);

// Create a GaugeAdapter bean that uses the instance of the bean and invokes the callback
final String generatedClassName = classInfo.name().toString() + "_GaugeAdapter";
final String generatedClassName = String.format("%s_%s_GaugeAdapter",
classInfo.name().toString(), methodInfo.name().toString());
if (createdClasses.add(generatedClassName)) {
createClass(index, classOutput, generatedClassName, annotation, target, classInfo, methodInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,9 @@ String checkPrime(long number) {
public Long highestPrimeNumberSoFar() {
return highestPrimeSoFar.get();
}

@Gauge(unit = MetricUnits.NONE, description = "Highest prime number so far.")
public Long highestPrimeNumberSoFar2() {
return highestPrimeSoFar.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void validateMetricsOutput_1() {
"io_quarkus_it_micrometer_mpmetrics_CountedInstance_countPrimes_total{scope=\"application\",} 2.0"))
.body(containsString(
"highestPrimeNumberSoFar 887.0"))
.body(containsString(
"io_quarkus_it_micrometer_mpmetrics_PrimeResource_highestPrimeNumberSoFar2{scope=\"application\",} 887.0"))

// the counter associated with a timed method should have been removed
.body(not(containsString("io_quarkus_it_micrometer_mpmetrics_PrimeResource_checkPrime")));
Expand Down

0 comments on commit 726327e

Please sign in to comment.