Skip to content

Commit

Permalink
Improve telemetry around docker usage (#3701)
Browse files Browse the repository at this point in the history
* fix DockerDaemonTypeLocal.String to account for being bitmask

* track whether we've detected ci environment
  • Loading branch information
btoews committed Jul 8, 2024
1 parent 826a889 commit e360f62
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
29 changes: 17 additions & 12 deletions internal/build/imgsrc/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,25 @@ const (
)

func (t DockerDaemonType) String() string {
switch t {
case DockerDaemonTypeLocal:
return "local"
case DockerDaemonTypeRemote:
return "remote"
case DockerDaemonTypeNone:
return "none"
case DockerDaemonTypePrefersLocal:
return "prefers-local"
case DockerDaemonTypeNixpacks:
return "nix-packs"
default:
strs := []string{}

if t&DockerDaemonTypeLocal != 0 {
strs = append(strs, "local")
}
if t&DockerDaemonTypeRemote != 0 {
strs = append(strs, "remote")
}
if t&DockerDaemonTypePrefersLocal != 0 {
strs = append(strs, "prefers-local")
}
if t&DockerDaemonTypeNixpacks != 0 {
strs = append(strs, "nix-packs")
}
if len(strs) == 0 {
return "none"
}

return strings.Join(strs, ", ")
}

func (t DockerDaemonType) AllowLocal() bool {
Expand Down
2 changes: 2 additions & 0 deletions internal/tracing/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/go-logr/logr"
"github.com/superfly/flyctl/internal/buildinfo"
"github.com/superfly/flyctl/internal/config"
"github.com/superfly/flyctl/internal/env"
"github.com/superfly/flyctl/internal/logger"
"github.com/superfly/flyctl/iostreams"
)
Expand Down Expand Up @@ -133,6 +134,7 @@ func InitTraceProvider(ctx context.Context, appName string) (*sdktrace.TracerPro
attribute.String("build.info.os", buildinfo.OS()),
attribute.String("build.info.arch", buildinfo.Arch()),
attribute.String("build.info.commit", buildinfo.Commit()),
attribute.Bool("is_ci", env.IsCI()),
}

if appName != "" {
Expand Down

0 comments on commit e360f62

Please sign in to comment.