I have a script where I’m trying to get the metrics of the gateway using the javadocs. I have everything coming in except for the gauges.
On this line o = registry.gauge(item)
I’m getting an attribute not found error:
AttributeError: 'com.codahale.metrics.MetricRegistry' object has no attribute 'gauge'
Which is strange, because that does exist in the javadocs and the singular version exists for all other metrics (histogram, meter, counter, etc.):
https://www.javadoc.io/doc/io.dropwizard.metrics/metrics-core/4.1.0-rc2/com/codahale/metrics/MetricRegistry.html#gauge--
I used dir
to pull out the props/methods of the registry
object, and I don’t see gauge
(singular) in there only the plural version
gauges
. I see all of the other metrics as singular.
Any ideas?
@PGriffith @Kevin.Herron
def getGatewayMetrics():
fn = 'getGatewaryMetrics'
from com.inductiveautomation.ignition.gateway import IgnitionGateway
context = IgnitionGateway.get()
registry = context.getMetricRegistry()
metrics = {}
items = registry.getCounters()
for item in items:
o = registry.counter(item)
metrics[item] = {'type': 'counter',
'value': o.getCount()
}
items = registry.getMeters()
for item in items:
o = registry.meter(item)
metrics[item] = {'type': 'meter',
'value_1min': o.getOneMinuteRate(),
'value_5min': o.getFiveMinuteRate(),
'value_15min': o.getFifteenMinuteRate()
}
items = registry.getGauges()
for item in items:
o = registry.gauge(item) ### <--- Error occurs here
metrics[item] = {'type': 'gauge',
'value': o.getValue()
}
# items = registry.getHistograms()
# for item in items:
# o = registry.histogram(item)
items = registry.getTimers()
for item in items:
o = registry.timer(item)
metrics[item] = {'type': 'timer',
'value_1min': o.getOneMinuteRate(),
'value_5min': o.getFiveMinuteRate(),
'value_15min': o.getFifteenMinuteRate()
}
return metrics