- Notifications
You must be signed in to change notification settings - Fork 208
Read environment variables for AKS metrics otlp support #4458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4bb5788
to 732a57f
Compare 732a57f
to 0f009a6
Compare .../framework/src/main/java/com/microsoft/applicationinsights/smoketest/SmokeTestExtension.java Outdated Show resolved Hide resolved
...ork/src/main/java/com/microsoft/applicationinsights/smoketest/SmokeTestExtensionBuilder.java Outdated Show resolved Hide resolved
1e05ccc
to 9aec7b3
Compare ...src/test/java/com/microsoft/applicationinsights/agent/internal/PreAggregatedMetricsTest.java Show resolved Hide resolved
...smokeTest/java/com/microsoft/applicationinsights/smoketest/OpenTelemetryMetricTestToAmw.java Outdated Show resolved Hide resolved
…ove branch in build-common.yml.
// 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is sorting needed? looks like same verification is performed for all 3
// 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(there's only 1)
// 1st pre-aggregated metric |
List<Metric> otlpMetrics = | ||
testing.mockedOtlpIngestion.extractMetricsFromRequests(otlpRequests); | ||
| ||
assertThat(otlpMetrics).hasSizeGreaterThanOrEqualTo(3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it may be worth adding assertions about the name and attributes of these 3 metrics
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.