From 15e5e423e863915fcc6b9728e96907f66170a7f5 Mon Sep 17 00:00:00 2001 From: harsimar Date: Tue, 30 Apr 2024 16:41:44 -0700 Subject: [PATCH 01/10] initial code, will test tomorrow --- .../configuration/ConfigurationBuilder.java | 28 ---------------- .../internal/init/AiConfigCustomizer.java | 1 + .../init/PerformanceCounterInitializer.java | 32 +++++++++++++++++++ .../DetectUnexpectedOtelMetricsTest.java | 23 +++++++++++++ .../smoketest/JmxMetricTest.java | 12 +++---- 5 files changed, 60 insertions(+), 36 deletions(-) diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationBuilder.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationBuilder.java index 48e4ddda388..6b64f078785 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationBuilder.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationBuilder.java @@ -547,33 +547,6 @@ private static void loadJmxMetricsEnvVar( } } - private static void addDefaultJmxMetricsIfNotPresent(Configuration config) { - if (!jmxMetricExists(config.jmxMetrics, "java.lang:type=Threading", "ThreadCount")) { - JmxMetric threadCountJmxMetric = new JmxMetric(); - threadCountJmxMetric.name = "Current Thread Count"; - threadCountJmxMetric.objectName = "java.lang:type=Threading"; - threadCountJmxMetric.attribute = "ThreadCount"; - config.jmxMetrics.add(threadCountJmxMetric); - } - if (!jmxMetricExists(config.jmxMetrics, "java.lang:type=ClassLoading", "LoadedClassCount")) { - JmxMetric classCountJmxMetric = new JmxMetric(); - classCountJmxMetric.name = "Loaded Class Count"; - classCountJmxMetric.objectName = "java.lang:type=ClassLoading"; - classCountJmxMetric.attribute = "LoadedClassCount"; - config.jmxMetrics.add(classCountJmxMetric); - } - } - - private static boolean jmxMetricExists( - List jmxMetrics, String objectName, String attribute) { - for (JmxMetric metric : jmxMetrics) { - if (metric.objectName.equals(objectName) && metric.attribute.equals(attribute)) { - return true; - } - } - return false; - } - private static void overlayInstrumentationEnabledEnvVars( Configuration config, Function envVarsFunction) { config.instrumentation.azureSdk.enabled = @@ -833,7 +806,6 @@ static void overlayFromEnv( loadLogCaptureEnvVar(config, envVarsFunction); loadJmxMetricsEnvVar(config, envVarsFunction); - addDefaultJmxMetricsIfNotPresent(config); overlayProfilerEnvVars(config, envVarsFunction); overlayAadEnvVars(config, envVarsFunction); overlayInstrumentationEnabledEnvVars(config, envVarsFunction); diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/AiConfigCustomizer.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/AiConfigCustomizer.java index fe862e8ac3d..18e230abed7 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/AiConfigCustomizer.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/AiConfigCustomizer.java @@ -199,6 +199,7 @@ private static void enableInstrumentations( properties.put("otel.instrumentation.reactor-netty.enabled", "true"); } properties.put("otel.instrumentation.rxjava.enabled", "true"); + properties.put("otel.instrumentation.runtime-telemetry.enabled", "true"); properties.put("otel.instrumentation.servlet.enabled", "true"); properties.put("otel.instrumentation.spring-core.enabled", "true"); diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java index 25a656c58e0..9523b0cb26c 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java @@ -13,6 +13,7 @@ import com.microsoft.applicationinsights.agent.internal.perfcounter.GcPerformanceCounter; import com.microsoft.applicationinsights.agent.internal.perfcounter.JmxAttributeData; import com.microsoft.applicationinsights.agent.internal.perfcounter.JmxDataFetcher; +import com.microsoft.applicationinsights.agent.internal.perfcounter.JmxMetricPerformanceCounter; import com.microsoft.applicationinsights.agent.internal.perfcounter.JvmHeapMemoryUsedPerformanceCounter; import com.microsoft.applicationinsights.agent.internal.perfcounter.OshiPerformanceCounter; import com.microsoft.applicationinsights.agent.internal.perfcounter.PerformanceCounterContainer; @@ -25,6 +26,7 @@ import java.lang.management.ManagementFactory; import java.lang.management.ThreadMXBean; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -48,6 +50,19 @@ public static void initialize(Configuration configuration) { PerformanceCounterContainer.INSTANCE.setLogAvailableJmxMetrics(); } + // We don't want these two to be flowing to the OTLP endpoint + // because in the long term we will probably be deprecating these + // in favor of the otel instrumentation runtime metrics that relay + // the same information. + registerCounterInContainer("java.land.type=Threading", + "Current Thread Count", + "ThreadCount", + configuration.jmxMetrics); + registerCounterInContainer("java.lang:type=ClassLoading", + "Loaded Class Count", + "LoadedClassCount", + configuration.jmxMetrics); + loadCustomJmxPerfCounters(configuration.jmxMetrics); PerformanceCounterContainer.INSTANCE.register( @@ -74,6 +89,23 @@ private static boolean isAgentRunningInSandboxEnvWindows() { return qualifiedSdkVersion.startsWith("awr") || qualifiedSdkVersion.startsWith("fwr"); } + private static void registerCounterInContainer(String objectName, String metricName, String attribute, List jmxMetricsList) { + if(!isMetricInConfig(objectName, attribute, jmxMetricsList)) { + JmxAttributeData attributeData = new JmxAttributeData(metricName, attribute); + JmxMetricPerformanceCounter jmxPerfCounter = new JmxMetricPerformanceCounter(objectName, + Arrays.asList(attributeData)); + PerformanceCounterContainer.INSTANCE.register(jmxPerfCounter); + } + } + + private static boolean isMetricInConfig(String objectName, String attribute, List jmxMetricsList) { + for (Configuration.JmxMetric metric : jmxMetricsList) { + if (metric.objectName.equals(objectName) && metric.attribute.equals(attribute)) { + return true; + } + } + return false; + } /** * The method will load the Jmx performance counters requested by the user to the system: 1. Build * a map where the key is the Jmx object name and the value is a list of requested attributes. 2. diff --git a/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java b/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java index 93d8a37131c..a4e0441ce78 100644 --- a/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java +++ b/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java @@ -47,6 +47,29 @@ abstract class DetectUnexpectedOtelMetricsTest { EXPECTED_METRIC_NAMES.add("% Of Max Heap Memory Used"); EXPECTED_METRIC_NAMES.add("GC Total Count"); EXPECTED_METRIC_NAMES.add("GC Total Time"); + + // adding metrics from otel.instrumentation.runtime-telemetry + // most are stable except the last six. + EXPECTED_METRIC_NAMES.add("jvm.memory.used"); // heap memory used in bytes + EXPECTED_METRIC_NAMES.add("jvm.memory.committed"); + // the measure of max obtainable memory, can be used by customer + // to calculate a percentage if needed + EXPECTED_METRIC_NAMES.add("jvm.memory.limit"); + EXPECTED_METRIC_NAMES.add("jvm.memory.used_after_last_gc"); + EXPECTED_METRIC_NAMES.add("jvm.gc.duration"); // same as GC Total Time + EXPECTED_METRIC_NAMES.add("jvm.thread.count"); // same as Current Thread Count + EXPECTED_METRIC_NAMES.add("jvm.class.loaded"); // same as Loaded Class Count + EXPECTED_METRIC_NAMES.add("jvm.class.unloaded"); + EXPECTED_METRIC_NAMES.add("jvm.class.count"); + EXPECTED_METRIC_NAMES.add("jvm.cpu.time"); + EXPECTED_METRIC_NAMES.add("jvm.cpu.count"); + EXPECTED_METRIC_NAMES.add("jvm.cpu.recent_utilization"); + EXPECTED_METRIC_NAMES.add("jvm.memory.init"); + EXPECTED_METRIC_NAMES.add("jvm.system.cpu.utilization"); + EXPECTED_METRIC_NAMES.add("jvm.system.cpu.load_1m"); + EXPECTED_METRIC_NAMES.add("jvm.buffer.memory.usage"); + EXPECTED_METRIC_NAMES.add("jvm.buffer.memory.limit"); + EXPECTED_METRIC_NAMES.add("jvm.buffer.count"); } @Test diff --git a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java index c170dcd8d03..00df80cd5be 100644 --- a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java +++ b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java @@ -52,13 +52,10 @@ abstract class JmxMetricTest { *

- Higher than Java 8: G1 Young Generation,type=GarbageCollector, G1 Old * Generation,type=GarbageCollector. (the corrresponding metric names are GCYoung and GCOld) * - *

- Loaded_Class_Count: This covers the case of collecting a default jmx metric that the - * customer did not specify in applicationInsights.json. Also note that there are underscores - * instead of spaces, as we are emitting the metric via OpenTelemetry now. We intend to implement - * a change in azure-sdk-for-java repo to have the metrics still emit with spaces to Breeze, but - * the OTEL collector will still get the metric names with _. When that change gets merged & - * incorporated, we will need to change this/DetectUnexpectedOtelMetrics test so that the Breeze - * verification expects our default jmx metrics with spaces. + *

- Loaded Class Count: This covers the case of collecting a default jmx metric that the + * customer did not specify in applicationInsights.json. This metric is only expected to flow + * to Breeze at the current moment. In the future we may deprecate this in favor of analogous + * metric that is emitted via otel instrumentation runtime metrics (enabled for this repo). * *

- BooleanJmxMetric: This covers the case of a jmx metric attribute with a boolean value. * @@ -81,7 +78,6 @@ abstract class JmxMetricTest { "NameWithDot", "DefaultJmxMetricNameOverride", "WildcardJmxMetric", - "Loaded_Class_Count", "BooleanJmxMetric", "DotInAttributeNameAsPathSeparator")); From ed542e8673071a302b3d536e3592362467fabe79 Mon Sep 17 00:00:00 2001 From: harsimar Date: Thu, 2 May 2024 09:53:06 -0700 Subject: [PATCH 02/10] test modifications --- .../smoketest/DetectUnexpectedOtelMetricsTest.java | 10 ++-------- .../applicationinsights/smoketest/JmxMetricTest.java | 7 ++++--- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java b/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java index a4e0441ce78..9580bf0b5fd 100644 --- a/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java +++ b/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java @@ -22,6 +22,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Predicate; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -48,8 +49,7 @@ abstract class DetectUnexpectedOtelMetricsTest { EXPECTED_METRIC_NAMES.add("GC Total Count"); EXPECTED_METRIC_NAMES.add("GC Total Time"); - // adding metrics from otel.instrumentation.runtime-telemetry - // most are stable except the last six. + // adding stable metrics from otel.instrumentation.runtime-telemetry EXPECTED_METRIC_NAMES.add("jvm.memory.used"); // heap memory used in bytes EXPECTED_METRIC_NAMES.add("jvm.memory.committed"); // the measure of max obtainable memory, can be used by customer @@ -64,12 +64,6 @@ abstract class DetectUnexpectedOtelMetricsTest { EXPECTED_METRIC_NAMES.add("jvm.cpu.time"); EXPECTED_METRIC_NAMES.add("jvm.cpu.count"); EXPECTED_METRIC_NAMES.add("jvm.cpu.recent_utilization"); - EXPECTED_METRIC_NAMES.add("jvm.memory.init"); - EXPECTED_METRIC_NAMES.add("jvm.system.cpu.utilization"); - EXPECTED_METRIC_NAMES.add("jvm.system.cpu.load_1m"); - EXPECTED_METRIC_NAMES.add("jvm.buffer.memory.usage"); - EXPECTED_METRIC_NAMES.add("jvm.buffer.memory.limit"); - EXPECTED_METRIC_NAMES.add("jvm.buffer.count"); } @Test diff --git a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java index 00df80cd5be..f2c53cc2f29 100644 --- a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java +++ b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java @@ -87,8 +87,8 @@ abstract class JmxMetricTest { @Test @TargetUri("/test") void doMostBasicTest() throws Exception { - verifyJmxMetricsSentToBreeze(); verifyJmxMetricsSentToOtlpEndpoint(); + verifyJmxMetricsSentToBreeze(); } @SuppressWarnings({"PreferJavaTimeOverload"}) @@ -122,12 +122,13 @@ private void verifyJmxMetricsSentToOtlpEndpoint() { } } + System.out.println("Printing metrics names to # of occurrences for otlp"); for (Map.Entry entry : occurrences.entrySet()) { System.out.println(entry.toString()); } // confirm that those metrics received once or twice // (the collector seems to run for 5-10 sec) - assertThat(occurrences.keySet()).hasSize(6); + assertThat(occurrences.keySet()).hasSize(jmxMetricsAllJavaVersionsOtlp.size()); for (int value : occurrences.values()) { assertThat(value).isBetween(1, 8); } @@ -136,7 +137,7 @@ private void verifyJmxMetricsSentToOtlpEndpoint() { private void verifyJmxMetricsSentToBreeze() throws Exception { List metricItems = - testing.mockedIngestion.waitForItems(JmxMetricTest::isJmxMetric, 1, 10, TimeUnit.SECONDS); + testing.mockedIngestion.waitForItems(JmxMetricTest::isJmxMetric, 7, 10, TimeUnit.SECONDS); assertThat(metricItems).hasSizeBetween(7, 16); From 917994ab3bbbc53ea027d40bae64f46f92ac8626 Mon Sep 17 00:00:00 2001 From: harsimar Date: Thu, 2 May 2024 09:56:42 -0700 Subject: [PATCH 03/10] removing unnecessary import --- .../smoketest/DetectUnexpectedOtelMetricsTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java b/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java index 9580bf0b5fd..81d30aff50f 100644 --- a/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java +++ b/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java @@ -22,7 +22,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.function.Predicate; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; From 7697af06ee98d88ec8f691813ae6f166deac0e63 Mon Sep 17 00:00:00 2001 From: harsimar Date: Thu, 2 May 2024 10:37:19 -0700 Subject: [PATCH 04/10] spotless --- .../init/PerformanceCounterInitializer.java | 24 ++++++++++++------- .../smoketest/JmxMetricTest.java | 6 ++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java index 9523b0cb26c..f051b116731 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java @@ -54,11 +54,13 @@ public static void initialize(Configuration configuration) { // because in the long term we will probably be deprecating these // in favor of the otel instrumentation runtime metrics that relay // the same information. - registerCounterInContainer("java.land.type=Threading", + registerCounterInContainer( + "java.land.type=Threading", "Current Thread Count", "ThreadCount", configuration.jmxMetrics); - registerCounterInContainer("java.lang:type=ClassLoading", + registerCounterInContainer( + "java.lang:type=ClassLoading", "Loaded Class Count", "LoadedClassCount", configuration.jmxMetrics); @@ -89,23 +91,29 @@ private static boolean isAgentRunningInSandboxEnvWindows() { return qualifiedSdkVersion.startsWith("awr") || qualifiedSdkVersion.startsWith("fwr"); } - private static void registerCounterInContainer(String objectName, String metricName, String attribute, List jmxMetricsList) { - if(!isMetricInConfig(objectName, attribute, jmxMetricsList)) { + private static void registerCounterInContainer( + String objectName, + String metricName, + String attribute, + List jmxMetricsList) { + if (!isMetricInConfig(objectName, attribute, jmxMetricsList)) { JmxAttributeData attributeData = new JmxAttributeData(metricName, attribute); - JmxMetricPerformanceCounter jmxPerfCounter = new JmxMetricPerformanceCounter(objectName, - Arrays.asList(attributeData)); + JmxMetricPerformanceCounter jmxPerfCounter = + new JmxMetricPerformanceCounter(objectName, Arrays.asList(attributeData)); PerformanceCounterContainer.INSTANCE.register(jmxPerfCounter); } } - private static boolean isMetricInConfig(String objectName, String attribute, List jmxMetricsList) { + private static boolean isMetricInConfig( + String objectName, String attribute, List jmxMetricsList) { for (Configuration.JmxMetric metric : jmxMetricsList) { if (metric.objectName.equals(objectName) && metric.attribute.equals(attribute)) { - return true; + return true; } } return false; } + /** * The method will load the Jmx performance counters requested by the user to the system: 1. Build * a map where the key is the Jmx object name and the value is a list of requested attributes. 2. diff --git a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java index f2c53cc2f29..a8070b1ab93 100644 --- a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java +++ b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java @@ -53,9 +53,9 @@ abstract class JmxMetricTest { * Generation,type=GarbageCollector. (the corrresponding metric names are GCYoung and GCOld) * *

- Loaded Class Count: This covers the case of collecting a default jmx metric that the - * customer did not specify in applicationInsights.json. This metric is only expected to flow - * to Breeze at the current moment. In the future we may deprecate this in favor of analogous - * metric that is emitted via otel instrumentation runtime metrics (enabled for this repo). + * customer did not specify in applicationInsights.json. This metric is only expected to flow to + * Breeze at the current moment. In the future we may deprecate this in favor of analogous metric + * that is emitted via otel instrumentation runtime metrics (enabled for this repo). * *

- BooleanJmxMetric: This covers the case of a jmx metric attribute with a boolean value. * From a6fe762993765619764d80e9bc0827d8f8029d0b Mon Sep 17 00:00:00 2001 From: harsimar Date: Thu, 2 May 2024 11:24:04 -0700 Subject: [PATCH 05/10] adding link to upstream metrics --- .../smoketest/DetectUnexpectedOtelMetricsTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java b/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java index 81d30aff50f..58de1d7ded6 100644 --- a/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java +++ b/smoke-tests/apps/DetectUnexpectedOtelMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/DetectUnexpectedOtelMetricsTest.java @@ -49,6 +49,8 @@ abstract class DetectUnexpectedOtelMetricsTest { EXPECTED_METRIC_NAMES.add("GC Total Time"); // adding stable metrics from otel.instrumentation.runtime-telemetry + // link: + // https://github.com/open-telemetry/semantic-conventions/blob/main/docs/runtime/jvm-metrics.md EXPECTED_METRIC_NAMES.add("jvm.memory.used"); // heap memory used in bytes EXPECTED_METRIC_NAMES.add("jvm.memory.committed"); // the measure of max obtainable memory, can be used by customer From a807c8bbf5230489e41cbef666420c8529b467f3 Mon Sep 17 00:00:00 2001 From: harsimar Date: Wed, 8 May 2024 16:41:52 -0700 Subject: [PATCH 06/10] fixing type & test fixes --- .../agent/internal/init/PerformanceCounterInitializer.java | 2 +- .../agent/internal/configuration/ConfigurationTest.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java index f051b116731..a17fb4485cd 100644 --- a/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java +++ b/agent/agent-tooling/src/main/java/com/microsoft/applicationinsights/agent/internal/init/PerformanceCounterInitializer.java @@ -55,7 +55,7 @@ public static void initialize(Configuration configuration) { // in favor of the otel instrumentation runtime metrics that relay // the same information. registerCounterInContainer( - "java.land.type=Threading", + "java.lang:type=Threading", "Current Thread Count", "ThreadCount", configuration.jmxMetrics); diff --git a/agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationTest.java b/agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationTest.java index 8520f08cb8b..4e90712a73d 100644 --- a/agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationTest.java +++ b/agent/agent-tooling/src/test/java/com/microsoft/applicationinsights/agent/internal/configuration/ConfigurationTest.java @@ -99,12 +99,11 @@ void shouldParseFromEnvVar() throws IOException { List jmxMetrics = parseJmxMetricsJson(jmxMetricsJson); assertThat(jmxMetrics.size()).isEqualTo(2); - assertThat(configuration.jmxMetrics.size()).isEqualTo(3); + assertThat(configuration.jmxMetrics.size()).isEqualTo(2); assertThat(configuration.jmxMetrics.get(0).name) .isEqualTo(jmxMetrics.get(0).name); // class count is overridden by the env var assertThat(configuration.jmxMetrics.get(1).name) .isEqualTo(jmxMetrics.get(1).name); // code cache is overridden by the env var - assertThat("Current Thread Count").isEqualTo(configuration.jmxMetrics.get(2).name); } @Test @@ -513,12 +512,11 @@ void shouldOverrideJmxMetrics() throws IOException { List jmxMetrics = parseJmxMetricsJson(jmxMetricsJson); assertThat(jmxMetrics.size()).isEqualTo(2); - assertThat(configuration.jmxMetrics.size()).isEqualTo(3); + assertThat(configuration.jmxMetrics.size()).isEqualTo(2); assertThat(configuration.jmxMetrics.get(0).name) .isEqualTo(jmxMetrics.get(0).name); // class count is overridden by the env var assertThat(configuration.jmxMetrics.get(1).name) .isEqualTo(jmxMetrics.get(1).name); // code cache is overridden by the env var - assertThat("Current Thread Count").isEqualTo(configuration.jmxMetrics.get(2).name); } @Test From 8c00c51b7ff71ca39bca38b011d3391126dd7788 Mon Sep 17 00:00:00 2001 From: harsimar Date: Thu, 9 May 2024 11:41:59 -0700 Subject: [PATCH 07/10] adding todo --- .../microsoft/applicationinsights/smoketest/JmxMetricTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java index a8070b1ab93..a8c5ffa7093 100644 --- a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java +++ b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java @@ -54,7 +54,7 @@ abstract class JmxMetricTest { * *

- Loaded Class Count: This covers the case of collecting a default jmx metric that the * customer did not specify in applicationInsights.json. This metric is only expected to flow to - * Breeze at the current moment. In the future we may deprecate this in favor of analogous metric + * Breeze at the current moment. TODO: deprecate this in favor of analogous metric * that is emitted via otel instrumentation runtime metrics (enabled for this repo). * *

- BooleanJmxMetric: This covers the case of a jmx metric attribute with a boolean value. From 1ebcc48a5193b9e3bec9c162f6f6af437e598461 Mon Sep 17 00:00:00 2001 From: Harsimar Kaur Date: Thu, 9 May 2024 12:05:26 -0700 Subject: [PATCH 08/10] fix todo comment Co-authored-by: Helen <56097766+heyams@users.noreply.github.com> --- .../applicationinsights/smoketest/JmxMetricTest.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java index a8c5ffa7093..1b2eda626e4 100644 --- a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java +++ b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java @@ -53,9 +53,8 @@ abstract class JmxMetricTest { * Generation,type=GarbageCollector. (the corrresponding metric names are GCYoung and GCOld) * *

- Loaded Class Count: This covers the case of collecting a default jmx metric that the - * customer did not specify in applicationInsights.json. This metric is only expected to flow to - * Breeze at the current moment. TODO: deprecate this in favor of analogous metric - * that is emitted via otel instrumentation runtime metrics (enabled for this repo). + * customer did not specify in applicationInsights.json. + * TODO deprecate this in favor of analogous metric that is emitted via OTel instrumentation runtime metrics. * *

- BooleanJmxMetric: This covers the case of a jmx metric attribute with a boolean value. * From e8d9016dcbbd550f782d6d6ed241b9a8d42d09fa Mon Sep 17 00:00:00 2001 From: harsimar Date: Thu, 9 May 2024 14:16:06 -0700 Subject: [PATCH 09/10] fixing spotless issue --- .../applicationinsights/smoketest/JmxMetricTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java index 1b2eda626e4..e7dfc951d12 100644 --- a/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java +++ b/smoke-tests/apps/JmxMetric/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/JmxMetricTest.java @@ -53,8 +53,8 @@ abstract class JmxMetricTest { * Generation,type=GarbageCollector. (the corrresponding metric names are GCYoung and GCOld) * *

- Loaded Class Count: This covers the case of collecting a default jmx metric that the - * customer did not specify in applicationInsights.json. - * TODO deprecate this in favor of analogous metric that is emitted via OTel instrumentation runtime metrics. + * customer did not specify in applicationInsights.json. TODO deprecate this in favor of analogous + * metric that is emitted via OTel instrumentation runtime metrics. * *

- BooleanJmxMetric: This covers the case of a jmx metric attribute with a boolean value. * From 68cfec92dde3c51862b278a962e18e29dad163f4 Mon Sep 17 00:00:00 2001 From: harsimar Date: Tue, 28 May 2024 14:57:57 -0700 Subject: [PATCH 10/10] exporter local build --- .github/workflows/build-common.yml | 2 +- agent/agent-tooling/build.gradle.kts | 2 +- agent/agent-tooling/gradle.lockfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-common.yml b/.github/workflows/build-common.yml index ffed0fbd95d..c70d4c9b697 100644 --- a/.github/workflows/build-common.yml +++ b/.github/workflows/build-common.yml @@ -8,7 +8,7 @@ on: required: false env: - EXPORTER_VERSION: 1.0.0-beta.22 # to be updated with the latest version + EXPORTER_VERSION: 1.0.0-beta.24 # to be updated with the latest version jobs: spotless: diff --git a/agent/agent-tooling/build.gradle.kts b/agent/agent-tooling/build.gradle.kts index ccad91b7b06..363720208bb 100644 --- a/agent/agent-tooling/build.gradle.kts +++ b/agent/agent-tooling/build.gradle.kts @@ -21,7 +21,7 @@ dependencies { implementation(project(":agent:agent-profiler:agent-diagnostics")) implementation(project(":etw:java")) - implementation("com.azure:azure-monitor-opentelemetry-exporter:1.0.0-beta.22") + implementation("com.azure:azure-monitor-opentelemetry-exporter:1.0.0-beta.24") compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap") compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling") compileOnly("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-servlet-common-bootstrap") diff --git a/agent/agent-tooling/gradle.lockfile b/agent/agent-tooling/gradle.lockfile index 0a1eeb05397..a33caeb5eb6 100644 --- a/agent/agent-tooling/gradle.lockfile +++ b/agent/agent-tooling/gradle.lockfile @@ -9,7 +9,7 @@ com.azure:azure-core-http-netty:1.14.2=runtimeClasspath com.azure:azure-core:1.48.0=runtimeClasspath com.azure:azure-identity:1.12.1=runtimeClasspath com.azure:azure-json:1.1.0=runtimeClasspath -com.azure:azure-monitor-opentelemetry-exporter:1.0.0-beta.22=runtimeClasspath +com.azure:azure-monitor-opentelemetry-exporter:1.0.0-beta.24=runtimeClasspath com.azure:azure-sdk-bom:1.2.23=runtimeClasspath com.azure:azure-storage-blob:12.25.4=runtimeClasspath com.azure:azure-storage-common:12.24.4=runtimeClasspath