Add operator/agent_name to deploy/launch metrics payloads#4995
Merged
Conversation
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>
3004ae6 to
fcc9272
Compare
Always detects signals via clientsignals.DetectOnce() and stores the agent name on context — independent of the client-signals feature flag (which only gates API request headers). Deploy and launch commands read the agent from context to populate the new ClientAgent payload field. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fcc9272 to
54e32ff
Compare
Always detects client signals and stores the agent name on context, independent of the client-signals feature flag (which only gates API request headers). Deploy and launch commands read the agent from context to populate the new ClientAgent payload field, which flyctl-metrics can use as a Prometheus label. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When client signals are enabled, stores the detected agent name on context in InitClient. Deploy and launch commands read it to populate the new ClientAgent payload field, which flyctl-metrics uses as a Prometheus label. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Call clientsignals.DetectOnce() directly in deploy and launch commands to classify the operator as interactive/ci/agent, and capture the agent name when present. Revert the context-plumbing approach in preparers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The package already declares itself as clientsignals, so the explicit alias is unnecessary. Matches the import style in preparers.go. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CI now takes priority over agent (an agent running in CI is "ci"). Interactive requires the terminal check to be true. Falls back to "unknown" when no signals match. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dangra
approved these changes
Jul 10, 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.
Summary
operatorandagentNamefields toLaunchStatusPayloadandDeployStatusPayloadclientsignals.DetectOnce()directly in deploy and launch commands to classify the callerOperatorFromSignals()helper maps signals to operator values:agent,ci, orinteractiveagent,agentNamecarries the specific agent (e.g.claude-code,cursor)omitemptyso older flyctl-metrics versions ignore them gracefullyCompanion PR
operatorandagentNamefrom the payload and uses them as Prometheus labels on deploy/launch metricsMerge order
flyctl-metrics can be merged first — empty payload fields default to
"none".Test plan
go buildpassesfly deployfrom a terminal and verifyoperator=interactivein payloadfly deployfrom CI and verifyoperator=cifly deployfrom an agent (e.g. withCLAUDECODE=1) and verifyoperator=agent,agentName=claude-code🤖 Generated with Claude Code