Skip to content

Improve telemetry device detection stability - #11071

Open
Victor Vazquez (vhvb1989) wants to merge 1 commit into
mainfrom
vhvb1989-machine-id-cache-investigation
Open

Victor Vazquez (vhvb1989) wants to merge 1 commit into
mainfrom
vhvb1989-machine-id-cache-investigation

Conversation

@vhvb1989

Copy link
Copy Markdown
Member

Summary

Improves telemetry device detection by reusing the persisted pseudonymous machine.id value across azd invocations.

  • Read the machine ID cache before calculating a new value.
  • Return the same value that is persisted.
  • Recalculate when the cache is empty.
  • Add focused tests for cache reuse, first write, and empty cache recovery.
  • Update telemetry docs to describe the cached identifier.

Telemetry change

What changed: machine.id continues to be a pseudonymous MAC-address hash or UUID fallback, but azd now reuses its cached value instead of recalculating it on each invocation.
Why it is needed: Improves the stability of device-level telemetry.
Approval coverage (maintainer): pending assessment

  • Values are limited to what is needed; custom and invalid inputs are handled.
  • Field/event declarations, classification, purpose, identifier metadata, hashing rules, and affected telemetry docs are updated.
  • Focused tests check emitted and excluded values, including hashes where relevant. Opt-out behavior is unchanged.
  • Known affected queries, tables, reports, or exports are listed, with an owner for follow-up or migration.
  • Code changes, metadata deployment, and downstream checks have separate statuses and owners.

Open questions or follow-ups: Confirm downstream reporting rollout with telemetry owners.

Validation

  • go test ./internal/tracing/resource -count=1
  • go vet ./internal/tracing/resource
  • go fix ./internal/tracing/resource

Reuse the cached pseudonymous machine identifier and return the same value that is persisted.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

azure-pipelines Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
26 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@vhvb1989
Victor Vazquez (vhvb1989) marked this pull request as ready for review December 2, 2026 22:01
@vhvb1989
Victor Vazquez (vhvb1989) requested a review from a team as a code owner December 2, 2026 22:01
Copilot AI max review requested due to automatic review settings December 2, 2026 22:01

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.

🟡 Changes recommended

Cached machine IDs are reused without validation, potentially exposing raw MAC addresses and retaining truncated identifiers across runs.

2 open issues
What changed in this PR

Stabilizes azd device telemetry by reusing the persisted pseudonymous machine.id across invocations.

Changes:

  • Reads cached IDs first and calculates once when needed.
  • Tests cache reuse, initial writes, and empty-cache recovery.
  • Documents cached hash and UUID identifiers.
File Description
docs/​specs/​metrics-audit/​telemetry-schema.md Clarifies cached identifier sources.
docs/​reference/​telemetry-data.md Describes cached IDs and UUID fallback.
cli/​azd/​internal/​tracing/​resource/​resource_test.go Adds cache behavior tests.
cli/​azd/​internal/​tracing/​resource/​machine_id.go Corrects cache reads and avoids duplicate calculation.

Review effort: Max

Comment on lines +70 to +71
if cached := strings.TrimSpace(string(bytes)); cached != "" {
return cached
Comment on lines +286 to +287
require.Equal(t, tt.wantValue, loadOrCalculate(calc, cacheFileName))
require.Equal(t, tt.wantValue, loadOrCalculate(calc, cacheFileName))

@hemarina hemarina 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's review comments are worth addressing. The machine.id field name and type remain unchanged, so no Kusto schema update should be needed. The value may change for some devices after upgrading. LGTM otherwise.

This branch has not been deployed

No deployments
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