Disable _otelresource_ custom metric in non-AKS envs (#3710)
Co-authored-by: heyams <heya@microsoft.com> Co-authored-by: Helen <56097766+heyams@users.noreply.github.com>
This commit is contained in:
Родитель
50c8febf98
Коммит
233328f734
|
@ -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.23 # to be updated with the latest version
|
||||
|
||||
jobs:
|
||||
spotless:
|
||||
|
|
|
@ -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.23")
|
||||
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-bootstrap")
|
||||
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling")
|
||||
compileOnly("io.opentelemetry.javaagent.instrumentation:opentelemetry-javaagent-servlet-common-bootstrap")
|
||||
|
|
|
@ -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.23=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
|
||||
|
|
|
@ -350,7 +350,7 @@ _2024-05-27 03:31:29 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.22`
|
||||
**67** **Group:** `com.azure` **Name:** `azure-monitor-opentelemetry-exporter` **Version:** `1.0.0-beta.23`
|
||||
> - **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`
|
||||
|
|
|
@ -29,9 +29,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
|||
@UseAgent
|
||||
abstract class ConnectionStringOverridesTest {
|
||||
|
||||
@RegisterExtension
|
||||
static final SmokeTestExtension testing =
|
||||
SmokeTestExtension.builder().otelResourceAttributesEnvVar("key1=value1,key2=value2").build();
|
||||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create();
|
||||
|
||||
@Test
|
||||
@TargetUri("/app2")
|
||||
|
@ -46,11 +44,6 @@ abstract class ConnectionStringOverridesTest {
|
|||
}
|
||||
|
||||
private static void testApp(String iKey) throws Exception {
|
||||
// verify _OTELRESOURCE_ custom metric per connection string
|
||||
List<Envelope> otelResourceMetrics =
|
||||
testing.mockedIngestion.waitForMetricItems("_OTELRESOURCE_", iKey, 1, false);
|
||||
verifyOtelResourceAttributeCustomMetric(otelResourceMetrics, iKey);
|
||||
|
||||
List<Envelope> rdList = testing.mockedIngestion.waitForItems("RequestData", 1);
|
||||
|
||||
Envelope rdEnvelope = rdList.get(0);
|
||||
|
@ -106,21 +99,6 @@ abstract class ConnectionStringOverridesTest {
|
|||
verifyHttpServerPreAggregatedMetrics(serverMetrics, iKey);
|
||||
}
|
||||
|
||||
private static void verifyOtelResourceAttributeCustomMetric(
|
||||
List<Envelope> otelResourceMetrics, String iKey) {
|
||||
Map<String, String> tags = otelResourceMetrics.get(0).getTags();
|
||||
assertThat(otelResourceMetrics.get(0).getIKey()).isEqualTo(iKey);
|
||||
assertThat(tags.get("ai.internal.sdkVersion")).isNotNull();
|
||||
assertThat(tags.get("ai.cloud.roleInstance")).isNotNull();
|
||||
assertThat(tags.get("ai.cloud.role")).isEqualTo("testrolename");
|
||||
|
||||
MetricData otelResourceMetricData =
|
||||
(MetricData) ((Data<?>) otelResourceMetrics.get(0).getData()).getBaseData();
|
||||
Map<String, String> properties = otelResourceMetricData.getProperties();
|
||||
assertThat(properties.get("key1")).isEqualTo("value1");
|
||||
assertThat(properties.get("key2")).isEqualTo("value2");
|
||||
}
|
||||
|
||||
private static void verifyHttpClientPreAggregatedMetrics(List<Envelope> metrics, String iKey) {
|
||||
assertThat(metrics.size()).isEqualTo(1);
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
package com.microsoft.applicationinsights.smoketest;
|
||||
|
||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11;
|
||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11_OPENJ9;
|
||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_17;
|
||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_21;
|
||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8;
|
||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9;
|
||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8;
|
||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import com.microsoft.applicationinsights.smoketest.schemav2.Data;
|
||||
import com.microsoft.applicationinsights.smoketest.schemav2.Envelope;
|
||||
import com.microsoft.applicationinsights.smoketest.schemav2.MetricData;
|
||||
import java.util.List;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@UseAgent
|
||||
abstract class DefaultOtelResourceAttributesTest {
|
||||
|
||||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create();
|
||||
|
||||
@Test
|
||||
@TargetUri(value = "/app")
|
||||
void testApp() {
|
||||
List<Envelope> metricsEnvelops = testing.mockedIngestion.getItemsEnvelopeDataType("MetricData");
|
||||
metricsEnvelops.stream()
|
||||
.map(envelope -> (MetricData) ((Data<?>) envelope.getData()).getBaseData())
|
||||
.map(metricData -> metricData.getMetrics().get(0).getName())
|
||||
.forEach(name -> assertThat(name).isNotEqualTo("_OTELRESOURCE_"));
|
||||
}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_8)
|
||||
static class Tomcat8Java8Test extends DefaultOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_8_OPENJ9)
|
||||
static class Tomcat8Java8OpenJ9Test extends DefaultOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_11)
|
||||
static class Tomcat8Java11Test extends DefaultOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_11_OPENJ9)
|
||||
static class Tomcat8Java11OpenJ9Test extends DefaultOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_17)
|
||||
static class Tomcat8Java17Test extends DefaultOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_21)
|
||||
static class Tomcat8Java21Test extends DefaultOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(WILDFLY_13_JAVA_8)
|
||||
static class Wildfly13Java8Test extends DefaultOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(WILDFLY_13_JAVA_8_OPENJ9)
|
||||
static class Wildfly13Java8OpenJ9Test extends DefaultOtelResourceAttributesTest {}
|
||||
}
|
|
@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test;
|
|||
import org.junit.jupiter.api.extension.RegisterExtension;
|
||||
|
||||
@UseAgent
|
||||
abstract class OtelResourceCustomMetricTest {
|
||||
abstract class EnvVarOtelResourceAttributesTest {
|
||||
|
||||
private static final String OTEL_RESOURCE_ATTRIBUTES =
|
||||
"cloud.resource_id=/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxdfcdaa1/resourceGroups/fake-aks-cluster-name/providers/Microsoft.ContainerService/managedClusters/aks-vanilla-1,cloud.region=eastus,k8s.cluster.name=aks-vanilla-1,k8s.pod.namespace=default,k8s.node.name=aks-agentpool-19737836-vmss000001,k8s.pod.name=customer-test-app-78d8bf887c-nplmk,k8s.pod.uid=efa8fdda-873c-4a6f-b02a-8d3b00bc34a7,k8s.container.name=test-app-java,cloud.provider=Azure,cloud.platform=azure_aks,k8s.replicaset.name=customer-java-very-big-756899c8b6,k8s.deployment.name=customer-java-very-big,k8s.replicaset.uid=69ef5d52-c770-4ec7-a3a2-2e2e8e885b3d";
|
||||
|
@ -34,10 +34,8 @@ abstract class OtelResourceCustomMetricTest {
|
|||
static final SmokeTestExtension testing =
|
||||
SmokeTestExtension.builder().otelResourceAttributesEnvVar(OTEL_RESOURCE_ATTRIBUTES).build();
|
||||
|
||||
private static final int COUNT = 100;
|
||||
|
||||
@Test
|
||||
@TargetUri(value = "/app", callCount = COUNT)
|
||||
@TargetUri(value = "/app")
|
||||
void testApp() {
|
||||
List<Envelope> metricsEnvelops = testing.mockedIngestion.getItemsEnvelopeDataType("MetricData");
|
||||
List<Envelope> otelResourceCustomMetrics = new ArrayList<>();
|
||||
|
@ -62,7 +60,8 @@ abstract class OtelResourceCustomMetricTest {
|
|||
|
||||
private static void validateTags(Envelope envelope) {
|
||||
Map<String, String> tags = envelope.getTags();
|
||||
assertThat(tags.get("ai.internal.sdkVersion")).isNotNull();
|
||||
assertThat(tags).hasSize(3);
|
||||
assertThat(tags).containsKey("ai.internal.sdkVersion");
|
||||
assertThat(tags).containsEntry("ai.cloud.roleInstance", "customer-test-app-78d8bf887c-nplmk");
|
||||
assertThat(tags).containsEntry("ai.cloud.role", "customer-java-very-big");
|
||||
}
|
||||
|
@ -87,26 +86,26 @@ abstract class OtelResourceCustomMetricTest {
|
|||
}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_8)
|
||||
static class Tomcat8Java8Test extends OtelResourceCustomMetricTest {}
|
||||
static class Tomcat8Java8Test extends EnvVarOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_8_OPENJ9)
|
||||
static class Tomcat8Java8OpenJ9Test extends OtelResourceCustomMetricTest {}
|
||||
static class Tomcat8Java8OpenJ9Test extends EnvVarOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_11)
|
||||
static class Tomcat8Java11Test extends OtelResourceCustomMetricTest {}
|
||||
static class Tomcat8Java11Test extends EnvVarOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_11_OPENJ9)
|
||||
static class Tomcat8Java11OpenJ9Test extends OtelResourceCustomMetricTest {}
|
||||
static class Tomcat8Java11OpenJ9Test extends EnvVarOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_17)
|
||||
static class Tomcat8Java17Test extends OtelResourceCustomMetricTest {}
|
||||
static class Tomcat8Java17Test extends EnvVarOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_21)
|
||||
static class Tomcat8Java21Test extends OtelResourceCustomMetricTest {}
|
||||
static class Tomcat8Java21Test extends EnvVarOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(WILDFLY_13_JAVA_8)
|
||||
static class Wildfly13Java8Test extends OtelResourceCustomMetricTest {}
|
||||
static class Wildfly13Java8Test extends EnvVarOtelResourceAttributesTest {}
|
||||
|
||||
@Environment(WILDFLY_13_JAVA_8_OPENJ9)
|
||||
static class Wildfly13Java8OpenJ9Test extends OtelResourceCustomMetricTest {}
|
||||
static class Wildfly13Java8OpenJ9Test extends EnvVarOtelResourceAttributesTest {}
|
||||
}
|
|
@ -15,6 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
|
||||
import com.microsoft.applicationinsights.smoketest.schemav2.Data;
|
||||
import com.microsoft.applicationinsights.smoketest.schemav2.Envelope;
|
||||
import com.microsoft.applicationinsights.smoketest.schemav2.MetricData;
|
||||
import com.microsoft.applicationinsights.smoketest.schemav2.RequestData;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -39,6 +40,12 @@ abstract class AksRoleNameOverridesTest {
|
|||
|
||||
private static void verifyRoleNameAndInstance(String roleName, String roleInstance)
|
||||
throws Exception {
|
||||
|
||||
// verify _OTELRESOURCE_ custom metric per role name
|
||||
List<Envelope> otelResourceMetrics =
|
||||
testing.mockedIngestion.waitForMetricItems("_OTELRESOURCE_", roleName, 1, true);
|
||||
verifyOtelResourceAttributeCustomMetric(otelResourceMetrics);
|
||||
|
||||
List<Envelope> rdList = testing.mockedIngestion.waitForItems("RequestData", 1);
|
||||
Envelope rdEnvelope = rdList.get(0);
|
||||
assertThat(rdEnvelope.getTags()).containsEntry("ai.cloud.role", roleName);
|
||||
|
@ -69,6 +76,22 @@ abstract class AksRoleNameOverridesTest {
|
|||
assertThat(serverTags.get("ai.cloud.roleInstance")).isEqualTo(roleInstance);
|
||||
}
|
||||
|
||||
private static void verifyOtelResourceAttributeCustomMetric(List<Envelope> otelResourceMetrics) {
|
||||
Map<String, String> tags = otelResourceMetrics.get(0).getTags();
|
||||
assertThat(tags.get("ai.internal.sdkVersion")).isNotNull();
|
||||
assertThat(tags.get("ai.cloud.roleInstance")).isEqualTo("test-pod-name");
|
||||
assertThat(tags.get("ai.cloud.role")).isEqualTo("test-deployment-name");
|
||||
|
||||
MetricData otelResourceMetricData =
|
||||
(MetricData) ((Data<?>) otelResourceMetrics.get(0).getData()).getBaseData();
|
||||
Map<String, String> properties = otelResourceMetricData.getProperties();
|
||||
assertThat(properties.get("cloud.provider")).isEqualTo("Azure");
|
||||
assertThat(properties.get("cloud.platform")).isEqualTo("azure_aks");
|
||||
assertThat(properties.get("telemetry.sdk.language")).isEqualTo("java");
|
||||
assertThat(properties.get("service.name")).isEqualTo("test-deployment-name");
|
||||
assertThat(properties.get("service.instance.id")).isEqualTo("test-pod-name");
|
||||
}
|
||||
|
||||
@Environment(TOMCAT_8_JAVA_8)
|
||||
static class Tomcat8Java8Test extends AksRoleNameOverridesTest {}
|
||||
|
||||
|
|
|
@ -29,12 +29,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
|||
@UseAgent("overrides_applicationinsights.json")
|
||||
abstract class RoleNameOverridesTest {
|
||||
|
||||
@RegisterExtension
|
||||
static final SmokeTestExtension testing =
|
||||
SmokeTestExtension.builder()
|
||||
.otelResourceAttributesEnvVar(
|
||||
"fakeOtelResourceKey1=fakeValue1,fakeOtelResourceKey2=fakeValue2,fakeOtelResourceKey3=fakeValue3")
|
||||
.build();
|
||||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create();
|
||||
|
||||
@Test
|
||||
@TargetUri("/app2")
|
||||
|
@ -49,11 +44,6 @@ abstract class RoleNameOverridesTest {
|
|||
}
|
||||
|
||||
private static void testApp(String roleName) throws Exception {
|
||||
// verify _OTELRESOURCE_ custom metric per role name
|
||||
List<Envelope> otelResourceMetrics =
|
||||
testing.mockedIngestion.waitForMetricItems("_OTELRESOURCE_", roleName, 1, true);
|
||||
verifyOtelResourceAttributeCustomMetric(otelResourceMetrics, roleName);
|
||||
|
||||
List<Envelope> rdList = testing.mockedIngestion.waitForItems("RequestData", 1);
|
||||
Envelope rdEnvelope = rdList.get(0);
|
||||
String operationId = rdEnvelope.getTags().get("ai.operation.id");
|
||||
|
@ -106,21 +96,6 @@ abstract class RoleNameOverridesTest {
|
|||
verifyHttpServerPreAggregatedMetrics(serverMetrics, roleName);
|
||||
}
|
||||
|
||||
private static void verifyOtelResourceAttributeCustomMetric(
|
||||
List<Envelope> otelResourceMetrics, String rolename) {
|
||||
Map<String, String> tags = otelResourceMetrics.get(0).getTags();
|
||||
assertThat(tags.get("ai.internal.sdkVersion")).isNotNull();
|
||||
assertThat(tags.get("ai.cloud.roleInstance")).isNotNull();
|
||||
assertThat(tags.get("ai.cloud.role")).isEqualTo(rolename);
|
||||
|
||||
MetricData otelResourceMetricData =
|
||||
(MetricData) ((Data<?>) otelResourceMetrics.get(0).getData()).getBaseData();
|
||||
Map<String, String> properties = otelResourceMetricData.getProperties();
|
||||
assertThat(properties.get("fakeOtelResourceKey1")).isEqualTo("fakeValue1");
|
||||
assertThat(properties.get("fakeOtelResourceKey2")).isEqualTo("fakeValue2");
|
||||
assertThat(properties.get("fakeOtelResourceKey3")).isEqualTo("fakeValue3");
|
||||
}
|
||||
|
||||
private static void verifyHttpClientPreAggregatedMetrics(
|
||||
List<Envelope> metrics, String roleName) {
|
||||
assertThat(metrics.size()).isEqualTo(1);
|
||||
|
|
Загрузка…
Ссылка в новой задаче