-
Notifications
You must be signed in to change notification settings - Fork 830
Add GC duration histogram #1738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,8 @@ | ||||||||
| package io.prometheus.metrics.instrumentation.jvm; | ||||||||
|
|
||||||||
| import com.sun.management.GarbageCollectionNotificationInfo; | ||||||||
| import io.prometheus.metrics.config.PrometheusProperties; | ||||||||
| import io.prometheus.metrics.core.metrics.Histogram; | ||||||||
| import io.prometheus.metrics.core.metrics.SummaryWithCallback; | ||||||||
| import io.prometheus.metrics.model.registry.PrometheusRegistry; | ||||||||
| import io.prometheus.metrics.model.snapshots.Quantiles; | ||||||||
|
|
@@ -9,6 +11,8 @@ | |||||||
| import java.lang.management.ManagementFactory; | ||||||||
| import java.util.List; | ||||||||
| import javax.annotation.Nullable; | ||||||||
| import javax.management.NotificationEmitter; | ||||||||
| import javax.management.openmbean.CompositeData; | ||||||||
|
|
||||||||
| /** | ||||||||
| * JVM Garbage Collector metrics. The {@link JvmGarbageCollectorMetrics} are registered as part of | ||||||||
|
|
@@ -39,6 +43,7 @@ | |||||||
| public class JvmGarbageCollectorMetrics { | ||||||||
|
|
||||||||
| private static final String JVM_GC_COLLECTION_SECONDS = "jvm_gc_collection_seconds"; | ||||||||
| private static final String JVM_GC_DURATION = "jvm_gc_duration"; | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to have an "otel" mode - rather than mixing |
||||||||
|
|
||||||||
| private final PrometheusProperties config; | ||||||||
| private final List<GarbageCollectorMXBean> garbageCollectorBeans; | ||||||||
|
|
@@ -67,6 +72,46 @@ private void register(PrometheusRegistry registry) { | |||||||
| } | ||||||||
| }) | ||||||||
| .register(registry); | ||||||||
|
|
||||||||
| registerGCDurationHistogram(registry); | ||||||||
| } | ||||||||
|
|
||||||||
| private void registerGCDurationHistogram(PrometheusRegistry registry) { | ||||||||
| double[] buckets = {0.01, 0.1, 1, 10}; | ||||||||
|
|
||||||||
| Histogram gcDurationHistogram = | ||||||||
| Histogram.builder(config) | ||||||||
| .name(JVM_GC_DURATION) | ||||||||
| .help("Duration of JVM garbage collection actions.") | ||||||||
|
||||||||
| .help("Duration of JVM garbage collection actions.") | |
| .help("Duration of JVM garbage collection actions.") | |
| .unit(Unit.SECONDS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use . instead of _ - the conversion is done at scrape time (if needed)
zeitlinger marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,7 +58,9 @@ public void testGoodCase() throws IOException { | |
| @Test | ||
| public void testIgnoredMetricNotScraped() { | ||
| MetricNameFilter filter = | ||
| MetricNameFilter.builder().nameMustNotBeEqualTo("jvm_gc_collection_seconds").build(); | ||
| MetricNameFilter.builder() | ||
| .nameMustNotBeEqualTo("jvm_gc_collection_seconds", "jvm_gc_duration") | ||
zeitlinger marked this conversation as resolved.
Show resolved
Hide resolved
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also test label values |
||
| .build(); | ||
|
Comment on lines
+61
to
+63
|
||
|
|
||
| PrometheusRegistry registry = new PrometheusRegistry(); | ||
| JvmGarbageCollectorMetrics.builder() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.