Skip to content

Commit 01c4421

Browse files
committed
Enhance container image unpack client logs
Adds debug message per layer unpacking and adds duration field to the existing image unpacking debug message. Signed-off-by: Austin Vazquez <[email protected]>
1 parent 7deb68f commit 01c4421

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

pkg/unpack/unpacker.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ func (u *Unpacker) unpack(
235235
ctx := u.ctx
236236
ctx, layerSpan := tracing.StartSpan(ctx, tracing.Name(unpackSpanPrefix, "unpack"))
237237
defer layerSpan.End()
238+
unpackStart := time.Now()
238239
p, err := content.ReadBlob(ctx, u.content, config)
239240
if err != nil {
240241
return err
@@ -411,6 +412,7 @@ func (u *Unpacker) unpack(
411412

412413
for i, desc := range layers {
413414
_, layerSpan := tracing.StartSpan(ctx, tracing.Name(unpackSpanPrefix, "unpackLayer"))
415+
unpackLayerStart := time.Now()
414416
layerSpan.SetAttributes(
415417
tracing.Attribute("layer.media.type", desc.MediaType),
416418
tracing.Attribute("layer.media.size", desc.Size),
@@ -422,6 +424,10 @@ func (u *Unpacker) unpack(
422424
return err
423425
}
424426
layerSpan.End()
427+
log.G(ctx).WithFields(log.Fields{
428+
"layer": desc.Digest,
429+
"duration": time.Since(unpackLayerStart),
430+
}).Debug("layer unpacked")
425431
}
426432

427433
chainID := identity.ChainID(chain).String()
@@ -436,8 +442,9 @@ func (u *Unpacker) unpack(
436442
return err
437443
}
438444
log.G(ctx).WithFields(log.Fields{
439-
"config": config.Digest,
440-
"chainID": chainID,
445+
"config": config.Digest,
446+
"chainID": chainID,
447+
"duration": time.Since(unpackStart),
441448
}).Debug("image unpacked")
442449

443450
return nil

0 commit comments

Comments
 (0)