Skip to content

Commit

Permalink
otel attribute to track builder implementation selected
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <[email protected]>
  • Loading branch information
ndeloof committed Feb 26, 2025
1 parent 094b48f commit 7b3bdbe
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import (
"github.com/moby/buildkit/util/progress/progressui"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"

// required to get default driver registered
_ "github.com/docker/buildx/driver/docker"
Expand Down Expand Up @@ -101,6 +103,7 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
return nil, err
}
if bake {
trace.SpanFromContext(ctx).SetAttributes(attribute.String("builder", "bake"))
return s.doBuildBake(ctx, project, serviceToBuild, options)
}

Expand Down Expand Up @@ -197,6 +200,7 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
serviceName := fmt.Sprintf("Service %s", name)

if !buildkitEnabled {
trace.SpanFromContext(ctx).SetAttributes(attribute.String("builder", "classic"))
cw.Event(progress.BuildingEvent(serviceName))
id, err := s.doBuildClassic(ctx, project, service, options)
if err != nil {
Expand All @@ -220,6 +224,7 @@ func (s *composeService) build(ctx context.Context, project *types.Project, opti
return err
}

trace.SpanFromContext(ctx).SetAttributes(attribute.String("builder", "buildkit"))
digest, err := s.doBuildBuildkit(ctx, name, buildOptions, w, nodes)
if err != nil {
return err
Expand Down

0 comments on commit 7b3bdbe

Please sign in to comment.