From 13e139f8e37a713eb9dd2cd2ecb22aabb393b577 Mon Sep 17 00:00:00 2001 From: alkaplan Date: Wed, 19 Nov 2025 14:49:30 -0800 Subject: [PATCH] Moving to setting APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED=true for Java to work instead of -Dotel.metrics.exporter=otlp,azure_monitor --- appmonitoring/ts/src/Mutations.ts | 6 +++++- appmonitoring/ts/src/tests/Mutator.spec.ts | 9 +++++++++ appmonitoring/ts/src/tests/Patcher.spec.ts | 1 + appmonitoring/validation-helm/test-apps/java/pom.xml | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/appmonitoring/ts/src/Mutations.ts b/appmonitoring/ts/src/Mutations.ts index 5223eb7b5..970f5e2a3 100644 --- a/appmonitoring/ts/src/Mutations.ts +++ b/appmonitoring/ts/src/Mutations.ts @@ -225,6 +225,10 @@ export class Mutations { { name: "APPLICATIONINSIGHTS_CONNECTION_STRING", value: connectionString + }, + { + name: "APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED", + value: "true" }, ]; @@ -312,7 +316,7 @@ export class Mutations { { returnValue.push(...[{ name: "JAVA_TOOL_OPTIONS", - value: `-javaagent:${Mutations.agentVolumeMountPathJava}/applicationinsights-agent-codeless.jar -Dotel.metrics.exporter=otlp,azure_monitor`, + value: `-javaagent:${Mutations.agentVolumeMountPathJava}/applicationinsights-agent-codeless.jar`, platformSpecific: platforms[i] }, { diff --git a/appmonitoring/ts/src/tests/Mutator.spec.ts b/appmonitoring/ts/src/tests/Mutator.spec.ts index 674a2d7be..b27f98d84 100644 --- a/appmonitoring/ts/src/tests/Mutator.spec.ts +++ b/appmonitoring/ts/src/tests/Mutator.spec.ts @@ -746,6 +746,9 @@ describe("Mutator", () => { const connectionStringEnv = container.env.find(env => env.name === "APPLICATIONINSIGHTS_CONNECTION_STRING"); expect(connectionStringEnv.value).toBe("InstrumentationKey=cr1"); + const metricsToLAEnv = container.env.find(env => env.name === "APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED"); + expect(metricsToLAEnv.value).toBe("true"); + const nodeIpEnv = container.env.find(env => env.name === "OTEL_ENDPOINT_NODE_IP"); expect(nodeIpEnv.valueFrom.fieldRef.fieldPath).toBe("status.hostIP"); @@ -858,6 +861,9 @@ describe("Mutator", () => { const connectionStringEnv = container.env.find(env => env.name === "APPLICATIONINSIGHTS_CONNECTION_STRING"); expect(connectionStringEnv.value).toBe("InstrumentationKey=default"); + const metricsToLAEnv = container.env.find(env => env.name === "APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED"); + expect(metricsToLAEnv.value).toBe("true"); + // Verify node IP environment variable for OTEL endpoint const nodeIpEnv = container.env.find(env => env.name === "OTEL_ENDPOINT_NODE_IP"); expect(nodeIpEnv.valueFrom.fieldRef.fieldPath).toBe("status.hostIP"); @@ -955,6 +961,9 @@ describe("Mutator", () => { const connectionStringEnv = container.env.find(env => env.name === "APPLICATIONINSIGHTS_CONNECTION_STRING"); expect(connectionStringEnv).toBeUndefined(); + const metricsToLAEnv = container.env.find(env => env.name === "APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED"); + expect(metricsToLAEnv).toBeUndefined(); + const nodeIpEnv = container.env.find(env => env.name === "OTEL_ENDPOINT_NODE_IP"); expect(nodeIpEnv).toBeUndefined(); } diff --git a/appmonitoring/ts/src/tests/Patcher.spec.ts b/appmonitoring/ts/src/tests/Patcher.spec.ts index d314199b0..cd312606b 100644 --- a/appmonitoring/ts/src/tests/Patcher.spec.ts +++ b/appmonitoring/ts/src/tests/Patcher.spec.ts @@ -143,6 +143,7 @@ describe("Patcher", () => { (result[0]).value.spec.template.spec.containers[1].env.forEach(env => expect(env.isPlatformSpecific).not.toBe(true)); expect((result[0]).value.spec.template.spec.containers[0].env).toContainEqual({ name: "OTEL_RESOURCE_ATTRIBUTES", value: "cloud.resource_id=/subscriptions/66010356-d8a5-42d3-8593-6aaa3aeb1c11/resourceGroups/rambhatt-rnd-v2/providers/Microsoft.ContainerService/managedClusters/aks-rambhatt-test,cloud.region=eastus,k8s.cluster.name=aks-rambhatt-test,k8s.namespace.name=$(POD_NAMESPACE),k8s.node.name=$(NODE_NAME),k8s.pod.name=$(POD_NAME),k8s.pod.uid=$(POD_UID),k8s.container.name=" + container0Name + ",cloud.provider=Azure,cloud.platform=azure_aks,k8s.deployment.name=deployment1,k8s.deployment.uid=ownerUid,service.name=deployment1,service.instance.id=$(POD_NAME)" }); expect((result[0]).value.spec.template.spec.containers[1].env).toContainEqual({ name: "APPLICATIONINSIGHTS_CONNECTION_STRING", value: cr1.spec.destination.applicationInsightsConnectionString }); + expect((result[0]).value.spec.template.spec.containers[1].env).toContainEqual({ name: "APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED", value: "true" }); const newVolumeMounts: object[] = Mutations.GenerateVolumeMounts(cr1.spec.settings.autoInstrumentationPlatforms); diff --git a/appmonitoring/validation-helm/test-apps/java/pom.xml b/appmonitoring/validation-helm/test-apps/java/pom.xml index 2b85771ed..5d2ad57a3 100644 --- a/appmonitoring/validation-helm/test-apps/java/pom.xml +++ b/appmonitoring/validation-helm/test-apps/java/pom.xml @@ -35,7 +35,7 @@ spring-boot-starter-actuator ${spring-boot.version} - + io.opentelemetry