Skip to content

Fix #3223: WEB activity processors write tag keys the Azure Monitor exporter maps - #3224

Merged
Rajkumar Rangaraj (rajkumar-rangaraj) merged 5 commits into
mainfrom
rajrang/fixWebProcessorTagKeys
Oct 8, 2026
Merged

Rajkumar Rangaraj (rajkumar-rangaraj) merged 5 commits into
mainfrom
rajrang/fixWebProcessorTagKeys

Conversation

@rajkumar-rangaraj

Copy link
Copy Markdown
Member

Fix Issue #3223.

Changes

Five of the WEB package's activity processors wrote tag keys that Azure.Monitor.OpenTelemetry.Exporter doesn't map. The exporter exported those values as custom properties, so user_Id, session_Id, operation_SyntheticSource and user_AccountId stayed empty after upgrading from 2.x.

Processor Before After
UserActivityProcessor ai.user.id enduser.pseudo.id
SessionActivityProcessor session.id (+ session.isFirst) microsoft.session.id
SyntheticUserAgentActivityProcessor ai.operation.syntheticSource microsoft.synthetic_source
WebTestActivityProcessor ai.operation.syntheticSource, ai.user.id, session.id microsoft.synthetic_source, enduser.pseudo.id, microsoft.session.id
AccountIdActivityProcessor enduser.account microsoft.user.account_id
  • The processors now use the existing internal SemanticConventions constants, which TelemetryContextActivityProcessor already uses, in both the SetTag calls and the "already set" guards. WebTestActivityProcessor is registered before SyntheticUserAgentActivityProcessor, so with the shared key an availability test's source still takes precedence over the bot check.
  • AccountIdActivityProcessor checked enduser.id as its "already set" guard. AuthenticatedUserIdActivityProcessor runs just before it and sets enduser.id from the same ai_authUser cookie, so the account ID was always skipped when that cookie was present. The guard now checks the account key.
  • SessionActivityProcessor no longer emits session.isFirst. The exporter doesn't map it, so it only showed up as a stray custom dimension.

Tests

  • Updated the processor unit tests to assert on the new keys.
  • Added AccountIdActivityProcessorTests regression tests: the account ID is set when enduser.id is already present, and an existing account ID is not overwritten.
  • Added ActivityProcessorExportTests. It runs the processors, in production registration order, through AddAzureMonitorTraceExporter with a capturing HttpPipelineTransport, then asserts on the exported envelope's context tags and that none of the keys appear in customDimensions. It also covers availability-test precedence over the bot user agent and cookies. Against the old processor code these tests fail. With this fix, all 131 Web tests pass locally (net462).

Checklist

  • I ran Unit Tests locally.
  • CHANGELOG.md updated with one line description of the fix, and a link to the original issue if available.

For significant contributions please make sure you have completed the following items:

  • Design discussion issue #
  • Changes in public surface reviewed (no public API changes)

UserActivityProcessor, SessionActivityProcessor, SyntheticUserAgentActivityProcessor,
WebTestActivityProcessor and AccountIdActivityProcessor wrote tag keys that
Azure.Monitor.OpenTelemetry.Exporter does not map, so the values were exported as
custom properties and user_Id, session_Id, operation_SyntheticSource and
user_AccountId stayed empty.

- Use SemanticConventions.AttributeEnduserPseudoId, AttributeMicrosoftSessionId,
  AttributeMicrosoftSyntheticSource and AttributeMicrosoftUserAccountId for both
  the SetTag calls and the already-set guards.
- AccountIdActivityProcessor now guards on the account key instead of enduser.id,
  which AuthenticatedUserIdActivityProcessor had already set from the same cookie.
- Stop emitting the unmapped session.isFirst tag.
- Add tests that run the processors through the Azure Monitor exporter and assert
  on the exported envelope.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 21:11
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The mapped keys, processor precedence, account regression, and exported envelopes are covered consistently without unresolved issues.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes WEB activity processors so user, session, synthetic-source, and account context values map correctly through the Azure Monitor exporter.

Changes:

  • Replaces unmapped tag keys with shared SemanticConventions keys.
  • Corrects account-ID guarding and removes the unmapped session.isFirst tag.
  • Updates unit tests and adds exporter-level regression coverage.
File Description
WEB/​Src/​Web/​Web/​WebTestActivityProcessor.cs Uses exporter-mapped web-test context keys.
WEB/​Src/​Web/​Web/​UserActivityProcessor.cs Uses the mapped anonymous-user key.
WEB/​Src/​Web/​Web/​SyntheticUserAgentActivityProcessor.cs Uses the mapped synthetic-source key.
WEB/​Src/​Web/​Web/​SessionActivityProcessor.cs Uses the mapped session key and removes session.isFirst.
WEB/​Src/​Web/​Web/​AccountIdActivityProcessor.cs Corrects the account guard and mapped key.
WEB/​Src/​Web/​Web.Tests/​WebTestActivityProcessorTests.cs Updates web-test key assertions.
WEB/​Src/​Web/​Web.Tests/​UserActivityProcessorTests.cs Updates anonymous-user assertions.
WEB/​Src/​Web/​Web.Tests/​SyntheticUserAgentActivityProcessorTests.cs Updates synthetic-source assertions.
WEB/​Src/​Web/​Web.Tests/​SessionActivityProcessorTests.cs Verifies mapped session output and removed tags.
WEB/​Src/​Web/​Web.Tests/​AccountIdActivityProcessorTests.cs Adds account guard regressions.
WEB/​Src/​Web/​Web.Tests/​ActivityProcessorExportTests.cs Adds end-to-end exporter mapping tests.
CHANGELOG.md Documents the corrected telemetry mappings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

This PR was marked stale due to lack of activity and will be closed in 7 days. Commenting or pushing will instruct the bot to automatically remove the label. This bot runs once per day.

@rajkumar-rangaraj
Rajkumar Rangaraj (rajkumar-rangaraj) merged commit aba5687 into main Oct 8, 2026
18 checks passed
@rajkumar-rangaraj
Rajkumar Rangaraj (rajkumar-rangaraj) deleted the rajrang/fixWebProcessorTagKeys branch October 8, 2026 23:21
Rajkumar Rangaraj (rajkumar-rangaraj) added a commit that referenced this pull request Oct 8, 2026
Resolves the CHANGELOG.md conflict by keeping both Unreleased entries (#3224 from main and #3225 from this branch) in ascending PR-number order.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Oct 27, 2026
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.

4 participants