Skip to content

Conversation

JacksonWeber
Copy link
Member

Packages impacted by this PR

@azure/monitor-opentelemetry-exporter

Describe the problem that is addressed by this PR

https://msazure.visualstudio.com/One/_git/CommonSchema/pullrequest/13225763?path=/v4.0/Mappings/AzureMonitor-AI.md

This pull request updates how OpenTelemetry end user identifiers are mapped to Application Insights tags, ensuring more accurate user tracking and improved compatibility with semantic conventions. The main changes involve introducing support for new experimental OpenTelemetry attributes, updating mapping logic, and enhancing test coverage.

End User Attribute Mapping:

  • Added support for ATTR_ENDUSER_ID and ATTR_ENDUSER_PSEUDO_ID in experimentalOpenTelemetryValues, and included them in httpSemanticValues for consistent attribute handling. [1] [2]
  • Updated createTagsFromSpan and createTagsFromLog to map ATTR_ENDUSER_ID to ai.user.authUserId and ATTR_ENDUSER_PSEUDO_ID to ai.user.id, replacing the previous usage of SEMATTRS_ENDUSER_ID. [1] [2]

Codebase Cleanup:

  • Removed imports and references to SEMATTRS_ENDUSER_ID throughout the codebase, switching to the new experimental attributes for user identification. [1] [2] [3]

Testing Improvements:

  • Added and updated unit tests to verify correct mapping of ATTR_ENDUSER_ID and ATTR_ENDUSER_PSEUDO_ID to Application Insights tags, and to ensure these attributes are not included in properties. [1] [2] [3] [4]

Are there test cases added in this PR? (If not, why?)

Yes

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 Copilot AI review requested due to automatic review settings August 27, 2025 22:39
Copy link
Contributor

@Copilot 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 updates OpenTelemetry end user attribute mapping to align with new experimental semantic conventions, replacing the deprecated SEMATTRS_ENDUSER_ID with two distinct attributes for better user tracking in Application Insights.

  • Updates user identification mapping to use ATTR_ENDUSER_ID (mapped to ai.user.authUserId) and ATTR_ENDUSER_PSEUDO_ID (mapped to ai.user.id)
  • Removes deprecated SEMATTRS_ENDUSER_ID imports and usage across the codebase
  • Adds comprehensive test coverage for the new attribute mappings

Reviewed Changes

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

Show a summary per file
File Description
src/types.ts Defines new experimental OpenTelemetry attributes and includes them in semantic values array
src/utils/spanUtils.ts Updates span tag creation logic to map new user attributes and removes deprecated import
src/utils/logUtils.ts Implements user attribute mapping for log records with proper tag assignment
test/internal/spanUtils.spec.ts Updates existing tests and adds new test for pseudo ID mapping verification
test/internal/logUtils.spec.ts Adds comprehensive tests for both user ID attributes in log processing

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

@JacksonWeber JacksonWeber merged commit a33d94d into Azure:main Sep 5, 2025
14 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.

3 participants