Skip to content

Send Fly-Client-Agent header with metrics requests#4994

Closed
clouvet wants to merge 4 commits into
masterfrom
metrics-client-agent-header
Closed

Send Fly-Client-Agent header with metrics requests#4994
clouvet wants to merge 4 commits into
masterfrom
metrics-client-agent-header

Conversation

@clouvet

@clouvet clouvet commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds Fly-Client-Agent header to metrics POST requests sent to flyctl-metrics
  • Uses clientsignals.DetectOnce() which is already a dependency — detection is cached and cheap
  • Works in both interactive (forked subprocess inherits env vars) and non-interactive paths
  • No feature flag gating — this is internal metrics, we control both sides

Companion PR

  • superfly/flyctl-metrics#67 — reads the header and adds it as a client_agent Prometheus label

Test plan

  • go build ./internal/metrics/... passes
  • Verify header appears in metrics POST requests when running under an agent environment
  • Verify no header sent for normal human CLI usage

🤖 Generated with Claude Code

Sprite and others added 4 commits July 9, 2026 16:46
When determineRegion fails in non-interactive mode, buildManifest
returned nil, causing the deferred metrics event to have empty
org/app/region/flyctl-version fields. Now buildManifest returns a
partial manifest with the org/app info that was already determined,
and run() populates the metrics status from it before returning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Daniel Graña <dangra@gmail.com>
Uses client-signals DetectOnce() to include the agent name header
on metrics POST requests to flyctl-metrics. This enables the metrics
service to distinguish agent-driven vs human-driven CLI commands.

Works in both interactive (forked subprocess) and non-interactive
paths since env vars are inherited and DetectOnce() caches its result.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clouvet

clouvet commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by clean rebased PR

@clouvet clouvet closed this Jul 9, 2026
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