Skip to content

Conversation

@JacksonWeber
Copy link
Member

Packages impacted by this PR

@azure/monitor-opentelemetry

Issues associated with this PR

#33012 (comment)

Describe the problem that is addressed by this PR

This pull request introduces support for configuring custom metric views in the Azure Monitor OpenTelemetry SDK. Users can now specify additional metric views via the views property in AzureMonitorOpenTelemetryOptions, which will be registered with the NodeSDK's meter provider. The change is documented in the README and changelog, and is covered by new unit tests to ensure correct behavior.

Custom metric views support:

  • Added a views property (array of ViewOptions) to the AzureMonitorOpenTelemetryOptions interface in src/types.ts and updated all relevant type imports. [1] [2] [3] [4]
  • Updated the SDK initialization in src/index.ts to merge user-provided views with default views and pass them to the NodeSDK configuration. [1] [2]
  • Documented the new views option in the README usage example and options table. [1] [2]
  • Added a changelog entry for version 1.15.0 describing the new feature.

Testing and validation:

  • Added a unit test to verify that custom metric views are correctly registered with the meter provider. [1] [2]
  • Updated snippet tests to include the views option in sample usage.

Test suite improvements:

  • Improved instrumentation lifecycle management in trace handler tests by tracking and disabling instrumentations after each test, ensuring test isolation and reliability. [1] [2] [3] [4] [5]

Checklists

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator?** (If so, create an Issue in the Autorest/typescript repository and link it here)
  • Added a changelog (if necessary)

Copilot AI review requested due to automatic review settings November 19, 2025 06:20
Copilot finished reviewing on behalf of JacksonWeber November 19, 2025 06:22
@github-actions
Copy link

github-actions bot commented Nov 19, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

@azure/monitor-opentelemetry

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 PR adds support for configuring custom metric views in the Azure Monitor OpenTelemetry SDK through a new views property in AzureMonitorOpenTelemetryOptions. Users can now provide custom view configurations that will be merged with default views and passed to the OpenTelemetry NodeSDK's meter provider.

Key changes:

  • Added views property to AzureMonitorOpenTelemetryOptions for custom metric view configuration
  • Custom views are merged with default views from MetricHandler before SDK initialization
  • Improved test isolation in trace handler tests by tracking and properly managing instrumentation lifecycle

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sdk/monitor/monitor-opentelemetry/src/types.ts Added ViewOptions[] import and views property to AzureMonitorOpenTelemetryOptions interface
sdk/monitor/monitor-opentelemetry/src/index.ts Implemented merging of custom views with default views and passed them to NodeSDK configuration
sdk/monitor/monitor-opentelemetry/test/internal/unit/main.test.ts Added unit test to verify custom metric views are registered with the meter provider
sdk/monitor/monitor-opentelemetry/test/snippets.spec.ts Updated snippet test to include empty views array in sample configuration
sdk/monitor/monitor-opentelemetry/test/internal/unit/traces/traceHandler.test.ts Improved test reliability by properly managing instrumentation lifecycle (enable/disable/setTracerProvider)
sdk/monitor/monitor-opentelemetry/review/monitor-opentelemetry-node.api.md Added ViewOptions import and views property to API surface
sdk/monitor/monitor-opentelemetry/README.md Documented the new views option in usage examples and configuration table
sdk/monitor/monitor-opentelemetry/CHANGELOG.md Added changelog entry for version 1.15.0 describing the new feature

azureMonitorExporterOptions: {
connectionString: "InstrumentationKey=00000000-0000-0000-0000-000000000000",
},
views: [customView],
Copy link
Member

@rads-1996 rads-1996 Nov 21, 2025

Choose a reason for hiding this comment

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

It is possible to have multiple custom views right? In that case, does config have the ability to process them as a list of views?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we just pass this to the NodeSDKConfiguration in OpenTelemetry which takes a ViewOptions array.

<td></td>
</tr>
<tr>
<td><code>views</code></td>
Copy link
Member

Choose a reason for hiding this comment

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

Does the documentation for the configure opentelemetry needs to be updated for this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it will need to be, but waiting on PR review & API review.

Copy link
Member

@rads-1996 rads-1996 left a comment

Choose a reason for hiding this comment

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

LGTM

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