Skip to content

azurebackup: emit AzSubscriptionGuid telemetry tag from each tool#2734

Merged
shrja-ms merged 1 commit into
microsoft:mainfrom
shrja-ms:user/azurebackup-per-tool-subscription-tag
May 27, 2026
Merged

azurebackup: emit AzSubscriptionGuid telemetry tag from each tool#2734
shrja-ms merged 1 commit into
microsoft:mainfrom
shrja-ms:user/azurebackup-per-tool-subscription-tag

Conversation

@shrja-ms

Copy link
Copy Markdown
Contributor

Summary

Per reviewer feedback on #2725, set the AzSubscriptionGuid Activity telemetry tag directly in each AzureBackup tool alongside existing OperationScope/VaultType tags, instead of relying on a central emission path in McpRuntime/NamespaceToolLoader. This restores per-subscription telemetry for AzureBackup tools in both namespace and standard server modes.

Changes

  • Add SubscriptionGuid constant + AddSubscriptionTag helper to AzureBackupTelemetryTags.
    • The literal "AzSubscriptionGuid" is duplicated here because the canonical constant in Microsoft.Mcp.Core (AzureTagName.SubscriptionGuid) is internal and not visible to the AzureBackup tool assembly. A code comment notes this.
  • Insert AzureBackupTelemetryTags.AddSubscriptionTag(context.Activity, options.Subscription); near the top of ExecuteAsync in 18 AzureBackup command classes, immediately before the existing AddVaultTags / scope-tagging calls.
  • Add 5 unit tests in AzureBackupTelemetryTagsTests covering:
    • Constant value matches the global AzSubscriptionGuid tag name.
    • AddSubscriptionTag is a safe no-op when Activity is null.
    • AddSubscriptionTag emits no tag when subscription is null.
    • AddSubscriptionTag emits the tag for GUID, name, and empty-string inputs (theory).

Validation

  • dotnet build tools/Azure.Mcp.Tools.AzureBackup/src — 0 warnings, 0 errors.
  • dotnet test tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.UnitTests --filter "FullyQualifiedName~AzureBackupTelemetryTagsTests" — 23 passed, 0 failed.

Files changed

  • tools/Azure.Mcp.Tools.AzureBackup/src/Models/AzureBackupTelemetryTags.cs
  • 18 command files under tools/Azure.Mcp.Tools.AzureBackup/src/Commands/**
  • tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.UnitTests/Models/AzureBackupTelemetryTagsTests.cs
  • servers/Azure.Mcp.Server/changelog-entries/1779814991354.yaml

Invoking Livetests

Copilot submitted PRs are not trustworthy by default. Users with write access to the repo need to validate the contents of this PR before leaving a comment with the text /azp run mcp - pullrequest - live. This will trigger the necessary livetest workflows to complete required validation.

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.

Pull request overview

This PR restores per-subscription telemetry for AzureBackup tools by emitting the AzSubscriptionGuid activity tag directly from each AzureBackup command, rather than relying on runtime/tool-loader paths that may not see nested parameters in namespace server mode.

Changes:

  • Added AzureBackupTelemetryTags.SubscriptionGuid constant and AddSubscriptionTag(Activity?, string?) helper.
  • Updated 18 AzureBackup commands to call AddSubscriptionTag(context.Activity, options.Subscription) near the start of ExecuteAsync.
  • Added unit tests for the new telemetry constant/helper and a server changelog entry.

Reviewed changes

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

Show a summary per file
File Description
tools/Azure.Mcp.Tools.AzureBackup/src/Models/AzureBackupTelemetryTags.cs Adds AzSubscriptionGuid constant and helper to emit the subscription telemetry tag.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Backup/BackupStatusCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/DisasterRecovery/DisasterRecoveryEnableCrrCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Governance/GovernanceFindUnprotectedCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Governance/GovernanceImmutabilityCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Governance/GovernanceSoftDeleteCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Job/JobGetCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Policy/PolicyCreateCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Policy/PolicyGetCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Policy/PolicyUpdateCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/ProtectableItem/ProtectableItemListCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/ProtectedItem/ProtectedItemGetCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/ProtectedItem/ProtectedItemProtectCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/ProtectedItem/ProtectedItemUndeleteCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/RecoveryPoint/RecoveryPointGetCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Security/SecurityConfigureMuaCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Vault/VaultCreateCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Vault/VaultGetCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/src/Commands/Vault/VaultUpdateCommand.cs Emits subscription tag at command start for consistent telemetry.
tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.UnitTests/Models/AzureBackupTelemetryTagsTests.cs Adds tests covering the constant and AddSubscriptionTag behavior.
servers/Azure.Mcp.Server/changelog-entries/1779814991354.yaml Records the telemetry behavior change in the server changelog pipeline.

Per reviewer feedback on microsoft#2725, set the subscription tag directly in each
AzureBackup tool alongside existing OperationScope/VaultType tags, instead
of relying on the central McpRuntime/NamespaceToolLoader emission path.
This restores per-subscription telemetry for AzureBackup tools in both
namespace and standard server modes.

- Add SubscriptionGuid constant + AddSubscriptionTag helper to
  AzureBackupTelemetryTags (duplicates internal AzureTagName.SubscriptionGuid
  literal so it can be referenced from the tool assembly).
- Insert AddSubscriptionTag call in 18 AzureBackup command ExecuteAsync
  methods.
- Add 5 unit tests covering tag emission and no-op scenarios.
@shrja-ms shrja-ms force-pushed the user/azurebackup-per-tool-subscription-tag branch from d10b25e to d93f04a Compare May 27, 2026 02:11
@shrja-ms shrja-ms enabled auto-merge (squash) May 27, 2026 02:16
@shrja-ms shrja-ms merged commit 4a77c6d into microsoft:main May 27, 2026
15 checks passed
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in Azure MCP Server May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants