Loading
fix(v2/events): send a go-prefixed module version as the tracker version
The Snowplow tracker in LabKit v2 now sends go-<module version> as the tracker version (tv), in place of the fixed 0.0.1.
This lets the Data team keep Go events with one tracker_version LIKE 'go%' rule, so events from LabKit v2 services reach the modelled Snowflake tables.
Closes #173 (closed)
What changes
tvisgo-plus the version ofgitlab.com/gitlab-org/labkit/v2in the binary, for examplego-v2.66.0. The value comes fromruntime/debug.ReadBuildInfo, read once per process.tvisgo-unknownwhen the binary has no build information, the module isn't a dependency, the version is empty, or the module is replaced with areplacedirective.- No public API changes.
Why the prefix is go- and not labkit-
- Snowplow tracker versions name the language, not the library, and the dbt allowlist follows that:
js%,rb%,py%,java%,rust%. GitLab Rails wraps the Ruby tracker and still sendsrb-.go-adds one more rule of the same kind. - A
labkit-prefix would need a new kind of allowlist rule and buy little precision. LabKit is already identifiable from the user agent (GitLab Analytics Golang Tracker), the service fromapp_id, and the version string is a LabKit release. go%also accepts any other Go Snowplow tracker, which matches how the allowlist treats the other languages.
Design notes
- The lookup is a pure function,
trackerVersionFromBuildInfo, so the tests cover each branch without patching a global. - A replaced module falls back because the version in
go.moddoesn't describe the code that runs. - LabKit's own test binaries always get
go-unknown, because LabKit is the main module there, not a dependency. - Pseudo-versions pass through unchanged, for example
go-v2.66.1-0.20261102082407-e0b7ace12345.
Related
Verification
go test ./events/snowplow/...passes inv2.golangci-lint run ./events/snowplow/...reports 0 issues.
Edited by Pawel Rozlach