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 <[email protected]>
@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.

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 <[email protected]>
Point users from the installed go.env default to the detailed telemetry documentation.

Co-authored-by: Copilot <[email protected]>

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

Place the telemetry setting before MS_GO_NOSYSTEMCRYPTO in environment and help lists.

Co-authored-by: Copilot <[email protected]>

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 eng/doc/Telemetry.md Resolved
Comment thread eng/doc/Telemetry.md Resolved
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 <[email protected]>
Comment thread eng/doc/Telemetry.md Resolved
Comment thread eng/doc/Telemetry.md Resolved
Comment thread eng/doc/Telemetry.md Resolved
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 <[email protected]>

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.

George Adams (gdams) added a commit that referenced this pull request Oct 14, 2026
George Adams (gdams) added a commit that referenced this pull request Oct 14, 2026
…o.env (#2570)

Backport #2566. The standalone telemetry guide does not exist on this release branch, so this backport contains only the Go patch update.

Co-authored-by: Copilot <[email protected]>
Régis Desgroppes (rdesgroppes) added a commit to DataDog/datadog-agent that referenced this pull request Nov 6, 2026
### What does this PR do?
Patch the `msgo` SDK's `go.env` so that
`MS_GOTOOLCHAIN_TELEMETRY_ENABLED` defaults to `0`, as microsoft/go#2566
lets distributions do and microsoft/azurelinux#19611 does.

Users can still opt in through their environment or `go env -w`, which
both take precedence over `GOROOT/go.env`.

### Motivation
#58511 made `msgo` a Bazel SDK whose `go.env` enables Microsoft's
telemetry, which its `go build`, `go install` and `go run` send unless
`MS_GOTOOLCHAIN_TELEMETRY_ENABLED=0` is set.

#58530 builds FIPS binaries with `bazel run //:msgo -- build`, only
opted out by the `ENV` that `DataDog/datadog-agent-buildimages` sets in
its images, leaving other hosts, developer ones included, sending it.

Opting out in the SDK itself covers every host and lets the build images
drop that `ENV`.

### Describe how you validated your changes
With `MS_GOTOOLCHAIN_TELEMETRY_ENABLED` unset, checked on Linux and
Windows that `bazel run //:msgo -- env MS_GOTOOLCHAIN_TELEMETRY_ENABLED`
prints `0`, whereas it prints `1` on Linux without the patch.

With `MS_GOTOOLCHAIN_TELEMETRY_ENABLED=1` on Linux, checked that it
prints `1`.

Checked that `MODULE.bazel.lock` is unchanged and that
`bazel run //bazel/buildifier:test` passes.

### Additional Notes
Unlike `--run_env=MS_GOTOOLCHAIN_TELEMETRY_ENABLED=0`, the patch keeps
the user opt-in and covers every `go` command run from `@msgo`, not only
`bazel run //:msgo`.

The patch fails the SDK fetch should a later `msgo` release reword its
`go.env`, rather than silently leaving telemetry on.
gh-worker-dd-mergequeue-cf854d Bot pushed a commit to DataDog/datadog-agent that referenced this pull request Nov 6, 2026
### What does this PR do?
Patch the `msgo` SDK's `go.env` so that `MS_GOTOOLCHAIN_TELEMETRY_ENABLED` defaults to `0`, as microsoft/go#2566 lets distributions do and microsoft/azurelinux#19611 indeed does.

Users can still opt in through their environment or `go env -w`, which both take precedence over `GOROOT/go.env`.

### Motivation
#58511 made `msgo` a Bazel SDK whose `go.env` enables Microsoft's telemetry, which its `go build`, `go install` and `go run` send unless `MS_GOTOOLCHAIN_TELEMETRY_ENABLED=0` is set.

#58530 builds FIPS binaries with `bazel run //:msgo -- build`, only opted out by the `ENV` that `DataDog/datadog-agent-buildimages` sets in its images, leaving other hosts, developer ones included, sending it.

Opting out in the SDK itself covers every host and lets the build images drop that `ENV`.

### Describe how you validated your changes
With `MS_GOTOOLCHAIN_TELEMETRY_ENABLED` unset, checked on Linux and Windows that `bazel run //:msgo -- env MS_GOTOOLCHAIN_TELEMETRY_ENABLED` prints `0`, whereas it prints `1` on Linux without the patch.

With `MS_GOTOOLCHAIN_TELEMETRY_ENABLED=1` on Linux, checked that it prints `1`.

### Additional Notes
Unlike `--run_env=MS_GOTOOLCHAIN_TELEMETRY_ENABLED=0`, the patch keeps the user opt-in and covers every `go` command run from `@msgo`, not only `bazel run //:msgo`.

The patch fails the SDK fetch should a later `msgo` release reword its `go.env`, rather than silently leaving telemetry on.

Co-authored-by: regis.desgroppes <[email protected]>
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