azurebackup: emit AzSubscriptionGuid telemetry tag from each tool#2734
Merged
shrja-ms merged 1 commit intoMay 27, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.SubscriptionGuidconstant andAddSubscriptionTag(Activity?, string?)helper. - Updated 18 AzureBackup commands to call
AddSubscriptionTag(context.Activity, options.Subscription)near the start ofExecuteAsync. - 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. |
alzimmermsft
approved these changes
May 26, 2026
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.
d10b25e to
d93f04a
Compare
alzimmermsft
approved these changes
May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per reviewer feedback on #2725, set the
AzSubscriptionGuidActivity telemetry tag directly in each AzureBackup tool alongside existingOperationScope/VaultTypetags, instead of relying on a central emission path inMcpRuntime/NamespaceToolLoader. This restores per-subscription telemetry for AzureBackup tools in both namespace and standard server modes.Changes
SubscriptionGuidconstant +AddSubscriptionTaghelper toAzureBackupTelemetryTags."AzSubscriptionGuid"is duplicated here because the canonical constant inMicrosoft.Mcp.Core(AzureTagName.SubscriptionGuid) isinternaland not visible to the AzureBackup tool assembly. A code comment notes this.AzureBackupTelemetryTags.AddSubscriptionTag(context.Activity, options.Subscription);near the top ofExecuteAsyncin 18 AzureBackup command classes, immediately before the existingAddVaultTags/ scope-tagging calls.AzureBackupTelemetryTagsTestscovering:AzSubscriptionGuidtag name.AddSubscriptionTagis a safe no-op whenActivityisnull.AddSubscriptionTagemits no tag whensubscriptionisnull.AddSubscriptionTagemits 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.cstools/Azure.Mcp.Tools.AzureBackup/src/Commands/**tools/Azure.Mcp.Tools.AzureBackup/tests/Azure.Mcp.Tools.AzureBackup.UnitTests/Models/AzureBackupTelemetryTagsTests.csservers/Azure.Mcp.Server/changelog-entries/1779814991354.yamlInvoking Livetests
Copilot submitted PRs are not trustworthy by default. Users with
writeaccess 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.