-
Notifications
You must be signed in to change notification settings - Fork 267
tracing: capture full extension command path using metadata capability #6528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3ef548a to
fdbbb66
Compare
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
There was a problem hiding this 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 enhances telemetry for extension commands by leveraging the metadata capability introduced in a previous PR (#6496). It enables capturing the full command path and flags for extension invocations, significantly improving observability. Previously, telemetry only captured the extension namespace, making it impossible to distinguish which specific subcommand was executed.
Changes:
- Introduces command resolver functions that parse extension metadata to extract command paths and flags from raw arguments
- Updates telemetry middleware to resolve and emit full extension command paths and flags when metadata capability is available
- Ensures the auto-generated
--helpflag is included in extension metadata for accurate flag tracking
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
cli/azd/pkg/extensions/command_resolver.go |
New file implementing command path and flag resolution logic using extension metadata |
cli/azd/pkg/extensions/metadata_test.go |
Comprehensive tests for the new resolver functions covering edge cases like aliases, subcommands, and combined flags |
cli/azd/cmd/middleware/telemetry.go |
Integrates command resolver into telemetry middleware to capture full extension command paths and flags |
cli/azd/cmd/middleware/telemetry_test.go |
Updates test calls to pass nil extensionManager parameter |
cli/azd/pkg/azdext/metadata_generator.go |
Adds call to InitDefaultHelpFlag() to ensure Cobra's help flag is included in generated metadata |
cli/azd/pkg/azdext/metadata_generator_test.go |
Updates test expectations to account for the auto-generated help flag |
cli/azd/extensions/microsoft.azd.demo/internal/cmd/colors.go |
Adds "colours" alias to demonstrate alias resolution functionality |
cli/azd/extensions/microsoft.azd.demo/cspell.yaml |
Adds "colours" to spelling dictionary |
cli/azd/.vscode/cspell.yaml |
Adds "intarray" and "stringarray" to spelling dictionary |
Resolves #6097
This PR improves tracing for extension commands by leveraging the metadata capability to capture the full command path and flags. Previously, extension telemetry only captured the extension namespace making it impossible to distinguish which specific subcommand was invoked.
Approach
Extensions that declare the
metadatacapability inextension.yamlexpose their command tree structure. This PR uses that metadata to:agent init→cmd.ai.agent.init)-m→["manifest"])Tracing Comparison
Example:
azd ai agent init --manifest foo.yaml -e myenvname(event)ext.runext.runext.runcmd.entrycmd.ai.agentcmd.ai.agentcmd.ai.agent.initcmd.flags[][]["environment", "manifest"]cmd.args.count3(inaccurate)00Example:
azd demo colours -h(using alias)name(event)ext.runext.runext.runcmd.entrycmd.democmd.democmd.demo.colorscmd.flags[][]["help"]cmd.args.count2(inaccurate)00Key Changes
cmd/middleware/telemetry.go: Updated to resolve extension command info using metadata capabilitypkg/extensions/command_resolver.go: New file withResolveCommandPathandResolveCommandFlagsfunctionspkg/azdext/metadata_generator.go: Include Cobra's auto-generated--helpflag in metadatacmd.args.count: Emit0for extension commands sinceDisableFlagParsingmeans args contain raw unparsed values