@@ -19,6 +19,7 @@ import (
19
19
"github.com/docker/docker/client"
20
20
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
21
21
"github.com/pterm/pterm"
22
+ "go.opentelemetry.io/otel/sdk/trace"
22
23
)
23
24
24
25
// Version contains al the version information that is being tracked.
@@ -117,20 +118,26 @@ func newWithOptions(ctx context.Context, newPing newPing, goos string) (*Docker,
117
118
// docker context, or if we've missed any common installation configs here.
118
119
switch goos {
119
120
case "darwin" :
120
- potentialHosts = append (potentialHosts ,
121
+ potentialHosts = append (potentialHosts ,
121
122
"unix:///var/run/docker.sock" ,
122
123
fmt .Sprintf ("unix://%s/.docker/run/docker.sock" , paths .UserHome ),
123
124
)
124
125
case "windows" :
125
126
potentialHosts = append (potentialHosts , "npipe:////./pipe/docker_engine" )
126
127
default :
127
- potentialHosts = append (potentialHosts ,
128
+ potentialHosts = append (potentialHosts ,
128
129
"unix:///var/run/docker.sock" ,
129
130
fmt .Sprintf ("unix://%s/.docker/desktop/docker-cli.sock" , paths .UserHome ),
130
131
)
131
132
}
132
133
133
- dockerOpts := []client.Opt {client .FromEnv , client .WithAPIVersionNegotiation ()}
134
+ // Do not sample Docker traces. Dockers Net/HTTP client has Otel instrumentation enabled.
135
+ // URL's and other fields may contain PII, or sensitive information.
136
+ noopTraceProvider := trace .NewTracerProvider (
137
+ trace .WithSampler (trace .NeverSample ()),
138
+ )
139
+
140
+ dockerOpts := []client.Opt {client .FromEnv , client .WithAPIVersionNegotiation (), client .WithTraceProvider (noopTraceProvider )}
134
141
135
142
for _ , host := range potentialHosts {
136
143
dockerCli , err := createAndPing (ctx , newPing , host , dockerOpts )
@@ -140,7 +147,7 @@ func newWithOptions(ctx context.Context, newPing newPing, goos string) (*Docker,
140
147
return & Docker {Client : dockerCli }, nil
141
148
}
142
149
}
143
-
150
+
144
151
return nil , fmt .Errorf ("%w: unable to create docker client" , localerr .ErrDocker )
145
152
}
146
153
0 commit comments