SmallRye + LambdaGauge bug
See original GitHub issueDescribe the bug When trying to register a LambdaGauge metric there is an exception.
Expected behavior The gauge is registered properly.
Actual behavior There is an exception. Metrics is not registered.
To Reproduce Steps to reproduce the behavior:
- metricFactory.register(“name”, new LambdaGauge( () -> 5 ));
- Exception:
Failed to start application: java.lang.IllegalArgumentException: number> is not a valid MetricType
You can use microprofile-metrics-quickstart and add to PrimeNumberChecker.java:
@Inject
MetricRegistry metricRegistry;
@PostConstruct
public void init() {
// this produces the exception
metricRegistry.register("test", new LambdaGauge(() -> 5));
}
Environment (please complete the following information):
- Quarkus version or git rev: 1.3.2.Final
Additional context There is obviously a bug at MetricRegistryImpl:86-90
if (metricCls.getName().contains("Lambda")) {
String tname = metricCls.getGenericInterfaces()[0].getTypeName(); // TODO [0] is brittle
tname = tname.substring(tname.lastIndexOf('.') + 1);
tname = tname.toLowerCase();
type = MetricType.from(tname);
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Extra Features :: SmallRye documentation
It is an error to add a backoff annotation to a program element that doesn't have @Retry (e.g. add @Retry on a class...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed for SmallRye Metrics 3.0 and 2.4.2. Unless someone really wants it in quick, I’d wait with releasing 2.4.2 until there’s a bit more to include.
The
MetricRegistry
was confused because the gauge’s impl class contains the wordLambda
, so it was mistakenly considered to be a lambda expression. I improved the logic and this should not happen anymore.This has been fixed for a long time, closing