mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 13:37:08 +08:00
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 <damaso.hierro@docker.com>
This commit is contained in:
@ -4,6 +4,8 @@ import (
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/context/docker"
|
||||
dockerclient "github.com/docker/docker/client"
|
||||
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
)
|
||||
|
||||
// ClientAPI represents an active docker API object.
|
||||
@ -36,6 +38,10 @@ func NewClientAPI(cli command.Cli, ep string) (*ClientAPI, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
clientOpts = append(clientOpts, dockerclient.WithTraceOptions(otelhttp.WithPropagators(
|
||||
propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{}),
|
||||
)))
|
||||
|
||||
ca.APIClient, err = dockerclient.NewClientWithOpts(clientOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user