Class JvmMetricsBuilder
java.lang.Object
com.itrsgroup.collection.instr.jvm.JvmMetricsBuilder
Builder for instances of
JvmMetrics.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCollector(JvmMetricsCollector collector) Add a custom collector.build()Build with the configured settings.client(MetricsClient client) Configure the client.Enable collection of memory metrics.Enable collection of operating system metrics.Enable collection of runtime metrics.Enable collection of thread metrics.errorCallback(Consumer<Throwable> callback) Configure the error callback (defaults to no-op).reportingInterval(long reportingInterval, TimeUnit unit) Configure the reporting interval.workerThreads(int count) Configure the number of collection worker threads.
-
Constructor Details
-
JvmMetricsBuilder
public JvmMetricsBuilder()
-
-
Method Details
-
client
Configure the client.- Parameters:
client- client- Returns:
- this
- Throws:
NullPointerException- if client is null
-
collectMemoryMetrics
Enable collection of memory metrics.- Returns:
- this
-
collectThreadMetrics
Enable collection of thread metrics.- Returns:
- this
-
collectRuntimeMetrics
Enable collection of runtime metrics.- Returns:
- this
-
collectOperatingSystemMetrics
Enable collection of operating system metrics.- Returns:
- this
-
addCollector
Add a custom collector.- Parameters:
collector- collector- Returns:
- this
-
reportingInterval
Configure the reporting interval.- Parameters:
reportingInterval- reporting interval - must be 1 second or greaterunit- reporting interval unit- Returns:
- this
- Throws:
IllegalArgumentException- if the reporting interval is less than one second
-
workerThreads
Configure the number of collection worker threads.- Parameters:
count- thread count, must be greater than zero- Returns:
- this
- Throws:
IllegalArgumentException- if count is less than 1
-
errorCallback
Configure the error callback (defaults to no-op).- Parameters:
callback- callback- Returns:
- this
- Throws:
NullPointerException- if the callback is null
-
build
Build with the configured settings.- Returns:
- the metrics collector
- Throws:
IllegalArgumentException- if no client has been configured
-