Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/command/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/logrusorgru/aurora"
"github.com/spf13/cobra"
"github.com/superfly/client-signals/go"
"github.com/superfly/fly-go/flaps"
"github.com/superfly/flyctl/internal/appconfig"
"github.com/superfly/flyctl/internal/build/imgsrc"
Expand Down Expand Up @@ -517,6 +518,7 @@ func deployToMachines(

startTime := time.Now()
var status metrics.DeployStatusPayload
status.Operator, status.AgentName = metrics.OperatorFromSignals(clientsignals.DetectOnce())

Comment thread
clouvet marked this conversation as resolved.
metrics.Started(ctx, "deploy")
// TODO: remove this once there is nothing upstream using it
Expand Down
2 changes: 2 additions & 0 deletions internal/command/launch/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/logrusorgru/aurora"
"github.com/samber/lo"
"github.com/spf13/cobra"
"github.com/superfly/client-signals/go"
"github.com/superfly/flyctl/gql"
"github.com/superfly/flyctl/internal/appconfig"
"github.com/superfly/flyctl/internal/appsecrets"
Expand Down Expand Up @@ -303,6 +304,7 @@ func run(ctx context.Context) (err error) {

startTime := time.Now()
var status metrics.LaunchStatusPayload
status.Operator, status.AgentName = metrics.OperatorFromSignals(clientsignals.DetectOnce())
metrics.Started(ctx, "launch")
Comment thread
clouvet marked this conversation as resolved.

var state *launchState = nil
Expand Down
21 changes: 21 additions & 0 deletions internal/metrics/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"sync"
"time"

"github.com/superfly/client-signals/go"
"github.com/superfly/flyctl/terminal"
)

Expand Down Expand Up @@ -80,6 +81,8 @@ type LaunchStatusPayload struct {

ScannerFamily string `json:"scanner_family"`
FlyctlVersion string `json:"flyctlVersion"`
Operator string `json:"operator,omitempty"`
AgentName string `json:"agentName,omitempty"`
}
Comment thread
clouvet marked this conversation as resolved.

func LaunchStatus(ctx context.Context, payload LaunchStatusPayload) {
Expand Down Expand Up @@ -113,6 +116,8 @@ type DeployStatusPayload struct {
Strategy string `json:"strategy"`

FlyctlVersion string `json:"flyctlVersion"`
Operator string `json:"operator,omitempty"`
AgentName string `json:"agentName,omitempty"`
}
Comment thread
clouvet marked this conversation as resolved.

func DeployStatus(ctx context.Context, payload DeployStatusPayload) {
Expand Down Expand Up @@ -159,6 +164,22 @@ func StartTiming(ctx context.Context, metricSlug string) func() {
}
}

// OperatorFromSignals returns an operator classification and, when the
// operator is "agent", the agent name. Precedence: ci > agent > interactive.
// Falls back to "unknown" when none of the signals match.
func OperatorFromSignals(s clientsignals.Signals) (operator, agentName string) {
switch {
case s.CI:
return "ci", ""
case s.Agent != "":
return "agent", s.Agent
case s.Interactive:
return "interactive", ""
default:
return "unknown", ""
}
}

type disableFlushMetricsKey struct{}

// WithDisableFlushMetrics returns a context with a flag that disables
Expand Down
Loading