Yes, that seems to be the implementation in metrics-core. It always maps the value of a Gauge to an Object, instead of the generic type. So, you will have to do the casting. If you just want to get the value, you can probably just call toString() on the object.
Thanks, Jun On Wed, Dec 10, 2014 at 4:40 PM, Jack Foy <j...@whitepages.com> wrote: > Kafka 0.8.2-beta consumer, 0.8.1 broker. > > In our consumer, we retrieve the mbeans > "kafka.server":name="*-ConsumerLag",type="FetcherLagMetrics" in order to > send partition lag data to our monitoring service. The underlying metrics > object is a Gauge[Long], but the "Value" attribute returned by JMX for this > mbean is a java.lang.Object. > > For example: > > import java.lang.management._ > import javax.management._ > > val mbs = ManagementFactory.getPlatformMBeanServer > val beanNames = mbs.queryNames(new > ObjectName("\"kafka.server\":type=\"FetcherLagMetrics\",name=\"*-ConsumerLag\""), > null) > for (b <- beanNames) println(mbs.getMBeanInfo(b)) > > generates the output: > > javax.management.MBeanInfo[attributes=[javax.management.MBeanAttributeInfo[name=Value, > type=java.lang.Object, read-only, descriptor={}]], > descriptor={immutableInfo=true, > interfaceClassName=com.yammer.metrics.reporting.JmxReporter$GaugeMBean, > mxbean=false}] > > We can work around this by using asInstanceOf[Long], but that usually > indicates we're doing something wrong. > > Am I missing something here? I would expect types like Scala Long to be > preserved across JMX. > > -- > Jack Foy <j...@whitepages.com<mailto:j...@whitepages.com>> > > > >