diff --git a/agent/agent-tooling/build.gradle.kts b/agent/agent-tooling/build.gradle.kts index 722c5dc7ab7..ccad91b7b06 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.21") + implementation("com.azure:azure-monitor-opentelemetry-exporter:1.0.0-beta.22") 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 61016217336..226156e9ce2 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.21=runtimeClasspath +com.azure:azure-monitor-opentelemetry-exporter:1.0.0-beta.22=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 diff --git a/licenses/more-licenses.md b/licenses/more-licenses.md index ef433e5e306..91bae3236d4 100644 --- a/licenses/more-licenses.md +++ b/licenses/more-licenses.md @@ -1,7 +1,7 @@ # agent ## Dependency License Report -_2024-05-06 19:10:34 UTC_ +_2024-05-06 12:02:06 PDT_ ## Apache License, Version 2.0 **1** **Group:** `com.fasterxml.jackson.core` **Name:** `jackson-annotations` **Version:** `2.17.1` @@ -350,7 +350,7 @@ _2024-05-06 19:10:34 UTC_ > - **POM Project URL**: [https://github.com/Azure/azure-sdk-for-java](https://github.com/Azure/azure-sdk-for-java) > - **POM License**: MIT License - [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT) -**67** **Group:** `com.azure` **Name:** `azure-monitor-opentelemetry-exporter` **Version:** `1.0.0-beta.21` +**67** **Group:** `com.azure` **Name:** `azure-monitor-opentelemetry-exporter` **Version:** `1.0.0-beta.22` > - **POM License**: MIT License - [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT) **68** **Group:** `com.azure` **Name:** `azure-storage-blob` **Version:** `12.25.4` diff --git a/smoke-tests/apps/ConnectionStringOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/ConnectionStringOverridesTest.java b/smoke-tests/apps/ConnectionStringOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/ConnectionStringOverridesTest.java index 655e079ceee..52fd7d88add 100644 --- a/smoke-tests/apps/ConnectionStringOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/ConnectionStringOverridesTest.java +++ b/smoke-tests/apps/ConnectionStringOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/ConnectionStringOverridesTest.java @@ -98,9 +98,9 @@ private static void testApp(String iKey) throws Exception { // and metrics too List clientMetrics = - testing.mockedIngestion.waitForMetricItems("http.client.request.duration", 1); + testing.mockedIngestion.waitForStandardMetricItems("dependencies/duration", 1); List serverMetrics = - testing.mockedIngestion.waitForMetricItems("http.server.request.duration", 1); + testing.mockedIngestion.waitForStandardMetricItems("requests/duration", 1); verifyHttpClientPreAggregatedMetrics(clientMetrics, iKey); verifyHttpServerPreAggregatedMetrics(serverMetrics, iKey); 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..41fc0b52042 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 @@ -14,14 +14,10 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import com.microsoft.applicationinsights.smoketest.schemav2.Data; -import com.microsoft.applicationinsights.smoketest.schemav2.Envelope; import com.microsoft.applicationinsights.smoketest.schemav2.MetricData; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import java.util.function.Predicate; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; @@ -47,6 +43,8 @@ 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"); + EXPECTED_METRIC_NAMES.add("http.server.request.duration"); + EXPECTED_METRIC_NAMES.add("http.client.request.duration"); } @Test @@ -66,29 +64,6 @@ void testApp() throws Exception { .isInstanceOf(TimeoutException.class); } - // wait for at least one unexpected otel metrics for failure case or timeout for success - public List waitForItemsUnexpectedOtelMetric(String type, Predicate condition) - throws InterruptedException, ExecutionException, TimeoutException { - return testing.mockedIngestion.waitForItems( - new Predicate() { - @Override - public boolean test(Envelope input) { - if (!input.getData().getBaseType().equals(type)) { - return false; - } - MetricData md = (MetricData) ((Data) input.getData()).getBaseData(); - if ("_OTELRESOURCE_".equals(md.getMetrics().get(0).getName()) - || md.getProperties().containsKey("_MS.MetricId")) { - return false; - } - return condition.test(input); - } - }, - 1, - 10, - TimeUnit.SECONDS); - } - @Environment(TOMCAT_8_JAVA_8) static class Tomcat8Java8Test extends DetectUnexpectedOtelMetricsTest {} diff --git a/smoke-tests/apps/HttpPreaggregatedMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/HttpPreaggregatedMetricsTest.java b/smoke-tests/apps/HttpPreaggregatedMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/HttpPreaggregatedMetricsTest.java index ec345730571..02fb85e4826 100644 --- a/smoke-tests/apps/HttpPreaggregatedMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/HttpPreaggregatedMetricsTest.java +++ b/smoke-tests/apps/HttpPreaggregatedMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/HttpPreaggregatedMetricsTest.java @@ -45,9 +45,9 @@ private void testHttpUrlConnectionAndSynthetic(boolean synthetic) throws Excepti verifyHttpclientRequestsAndDependencies("https://mock.codes/200?q=spaces%20test"); List clientMetrics = - testing.mockedIngestion.waitForMetricItems("http.client.request.duration", 3); + testing.mockedIngestion.waitForStandardMetricItems("dependencies/duration", 3); List serverMetrics = - testing.mockedIngestion.waitForMetricItems("http.server.request.duration", 1); + testing.mockedIngestion.waitForStandardMetricItems("requests/duration", 1); verifyHttpClientPreAggregatedMetrics(clientMetrics); verifyHttpServerPreAggregatedMetrics(serverMetrics, synthetic); diff --git a/smoke-tests/apps/InstrumentationKeyOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/InstrumentationKeyOverridesTest.java b/smoke-tests/apps/InstrumentationKeyOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/InstrumentationKeyOverridesTest.java index 3a61ed8a47c..7587a65f89e 100644 --- a/smoke-tests/apps/InstrumentationKeyOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/InstrumentationKeyOverridesTest.java +++ b/smoke-tests/apps/InstrumentationKeyOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/InstrumentationKeyOverridesTest.java @@ -88,9 +88,9 @@ private static void testApp(String iKey) throws Exception { // and metrics too List clientMetrics = - testing.mockedIngestion.waitForMetricItems("http.client.request.duration", 1); + testing.mockedIngestion.waitForStandardMetricItems("dependencies/duration", 1); List serverMetrics = - testing.mockedIngestion.waitForMetricItems("http.server.request.duration", 1); + testing.mockedIngestion.waitForStandardMetricItems("requests/duration", 1); verifyHttpClientPreAggregatedMetrics(clientMetrics, iKey); verifyHttpServerPreAggregatedMetrics(serverMetrics, iKey); diff --git a/smoke-tests/apps/OtlpMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/OtlpTest.java b/smoke-tests/apps/OtlpMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/OtlpTest.java index eb821df87aa..5014bec1a9d 100644 --- a/smoke-tests/apps/OtlpMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/OtlpTest.java +++ b/smoke-tests/apps/OtlpMetrics/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/OtlpTest.java @@ -46,10 +46,21 @@ public void testOtlpTelemetry() throws Exception { MetricData metricData = (MetricData) ((Data) metricEnvelope.getData()).getBaseData(); assertThat(metricData.getMetrics().get(0).getName()).isEqualTo("histogram-test-otlp-exporter"); + // verify stable otel metric sent to Application Insights endpoint + List stableOtelMetrics = + testing.mockedIngestion.waitForItems("MetricData", OtlpTest::isStableOtelMetric, 1); + Envelope stableOtelMetricEnvelope = stableOtelMetrics.get(0); + assertThat( + ((MetricData) ((Data) stableOtelMetricEnvelope.getData()).getBaseData()) + .getMetrics() + .get(0) + .getName()) + .isEqualTo("http.server.request.duration"); + // verify pre-aggregated standard metric sent to Application Insights endpoint - List standardMetricsList = - testing.mockedIngestion.waitForItems("MetricData", OtlpTest::isStandardMetric, 1); - Envelope standardMetricEnvelope = standardMetricsList.get(0); + List standardMetrics = + testing.mockedIngestion.waitForStandardMetricItems("requests/duration", 1); + Envelope standardMetricEnvelope = standardMetrics.get(0); MetricData standardMetricData = (MetricData) ((Data) standardMetricEnvelope.getData()).getBaseData(); assertThat(standardMetricData.getMetrics().get(0).getName()) @@ -95,10 +106,11 @@ private static boolean isHistogramMetric(Envelope envelope) { return false; } - private static boolean isStandardMetric(Envelope envelope) { + private static boolean isStableOtelMetric(Envelope envelope) { if (envelope.getData().getBaseType().equals("MetricData")) { MetricData data = (MetricData) ((Data) envelope.getData()).getBaseData(); - return data.getMetrics().get(0).getName().equals("http.server.request.duration"); + return data.getMetrics().get(0).getName().equals("http.server.request.duration") + && data.getProperties().get("http.response.status_code") != null; } return false; } diff --git a/smoke-tests/apps/PreAggMetricsWithRoleNameOverridesAndSampling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/PreAggMetricsWithRoleNameOverridesAndSamplingTest.java b/smoke-tests/apps/PreAggMetricsWithRoleNameOverridesAndSampling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/PreAggMetricsWithRoleNameOverridesAndSamplingTest.java index 5d5e0283d3f..6b7179e5233 100644 --- a/smoke-tests/apps/PreAggMetricsWithRoleNameOverridesAndSampling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/PreAggMetricsWithRoleNameOverridesAndSamplingTest.java +++ b/smoke-tests/apps/PreAggMetricsWithRoleNameOverridesAndSampling/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/PreAggMetricsWithRoleNameOverridesAndSamplingTest.java @@ -66,9 +66,11 @@ private void testApp(String roleName) throws Exception { for (Envelope envelope : metricsEnvelops) { MetricData metricData = (MetricData) ((Data) envelope.getData()).getBaseData(); String name = metricData.getMetrics().get(0).getName(); - if ("http.client.request.duration".equals(name)) { + if ("http.client.request.duration".equals(name) + && "dependencies/duration".equals(metricData.getProperties().get("_MS.MetricId"))) { clientMetrics.add(envelope); - } else if ("http.server.request.duration".equals(name)) { + } else if ("http.server.request.duration".equals(name) + && "requests/duration".equals(metricData.getProperties().get("_MS.MetricId"))) { serverMetrics.add(envelope); } } diff --git a/smoke-tests/apps/RoleNameOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/AksRoleNameOverridesTest.java b/smoke-tests/apps/RoleNameOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/AksRoleNameOverridesTest.java index 73f7271eeab..c231aa525d6 100644 --- a/smoke-tests/apps/RoleNameOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/AksRoleNameOverridesTest.java +++ b/smoke-tests/apps/RoleNameOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/AksRoleNameOverridesTest.java @@ -57,13 +57,13 @@ private static void verifyRoleNameAndInstance(String roleName, String roleInstan assertThat(mdList.get(0).getTags()).containsEntry("ai.cloud.roleInstance", roleInstance); List clientMetrics = - testing.mockedIngestion.waitForMetricItems("http.client.request.duration", 1); + testing.mockedIngestion.waitForStandardMetricItems("dependencies/duration", 1); Map clientTags = clientMetrics.get(0).getTags(); assertThat(clientTags.get("ai.cloud.role")).isEqualTo(roleName); assertThat(clientTags.get("ai.cloud.roleInstance")).isEqualTo(roleInstance); List serverMetrics = - testing.mockedIngestion.waitForMetricItems("http.server.request.duration", 1); + testing.mockedIngestion.waitForStandardMetricItems("requests/duration", 1); Map serverTags = serverMetrics.get(0).getTags(); assertThat(serverTags.get("ai.cloud.role")).isEqualTo(roleName); assertThat(serverTags.get("ai.cloud.roleInstance")).isEqualTo(roleInstance); diff --git a/smoke-tests/apps/RoleNameOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/RoleNameOverridesTest.java b/smoke-tests/apps/RoleNameOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/RoleNameOverridesTest.java index 9e7d8cbe0c5..df97d1f0ce8 100644 --- a/smoke-tests/apps/RoleNameOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/RoleNameOverridesTest.java +++ b/smoke-tests/apps/RoleNameOverrides/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/RoleNameOverridesTest.java @@ -98,9 +98,9 @@ private static void testApp(String roleName) throws Exception { // and metrics too List clientMetrics = - testing.mockedIngestion.waitForMetricItems("http.client.request.duration", 1); + testing.mockedIngestion.waitForStandardMetricItems("dependencies/duration", 1); List serverMetrics = - testing.mockedIngestion.waitForMetricItems("http.server.request.duration", 1); + testing.mockedIngestion.waitForStandardMetricItems("requests/duration", 1); verifyHttpClientPreAggregatedMetrics(clientMetrics, roleName); verifyHttpServerPreAggregatedMetrics(serverMetrics, roleName); diff --git a/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/SmokeTestExtension.java b/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/SmokeTestExtension.java index c29bde57d39..aa60694e93e 100644 --- a/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/SmokeTestExtension.java +++ b/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/SmokeTestExtension.java @@ -689,4 +689,18 @@ public static Predicate getMetricPredicate( return name.equals(md.getMetrics().get(0).getName()) && isSecondPredicateValid; }; } + + public static Predicate getStandardMetricPredicate(String metricId) { + Objects.requireNonNull(metricId, "metricId"); + return input -> { + if (input == null) { + return false; + } + if (!input.getData().getBaseType().equals("MetricData")) { + return false; + } + MetricData md = getBaseData(input); + return metricId.equals(md.getProperties().get("_MS.MetricId")); + }; + } } diff --git a/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServer.java b/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServer.java index 57e72b70282..661a63b9217 100644 --- a/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServer.java +++ b/smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedAppInsightsIngestionServer.java @@ -7,7 +7,6 @@ import com.microsoft.applicationinsights.smoketest.schemav2.Data; import com.microsoft.applicationinsights.smoketest.schemav2.Domain; import com.microsoft.applicationinsights.smoketest.schemav2.Envelope; -import com.microsoft.applicationinsights.smoketest.schemav2.MetricData; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -236,6 +235,12 @@ public List waitForMetricItems( timeUnit); } + public List waitForStandardMetricItems(String metricId, int numItems) + throws InterruptedException, TimeoutException { + return servlet.waitForItems( + SmokeTestExtension.getStandardMetricPredicate(metricId), numItems, 70, TimeUnit.SECONDS); + } + // this is important for Message and Exception types which can also be captured outside of // requests public List waitForItemsInOperation(String type, int numItems, String operationId) @@ -249,32 +254,6 @@ public List waitForItemsInOperation( return waitForItems(type, numItems, operationId, condition); } - // wait for at least one unexpected otel metrics for failure case or timeout for success - public List waitForItemsUnexpectedOtelMetric( - String type, Predicate condition, List expectedMetricNames) - throws InterruptedException, ExecutionException, TimeoutException { - return waitForItems( - new Predicate() { - @Override - public boolean test(Envelope input) { - if (!input.getData().getBaseType().equals(type)) { - return false; - } - MetricData md = (MetricData) ((Data) input.getData()).getBaseData(); - // return false if the metric name is expected - // "_MS.MetricId" is the metric name for pre-aggregated metrics - if (expectedMetricNames.contains(md.getMetrics().get(0).getName()) - || md.getProperties().containsKey("_MS.MetricId")) { - return false; - } - return condition.test(input); - } - }, - 1, - 10, - TimeUnit.SECONDS); - } - // this is used to filter out some sporadic messages that are captured via java.util.logging // instrumentation public List waitForMessageItemsInRequest(int numItems, String operationId)