-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Deprecate runtime telemetry individual metric classes #16064
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
Changes from 2 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 |
|---|---|---|
|
|
@@ -6,74 +6,21 @@ | |
| package io.opentelemetry.instrumentation.runtimemetrics.java8; | ||
|
|
||
| import io.opentelemetry.api.OpenTelemetry; | ||
| import io.opentelemetry.api.metrics.Meter; | ||
| import io.opentelemetry.instrumentation.runtimemetrics.java8.internal.JmxRuntimeMetricsUtil; | ||
| import java.lang.management.ClassLoadingMXBean; | ||
| import java.lang.management.ManagementFactory; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Registers measurements that generate metrics about JVM classes. The metrics generated by this | ||
| * class follow <a | ||
| * href="https://github.com/open-telemetry/semantic-conventions/blob/main/docs/runtime/jvm-metrics.md">the | ||
| * stable JVM metrics semantic conventions</a>. | ||
| * Registers measurements that generate metrics about JVM classes. | ||
| * | ||
| * <p>Example usage: | ||
| * | ||
| * <pre>{@code | ||
| * Classes.registerObservers(GlobalOpenTelemetry.get()); | ||
| * }</pre> | ||
| * | ||
| * <p>Example metrics being exported: | ||
| * | ||
| * <pre> | ||
| * jvm.class.loaded 100 | ||
| * jvm.class.unloaded 2 | ||
| * jvm.class.count 98 | ||
| * </pre> | ||
| * @deprecated Use {@link RuntimeMetrics} instead, and configure metric views to select specific | ||
| * metrics. | ||
| */ | ||
| @Deprecated | ||
|
Contributor
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. if your goal is just to move these to internal then maybe it would be easier to move the class, drop final, add deprecated class in original location that extends the moved class
Member
Author
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. done in cfbec4d |
||
| public final class Classes { | ||
|
|
||
| // Visible for testing | ||
| static final Classes INSTANCE = new Classes(); | ||
|
|
||
| /** Register observers for java runtime class metrics. */ | ||
| public static List<AutoCloseable> registerObservers(OpenTelemetry openTelemetry) { | ||
| return INSTANCE.registerObservers(openTelemetry, ManagementFactory.getClassLoadingMXBean()); | ||
| } | ||
|
|
||
| // Visible for testing | ||
| List<AutoCloseable> registerObservers(OpenTelemetry openTelemetry, ClassLoadingMXBean classBean) { | ||
| Meter meter = JmxRuntimeMetricsUtil.getMeter(openTelemetry); | ||
| List<AutoCloseable> observables = new ArrayList<>(); | ||
|
|
||
| observables.add( | ||
| meter | ||
| .counterBuilder("jvm.class.loaded") | ||
| .setDescription("Number of classes loaded since JVM start.") | ||
| .setUnit("{class}") | ||
| .buildWithCallback( | ||
| observableMeasurement -> | ||
| observableMeasurement.record(classBean.getTotalLoadedClassCount()))); | ||
| observables.add( | ||
| meter | ||
| .counterBuilder("jvm.class.unloaded") | ||
| .setDescription("Number of classes unloaded since JVM start.") | ||
| .setUnit("{class}") | ||
| .buildWithCallback( | ||
| observableMeasurement -> | ||
| observableMeasurement.record(classBean.getUnloadedClassCount()))); | ||
| observables.add( | ||
| meter | ||
| .upDownCounterBuilder("jvm.class.count") | ||
| .setDescription("Number of classes currently loaded.") | ||
| .setUnit("{class}") | ||
| .buildWithCallback( | ||
| observableMeasurement -> | ||
| observableMeasurement.record(classBean.getLoadedClassCount()))); | ||
|
|
||
| return observables; | ||
| return io.opentelemetry.instrumentation.runtimemetrics.java8.internal.Classes.registerObservers( | ||
| openTelemetry); | ||
| } | ||
|
|
||
| private Classes() {} | ||
|
|
||
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.
Do we have an example implementation with Java SDK we could link to ?
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.
bf2412f