Skip to content

feat: support extension-defined hook names in telemetry logging #7348

@jongio

Description

@jongio

Problem

When logging hook names in telemetry (hooks.name attribute), we currently validate against a static list of 16 known built-in azd hook names (prebuild, postbuild, predeploy, etc.). Unknown hook names are SHA-256 hashed to prevent logging arbitrary user input as customer content.

However, extensions can define custom hook names via:

  • azure.yaml project/service hook configurations
  • Runtime event handlers registered through azdext.ExtensionHost.WithProjectEventHandler() / WithServiceEventHandler()

These extension-defined hooks are legitimate hook names that would be useful to see in telemetry in plain text, but they currently get hashed because they're not in the built-in known-names list.

Current Behavior

  • Built-in hook names (prebuild, postdeploy, etc.) → logged raw ✅
  • Extension-defined hook names from azure.yamlhashed (not ideal)
  • Arbitrary user input (azd hooks run asdf) → hashed

Desired Behavior

Extension-defined hook names should also be logged in plain text when they can be validated as legitimate (i.e., defined in project config or registered by an extension).

Options to Investigate

  1. Validate against project config at telemetry time — Check projectConfig.Hooks and all service.Hooks maps. If the hook name exists there, log raw; otherwise hash. This covers extension hooks defined in azure.yaml but not runtime-only handlers.

  2. Extension hook name registry — Provide an API for extensions to register their custom hook names, making them available for telemetry validation.

  3. Accept hashing for extension hooks — If extension hook telemetry isn't critical, the current approach (hash unknown names) may be acceptable.

Context

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions