Skip to content

feat(telemetry): send the build environment to the telemetry proxy#241

Merged
LorrisSaintGenez merged 1 commit into
feat/create-planchange-flow-eventsfrom
feat/telemetry-env-header
Jun 10, 2026
Merged

feat(telemetry): send the build environment to the telemetry proxy#241
LorrisSaintGenez merged 1 commit into
feat/create-planchange-flow-eventsfrom
feat/telemetry-env-header

Conversation

@LorrisSaintGenez

@LorrisSaintGenez LorrisSaintGenez commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

What

  • Every telemetry request now carries an X-Algolia-CLI-Env header: prod for release builds (goreleaser injects a semver version.Version), dev for source builds (version.Version stays "main"). Deriving the environment from the build-time version (instead of an env var) makes it impossible to spoof or misconfigure at runtime: the split exactly mirrors "official release binary vs source build".
  • No behavior change today: the proxy ignores the header until it routes on it, so everything keeps going to the "CLI (DEV)" source. Shipping the header now means already-released CLIs will switch over instantly the day the proxy routes.
  • The transport clones the request before adding the header (RoundTrippers must not mutate the caller's request — unit-tested).
  • Fixes the doubled slash in the telemetry URL (telemetry-proxy.algolia.com//v1/batch): the endpoint had a trailing slash and analytics-go appends /v1/batch.

Remaining, outside this repo: create the "CLI (PROD)" source in Segment, and have the telemetry-proxy team route on the header (absent header → DEV, as today).

Test

The header isn't visible in DEBUG logs (the library doesn't log request headers); it is covered by unit tests. Manual check = no regression:

# events still flow, and the batch URL no longer has a double slash
DEBUG=1 go run ./cmd/algolia application plans

GROUT-349

- every telemetry request carries an X-Algolia-CLI-Env header (prod
  for release builds, where goreleaser injects a semver version; dev
  for source builds) so the proxy can route release events to the
  production Segment source; until the proxy routes on the header,
  everything keeps going to the development source
- the transport clones the request before adding the header
  (RoundTrippers must not mutate the caller's request)
- drop the trailing slash of the telemetry endpoint: analytics-go
  appends /v1/batch, which produced a double slash in the URL

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LorrisSaintGenez LorrisSaintGenez self-assigned this Jun 10, 2026
@LorrisSaintGenez LorrisSaintGenez marked this pull request as ready for review June 10, 2026 22:58
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 9 complexity · 0 duplication

Metric Results
Complexity 9
Duplication 0

View in Codacy

TIP This summary will be updated as you push new changes.

@LorrisSaintGenez LorrisSaintGenez merged commit 9ba4053 into feat/create-planchange-flow-events Jun 10, 2026
2 checks passed
@LorrisSaintGenez LorrisSaintGenez deleted the feat/telemetry-env-header branch June 10, 2026 23:49
LorrisSaintGenez added a commit that referenced this pull request Jun 11, 2026
)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant