Read environment variables for AKS metrics otlp support#4458
Merged
Conversation
4bb5788 to
732a57f
Compare
732a57f to
0f009a6
Compare
trask
reviewed
Sep 20, 2025
.../framework/src/main/java/com/microsoft/applicationinsights/smoketest/SmokeTestExtension.java
Outdated
Show resolved
Hide resolved
trask
reviewed
Sep 20, 2025
...ork/src/main/java/com/microsoft/applicationinsights/smoketest/SmokeTestExtensionBuilder.java
Outdated
Show resolved
Hide resolved
1e05ccc to
9aec7b3
Compare
trask
reviewed
Sep 20, 2025
...src/test/java/com/microsoft/applicationinsights/agent/internal/PreAggregatedMetricsTest.java
Show resolved
Hide resolved
trask
reviewed
Sep 20, 2025
...smokeTest/java/com/microsoft/applicationinsights/smoketest/OpenTelemetryMetricTestToAmw.java
Outdated
Show resolved
Hide resolved
…ove branch in build-common.yml.
trask
approved these changes
Sep 25, 2025
Comment on lines
+54
to
+75
| // sort metrics based on result code | ||
| metrics.sort( | ||
| Comparator.comparing( | ||
| obj -> { | ||
| MetricData metricData = (MetricData) ((Data<?>) obj.getData()).getBaseData(); | ||
| return metricData.getProperties().get("dependency/resultCode"); | ||
| })); | ||
|
|
||
| // 1st pre-aggregated metric | ||
| Envelope envelope1 = metrics.get(0); | ||
| MetricData md1 = (MetricData) ((Data<?>) envelope1.getData()).getBaseData(); | ||
| validateMetricData(md1); | ||
|
|
||
| // 2nd pre-aggregated metric | ||
| Envelope envelope2 = metrics.get(1); | ||
| MetricData md2 = (MetricData) ((Data<?>) envelope2.getData()).getBaseData(); | ||
| validateMetricData(md2); | ||
|
|
||
| // 3rd pre-aggregated metric | ||
| Envelope envelope3 = metrics.get(2); | ||
| MetricData md3 = (MetricData) ((Data<?>) envelope3.getData()).getBaseData(); | ||
| validateMetricData(md3); |
Member
There was a problem hiding this comment.
is sorting needed? looks like same verification is performed for all 3
Suggested change
| // sort metrics based on result code | |
| metrics.sort( | |
| Comparator.comparing( | |
| obj -> { | |
| MetricData metricData = (MetricData) ((Data<?>) obj.getData()).getBaseData(); | |
| return metricData.getProperties().get("dependency/resultCode"); | |
| })); | |
| // 1st pre-aggregated metric | |
| Envelope envelope1 = metrics.get(0); | |
| MetricData md1 = (MetricData) ((Data<?>) envelope1.getData()).getBaseData(); | |
| validateMetricData(md1); | |
| // 2nd pre-aggregated metric | |
| Envelope envelope2 = metrics.get(1); | |
| MetricData md2 = (MetricData) ((Data<?>) envelope2.getData()).getBaseData(); | |
| validateMetricData(md2); | |
| // 3rd pre-aggregated metric | |
| Envelope envelope3 = metrics.get(2); | |
| MetricData md3 = (MetricData) ((Data<?>) envelope3.getData()).getBaseData(); | |
| validateMetricData(md3); | |
| for (Envelope envelope : metrics) { | |
| MetricData md = (MetricData) ((Data<?>) envelope.getData()).getBaseData(); | |
| validateMetricData(md); | |
| } |
|
|
||
| private static void verifyHttpServerPreAggregatedMetrics(List<Envelope> metrics) { | ||
| assertThat(metrics.size()).isEqualTo(1); | ||
| // 1st pre-aggregated metric |
Member
There was a problem hiding this comment.
(there's only 1)
Suggested change
| // 1st pre-aggregated metric |
| List<Metric> otlpMetrics = | ||
| testing.mockedOtlpIngestion.extractMetricsFromRequests(otlpRequests); | ||
|
|
||
| assertThat(otlpMetrics).hasSizeGreaterThanOrEqualTo(3); |
Member
There was a problem hiding this comment.
it may be worth adding assertions about the name and attributes of these 3 metrics
trask
approved these changes
Sep 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR will read the following env vars so that the MetricDataMapper can append the necessary attribute to metric / send the metrics to the right places:
OTEL_METRICS_EXPORTER
OTEL_METRICS_EXPORTER_OTLP_ENDPOINT
APPLICATIONINSIGHTS_METRICS_TO_LOGANALYTICS_ENABLED
Note: still in draft mode because this depends on the azure-sdk-for-java pr, and won't build until I build on top of this pr. I also need to test the e2e behavior once I have a built java agent.