question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SmallRye + LambdaGauge bug

See original GitHub issue

Describe 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:

  1. metricFactory.register(“name”, new LambdaGauge( () -> 5 ));
  2. 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:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jmartiskcommented, Apr 23, 2020

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 word Lambda, so it was mistakenly considered to be a lambda expression. I improved the logic and this should not happen anymore.

0reactions
jmartiskcommented, Nov 24, 2021

This has been fixed for a long time, closing

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found