Skip to content

Conversation

harsimar
Copy link
Member

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.

@trask trask force-pushed the harskaur/aksMetrics branch from 732a57f to 0f009a6 Compare September 20, 2025 00:48
@trask trask changed the base branch from main to trask/update-to-azure-sdk-latest September 20, 2025 01:03
Comment on lines 428 to 432
if (useOtlpViaEnvVars) {
envVars.put("OTEL_METRICS_EXPORTER", "otlp,azure_monitor");
envVars.put("OTEL_EXPORTER_OTLP_METRICS_ENDPOINT", FAKE_OTLP_INGESTION_ENDPOINT);
envVars.put("OTEL_EXPORTER_OTLP_PROTOCOL", "http/protobuf");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems duplicative, I think we can simplify and just change useOtlpEndpoint to use the env vars (there's no specific need for us to test it also with system properties)

private final List<String> jvmArgs = new ArrayList<>();
private boolean useDefaultHttpPort;
private boolean useOtlpEndpoint;
private boolean useOtlpViaEnvVars;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we can revert changes to this file

@trask trask force-pushed the harskaur/aksMetrics branch from 1e05ccc to 9aec7b3 Compare September 20, 2025 01:09
MetricData metricData = metricDataCollection.iterator().next();
MetricDataMapper.updateMetricPointBuilder(
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true);
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true, null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better to pass false explicitly (and ideally change the function from Boolean to boolean)

Suggested change
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true, null);
builder, metricData, metricData.getData().getPoints().iterator().next(), true, true, false);

Copy link
Member

@xiang17 xiang17 Sep 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set it to Boolean in case anyone would want to skip the _MS.SentToAMW flag. It would have different values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to clarify in the spec if we can skip sending this flag. That would be better whenever false to save ingestion costs. And then we wouldn't need tri-state here.

assertThat(properties3).containsEntry("_MS.SentToAMW", "True");
}

private void validateOtlpMetricsReceived(String name) throws Exception {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't look like name is used in this function

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you confirm if it's correct to remove it, or if some validation on name should be added instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants