Allow passing in custom tags to telemetry#1723
Merged
derekmisler merged 1 commit intodocker:mainfrom Feb 13, 2026
Merged
Conversation
Signed-off-by: Derek Misler <derek.misler@docker.com>
c18c0cb to
0a6fa86
Compare
There was a problem hiding this comment.
Code Review Summary
✅ No issues found in the changed code.
The implementation correctly:
- Parses comma-separated
key=valuepairs fromTELEMETRY_TAGSenvironment variable - Uses
strings.Cut()to split on the first=(correctly allowing=characters in values) - Validates that keys are non-empty after trimming whitespace
- Trims both keys and values of leading/trailing whitespace
- Handles edge cases: empty values, malformed pairs without
=, pairs with extra spaces - Protects system metadata (
user_uuid,version,os,os_language) by writing them AFTER tags, preventing spoofing
The test coverage is comprehensive and covers all the important edge cases including security concerns, whitespace handling, malformed input, and the critical system metadata protection test.
Great work on this feature!
rumpl
approved these changes
Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: https://github.com/docker/gordon/issues/121
Add support for a
TELEMETRY_TAGSenvironment variable that allows callers to attach custom key-value metadata to every telemetry event. This enables tracking where and how the binary is invoked (e.g., GitHub Actions, specific repos, workflows) without hardcoding provider-specific logic into the binary itself.Changes
pkg/telemetry/http.go: ParseTELEMETRY_TAGSenv var (comma-separatedkey=valuepairs) increateEvent()and merge them into event properties. System metadata (user_uuid,version,os,os_language) is written after tags to prevent spoofing. Empty keys and malformed entries (missing=) are silently ignored. Whitespace around keys and values is trimmed.pkg/telemetry/telemetry_test.go: Add two test suites:TestCreateEventTelemetryTags— unit tests callingcreateEvent()directly, covering: single/multiple tags, whitespace trimming, malformed input, empty values, values containing=, system metadata protection, and operator-priority behavior.TestTelemetryTags— integration tests usingMockHTTPClientto verify tags appear in the actual HTTP request payload, including security and edge-case scenarios.Test plan
go test ./pkg/telemetry/ -run TestCreateEventTelemetryTags -v— 9 subtestsgo test ./pkg/telemetry/ -run TestTelemetryTags -v— 5 subtestsgo test ./pkg/telemetry/— full suite passes with no regressions