Skip to content

Conversation

@JacksonWeber
Copy link
Contributor

This pull request introduces support for configuring an OTLP metric reader in the AKSLoader class based on environment variables, allowing metrics to be exported to a custom endpoint. It also updates dependencies and applies minor type assertion changes, with comprehensive unit tests added to verify the new metric reader logic.

AKSLoader metric reader enhancements:

  • Added logic to AKSLoader to create and attach an OTLP metric reader when OTEL_METRICS_EXPORTER is set to "otlp" and an OTLP endpoint is provided via environment variables. The metric reader is added to the loader's options for use by downstream telemetry components. [1] [2]

Unit tests for metric reader configuration:

  • Added multiple unit tests to aksLoader.tests.ts to verify that the OTLP metric reader is correctly created and configured based on environment variables, including cases for both general and metrics-specific endpoints, as well as negative cases where the metric reader should not be created.

Dependency updates:

  • Updated @azure/monitor-opentelemetry from version ^1.12.0 to ^1.13.1 and relaxed the version constraint for @opentelemetry/sdk-logs to allow compatible updates. [1] [2]

Type assertion fixes:

  • Applied as any type assertions when pushing log record processors to address type compatibility in both main.ts and telemetryClient.ts. [1] [2]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request adds OTLP metrics export functionality to the AKS Auto-Attach scenarios by enabling the AKSLoader class to create and configure an OTLP metric reader based on environment variables. The changes allow metrics to be exported to custom OTLP endpoints alongside existing Azure Monitor telemetry.

  • Added logic to create OTLP metric readers when OTEL_METRICS_EXPORTER=otlp and OTLP endpoints are configured
  • Updated package dependencies for Azure Monitor OpenTelemetry
  • Applied type assertion fixes for log record processors

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/agent/aksLoader.ts Added OTLP metric reader creation logic with environment variable detection
test/unitTests/agent/aksLoader.tests.ts Added comprehensive unit tests for OTLP metric reader configuration scenarios
src/main.ts Applied type assertion fix for OTLP log processor
src/shim/telemetryClient.ts Applied type assertion fix for attribute log processor
package.json Updated Azure Monitor OpenTelemetry dependency and relaxed SDK logs version constraint

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

exportIntervalMillis: OTLP_METRIC_EXPORTER_EXPORT_INTERVAL,
});

metricReaders.push(otlpMetricReader);
Copy link
Member

Choose a reason for hiding this comment

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

Should we have views in place here? how do you manage the fact that certain metrics should end in Azure Monitor Exporter and some others in OTLP exporter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be managed by: Azure/azure-sdk-for-js#32793

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re: our conversation on this today, the reason the OTELRESOURCE metric is never sent to AMW is that it's not an OTel metric at all. We create it manually in the exporter explicitly as a breeze metric: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/monitor/monitor-opentelemetry-exporter/src/utils/common.ts/#L242

@JacksonWeber JacksonWeber merged commit e8a13e5 into microsoft:main Sep 11, 2025
16 checks passed
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.

2 participants