Skip to content
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

JmxReporter's JmxGauge returns Object which does not allow graphing #1408

Closed
oobles opened this issue Feb 19, 2019 · 1 comment · Fixed by #1451
Closed

JmxReporter's JmxGauge returns Object which does not allow graphing #1408

oobles opened this issue Feb 19, 2019 · 1 comment · Fixed by #1451

Comments

@oobles
Copy link

oobles commented Feb 19, 2019

I have some caches I'd like to report metrics to JMX. I'm using a gauge which is a great way to grab the metrics from the cache. However, in Java Mission Control the "Visualize..." menu option is disabled. This means a gauge can't be visualised. Obviously not a show stopper, but would be nice if this could be supported.

@oobles oobles changed the title JmxGauge JmxReporter's JmxGauge returns Object which does not allow graphing Feb 19, 2019
@oobles
Copy link
Author

oobles commented Feb 19, 2019

I was able to copy the JmxReporter and hack a JmxLongGauge that returns long instead of Object. Works, but doesn't feel like the best solution. Will do for now.

        @Override
        public void onGaugeAdded(String name, Gauge<?> gauge) {
            try {
                if (filter.matches(name, gauge)) {
                    final ObjectName objectName = createName("gauges", name);
                    Object object = gauge.getValue();
                    if (object instanceof Long) {
                        registerMBean(new JmxLongGauge(gauge, objectName), objectName);
                    } else {
                        registerMBean(new JmxGauge(gauge, objectName), objectName);
                    }
                }
            } catch (InstanceAlreadyExistsException e) {
                LOGGER.debug("Unable to register gauge", e);
            } catch (JMException e) {
                LOGGER.warn("Unable to register gauge", e);
            }
        }

arteam pushed a commit that referenced this issue Aug 9, 2019
* Add attribute 'Number' to JmxGaugeMBean

* Update JmxReporterTest

Fixes #1408
arteam pushed a commit that referenced this issue Aug 9, 2019
* Add attribute 'Number' to JmxGaugeMBean

* Update JmxReporterTest

Fixes #1408
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant