Skip to content

Commit f3a3d9c

Browse files
committed
chore(dockerutil): propagate OTEL context to Docker daemon
This allows to correlate operations triggered by a build (e.g. a client-side pull) with the build that generated them. Signed-off-by: Alberto Garcia Hierro <[email protected]>
1 parent 9ba3f77 commit f3a3d9c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ require (
5050
github.com/tonistiigi/go-csvvalue v0.0.0-20240710180619-ddb21b71c0b4
5151
github.com/tonistiigi/jaeger-ui-rest v0.0.0-20250408171107-3dd17559e117
5252
github.com/zclconf/go-cty v1.16.2
53+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0
5354
go.opentelemetry.io/otel v1.31.0
5455
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.31.0
5556
go.opentelemetry.io/otel/metric v1.31.0
@@ -152,7 +153,6 @@ require (
152153
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
153154
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.56.0 // indirect
154155
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.56.0 // indirect
155-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.56.0 // indirect
156156
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.31.0 // indirect
157157
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.31.0 // indirect
158158
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.31.0 // indirect

util/dockerutil/api.go

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"github.com/docker/cli/cli/command"
55
"github.com/docker/cli/cli/context/docker"
66
dockerclient "github.com/docker/docker/client"
7+
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
8+
"go.opentelemetry.io/otel/propagation"
79
)
810

911
// ClientAPI represents an active docker API object.
@@ -36,6 +38,10 @@ func NewClientAPI(cli command.Cli, ep string) (*ClientAPI, error) {
3638
return nil, err
3739
}
3840

41+
clientOpts = append(clientOpts, dockerclient.WithTraceOptions(otelhttp.WithPropagators(
42+
propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}),
43+
)))
44+
3945
ca.APIClient, err = dockerclient.NewClientWithOpts(clientOpts...)
4046
if err != nil {
4147
return nil, err

0 commit comments

Comments
 (0)