initialize

fun initialize(enableStandardExports: Boolean = false, enableMemoryPoolsExports: Boolean = false, enableGarbageCollectorExports: Boolean = false, enableThreadExports: Boolean = false, enableClassLoadingExports: Boolean = false, enableVersionInfoExports: Boolean = false, enableBufferPoolExports: Boolean = false, enableCompilationExports: Boolean = false, enableNativeMemoryExports: Boolean = false, registry: PrometheusRegistry = PrometheusRegistry.defaultRegistry)

Registers the selected JVM and process metric sets with registry.

This method is synchronized and safe to call repeatedly: a metric set already registered by an earlier call is skipped, and one requested for the first time is registered. Registrations are tracked per registry, so a metric set later removed with PrometheusRegistry.clear is not registered again.

Each metric set is registered all or nothing. The client's register(registry) for a set adds its metrics one at a time and returns no handle, so a name clash part-way through would leave the earlier metrics registered and impossible to remove. Each set therefore registers through a wrapper that passes every registration on to registry and remembers it; if one is rejected, those added before it are unregistered again.

A metric set whose names another collector already provides, such as one registered by JvmMetrics.builder().register(), is skipped with a warning instead of failing the call, and is not tried again. Any other registration failure is logged and retried by the next call.

Parameters

enableStandardExports

whether to register the process metrics (ProcessMetrics: CPU time, start time, open and max file descriptors, and, on Linux, virtual and resident memory).

enableMemoryPoolsExports

whether to register the JVM memory metrics (JvmMemoryMetrics) and the per-pool allocation counter (JvmMemoryPoolAllocationMetrics), each as its own all-or-nothing set.

enableGarbageCollectorExports

whether to register the garbage collector metrics (JvmGarbageCollectorMetrics).

enableThreadExports

whether to register the thread metrics (JvmThreadsMetrics).

enableClassLoadingExports

whether to register the class loading metrics (JvmClassLoadingMetrics).

enableVersionInfoExports

whether to register the JVM runtime info metric (JvmRuntimeInfoMetric).

enableBufferPoolExports

whether to register the buffer pool metrics (JvmBufferPoolMetrics).

enableCompilationExports

whether to register the JIT compilation metrics (JvmCompilationMetrics).

enableNativeMemoryExports

whether to register the native memory metrics (JvmNativeMemoryMetrics). They are only present when the JVM runs with -XX:NativeMemoryTracking=summary (or detail); otherwise the set registers nothing.

registry

the registry to register with. Defaults to PrometheusRegistry.defaultRegistry.