Skip to content

Make telemetry default configurable through go.env - #2566

Merged
George Adams (gdams) merged 8 commits into
microsoft/mainfrom
dev/gdams/telemetry-goenv
Oct 12, 2026
Merged

George Adams (gdams) merged 8 commits into
microsoft/mainfrom
dev/gdams/telemetry-goenv

Conversation

@gdams

Copy link
Copy Markdown
Member

Summary

  • define MS_GOTOOLCHAIN_TELEMETRY_ENABLED=1 in the installation-wide GOROOT/go.env
  • resolve the setting through cmd/go/internal/cfg so process environment and user GOENV values override the installation default
  • expose the setting through go env and document it in go help environment
  • document installation, user, and process-level configuration precedence
  • verify that user configuration overrides and can restore the installation default

Rationale

Microsoft Go telemetry remains enabled by default. Azure Linux disables it because its general-purpose images run third-party workloads, and currently carries a downstream code-and-test patch to make telemetry opt-in:

https://github.com/microsoft/azurelinux/blob/4.0/specs/g/golang/0007-Disable-msft-go-telemetry-by-default.patch

Using Go's existing installation configuration lets Azure Linux express that policy by changing one line in GOROOT/go.env:

MS_GOTOOLCHAIN_TELEMETRY_ENABLED=0

Selected 1P image builds can restore the value to 1 during image construction without rebuilding Go. Explicit process environment and per-user GOENV settings retain higher precedence, so users and workloads can still override the image default.

Resolving the value in cmd/go and passing a boolean to the shared telemetry counter package avoids introducing a dependency from cmd/internal/telemetry to cmd/go/internal/cfg.

Validation

  • go test cmd/go -run '^TestScript$/^env_write$' -count=1
  • go test cmd/internal/telemetry/counter -count=1
  • go test -tags=cmd_go_bootstrap cmd/internal/telemetry/counter -count=1
  • git go-patch extract successfully reapplied the full patch stack in its temporary validation clone

George Adams (gdams) and others added 2 commits October 12, 2026 13:33
Resolve the Microsoft telemetry setting through Go's standard configuration hierarchy so distributions can change the installation default without patching telemetry code. Keep Microsoft builds default-on while allowing Azure Linux to set the GOROOT go.env default to off and enable it in selected 1P images.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@gdams
George Adams (gdams) requested a review from a team as a code owner October 12, 2026 12:34
Copilot AI balanced review requested due to automatic review settings October 12, 2026 12:34
@azure-pipelines

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

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

The test harness inherits CI’s telemetry opt-out and the new test hard-codes a downstream-configurable default.

2 open findings
What changed in this PR

Makes Microsoft Go telemetry configurable through standard go.env precedence.

Changes:

  • Adds the installation-wide telemetry default and go env integration.
  • Documents configuration precedence.
  • Adds override/restoration tests.

Patch consistency: Patches are happy!

File Description
patches/​0007-Add-appinsights-telemetry.patch Adds configuration, command integration, documentation, and tests.
eng/​doc/​Telemetry.md Documents telemetry configuration and precedence.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread patches/0007-Add-appinsights-telemetry.patch Outdated
Comment thread patches/0007-Add-appinsights-telemetry.patch Outdated
George Adams (gdams) and others added 2 commits October 12, 2026 14:13
Keep script telemetry enabled for the fake endpoint even when CI opts out globally, and make the go env test independent of the installation default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Point users from the installed go.env default to the detailed telemetry documentation.

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

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.

🟢 Approval recommended

The implementation matches the intended precedence, with only non-blocking ordering cleanup noted.

1 open finding
2 resolved since last review

🧠 Review effort: Balanced

Comment thread patches/0007-Add-appinsights-telemetry.patch Outdated
Place the telemetry setting before MS_GO_NOSYSTEMCRYPTO in environment and help lists.

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

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.

🟢 Approval recommended

The implementation consistently uses Go’s existing environment configuration mechanism and covers the intended override behavior.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

Comment thread patches/0007-Add-appinsights-telemetry.patch Outdated
Comment thread eng/doc/Telemetry.md Outdated
Comment thread eng/doc/Telemetry.md Outdated
Use the Microsoft build of Go product name consistently, preserve the documentation's newline style, and explain the enabled and disabled values at the start of the opt-out section.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread patches/0007-Add-appinsights-telemetry.patch
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread eng/doc/Telemetry.md Outdated
Comment thread eng/doc/Telemetry.md Outdated
Comment thread eng/doc/Telemetry.md Outdated
Use platform-neutral process override guidance, clarify the Microsoft-specific scope, and format the enabled and disabled behavior as separate sentences.

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

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.

🟢 Approval recommended

The implementation consistently uses Go’s existing environment-resolution mechanism and includes focused validation.

0 open findings

🧠 Review effort: Balanced

@gdams
George Adams (gdams) merged commit cce8cff into microsoft/main Oct 12, 2026
60 checks passed
@gdams
George Adams (gdams) deleted the dev/gdams/telemetry-goenv branch October 12, 2026 20:23
@gdams

Copy link
Copy Markdown
Member Author

Copilot backport these changes to the 1.27 and 1.26 release branches.

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.

3 participants