Skip to content

Commit

Permalink
Enhance container image unpack client logs
Browse files Browse the repository at this point in the history
Adds debug message per layer unpacking and adds duration field to
the existing image unpacking debug message.

Signed-off-by: Austin Vazquez <macedonv@amazon.com>
(cherry picked from commit 01c4421)
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
  • Loading branch information
austinvazquez committed Nov 16, 2023
1 parent 4f03e10 commit 5930a37
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/unpack/unpacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ func (u *Unpacker) unpack(
ctx := u.ctx
ctx, layerSpan := tracing.StartSpan(ctx, tracing.Name(unpackSpanPrefix, "unpack"))
defer layerSpan.End()
unpackStart := time.Now()
p, err := content.ReadBlob(ctx, u.content, config)
if err != nil {
return err
Expand Down Expand Up @@ -412,6 +413,7 @@ func (u *Unpacker) unpack(

for i, desc := range layers {
_, layerSpan := tracing.StartSpan(ctx, tracing.Name(unpackSpanPrefix, "unpackLayer"))
unpackLayerStart := time.Now()
layerSpan.SetAttributes(
tracing.Attribute("layer.media.type", desc.MediaType),
tracing.Attribute("layer.media.size", desc.Size),
Expand All @@ -423,6 +425,10 @@ func (u *Unpacker) unpack(
return err
}
layerSpan.End()
log.G(ctx).WithFields(log.Fields{
"layer": desc.Digest,
"duration": time.Since(unpackLayerStart),
}).Debug("layer unpacked")
}

chainID := identity.ChainID(chain).String()
Expand All @@ -437,8 +443,9 @@ func (u *Unpacker) unpack(
return err
}
log.G(ctx).WithFields(log.Fields{
"config": config.Digest,
"chainID": chainID,
"config": config.Digest,
"chainID": chainID,
"duration": time.Since(unpackStart),
}).Debug("image unpacked")

return nil
Expand Down

0 comments on commit 5930a37

Please sign in to comment.