From f46527a1b6883c50aedcc6c87df9052e89a2c0c6 Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Mon, 10 Mar 2025 17:34:08 -0700 Subject: [PATCH] cache: add tracing spans for layer extraction Signed-off-by: Tonis Tiigi --- cache/refs.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cache/refs.go b/cache/refs.go index 5f5692b42..0d8f58c26 100644 --- a/cache/refs.go +++ b/cache/refs.go @@ -32,6 +32,7 @@ import ( "github.com/moby/buildkit/util/overlay" "github.com/moby/buildkit/util/progress" rootlessmountopts "github.com/moby/buildkit/util/rootless/mountopts" + "github.com/moby/buildkit/util/tracing" "github.com/moby/buildkit/util/winlayers" "github.com/moby/sys/mountinfo" "github.com/moby/sys/userns" @@ -39,6 +40,8 @@ import ( ocispecs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/sirupsen/logrus" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/trace" "golang.org/x/sync/errgroup" ) @@ -1308,6 +1311,11 @@ func (sr *immutableRef) unlazyLayer(ctx context.Context, dhs DescHandlers, pg pr statusDone := pg.Status("extracting "+desc.Digest.String(), "extracting") defer statusDone() } + sp, ctx := tracing.StartSpan(ctx, "extract", trace.WithAttributes( + attribute.String("digest", desc.Digest.String()), + attribute.Int("size", int(desc.Size)), + )) + defer sp.End() key := fmt.Sprintf("extract-%s %s", identity.NewID(), sr.getChainID())