Jolokia JMX-HTTP bridge. Using this for application specific metrics would require those metrics to be exposed to JMX first, which many users are not familiar with.
The following is an example configuration in YAML format.
base:
- name: "thread-count"
mbean: "java.lang:type=Threading/ThreadCount"
description: "Number of currently deployed threads"
unit: "none"
type: "gauge"
- name: "peak-thread-count"
mbean: "java.lang:type=Threading/PeakThreadCount"
description: "Max number of threads"
unit: "none"
type: "gauge"
- name: "total-started-thread-count"
mbean: "java.lang:type=Threading/TotalStartedThreadCount"
description: "Number of threads started for this server"
unit: "none"
type: "counter"
- name: "max-heap"
mbean: "java.lang:type=Memory/HeapMemoryUsage#max"
description: "Number of threads started for this server"
unit: "bytes"
type: "counter"
tags: "kind=memory"
vendor:
- name: "msc-loaded-modules"
mbean: "jboss.modules:type=ModuleLoader,name=BootModuleLoader-2/LoadedModuleCount"
description: "Number of loaded modules"
unit: "none"
type: "gauge"
This configuration can be backed into the runtime or be provided via an external configuration file.
@ApplicationScoped
public class MetricRegistryFactory {
@Produces
@Default
public MetricRegistry getMetricRegistry(InjectionPoint ip) {
RegistryScope registryTypeAnnotation = ip.getAnnotated().getAnnotation(RegistryScope.class);
if (registryTypeAnnotation == null) {
return getOrCreate(MetricRegistry.APPLICATION_SCOPE);
} else {
String annoScope = registryTypeAnnotation.scope();
return getOrCreate(annoScope);
}
}
}
The @Counted
annotation has changed. Users of the previous @Counted
annotation were surprised to learn that by default counters were not monotonic. Also, the OpenMetrics format expects all counters to be monotonic.
To migrate:
-
Replace
@Counted()
or@Counted(monotonic=false)
with@ConcurrentGauge
. A set of gauges will be created in the OpenMetrics output for each@ConcurrentGauge
. -
Replace
@Counted(monotonic=true)
with@Counted
(monotonic flag is gone)
This change has also had an impact on the Counter
interface to basically follow the above change:
-
Modify code which uses
Counter.dec()
to use aGauge
orConcurrentGauge
.
Some base metrics' types have changed from Counter
to Gauge
since counters must now count monotonically. Update code or dashboards that use the following metrics:
-
thread.count
-
thread.daemon.count
-
classloader.currentLoadedClass.count
-
thread.max.count
Some base metrics' names have changed to follow the convention of ending the name of accumulating counters with total
. Update code or dashboards that use the following metrics:
-
gc.count → gc.total
-
classloader.currentLoadedClass.count → classloader.loadedClasses.count (changed to stay consistent with other classloader metric names)
-
classloader.totalLoadedClass.count → classloader.loadedClasses.total
-
classloader.totalUnloadedClass.count → classloader.unloadedClasses.total