|
5 | 5 | "strings" |
6 | 6 |
|
7 | 7 | containerdimages "github.com/containerd/containerd/images" |
| 8 | + "github.com/containerd/containerd/tracing" |
8 | 9 | cerrdefs "github.com/containerd/errdefs" |
9 | 10 | "github.com/containerd/log" |
10 | 11 | "github.com/distribution/reference" |
@@ -75,6 +76,10 @@ func (i *ImageService) ImagesPrune(ctx context.Context, fltrs filters.Args) (*im |
75 | 76 | // In case a digested and tagged reference was used (e.g. `docker run alpine:latest@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1`), |
76 | 77 | // the alpine:latest image will be kept. |
77 | 78 | func (i *ImageService) pruneUnused(ctx context.Context, filterFunc imageFilterFunc, danglingOnly bool) (*image.PruneReport, error) { |
| 79 | + ctx, span := tracing.StartSpan(ctx, "ImageService.pruneUnused") |
| 80 | + span.SetAttributes(tracing.Attribute("danglingOnly", danglingOnly)) |
| 81 | + defer span.End() |
| 82 | + |
78 | 83 | allImages, err := i.images.List(ctx) |
79 | 84 | if err != nil { |
80 | 85 | return nil, err |
@@ -125,6 +130,10 @@ func filterImagesUsedByContainers(ctx context.Context, |
125 | 130 | allContainers []*container.Container, |
126 | 131 | imagesToPrune map[string]containerdimages.Image, |
127 | 132 | ) (usedDigests map[digest.Digest]struct{}) { |
| 133 | + ctx, span := tracing.StartSpan(ctx, "filterImagesUsedByContainers") |
| 134 | + span.SetAttributes(tracing.Attribute("count", len(allContainers))) |
| 135 | + defer span.End() |
| 136 | + |
128 | 137 | // Image specified by digests that are used by containers. |
129 | 138 | usedDigests = map[digest.Digest]struct{}{} |
130 | 139 |
|
@@ -179,6 +188,10 @@ func filterImagesUsedByContainers(ctx context.Context, |
179 | 188 | func (i *ImageService) pruneAll(ctx context.Context, imagesToPrune map[string]containerdimages.Image) (*image.PruneReport, error) { |
180 | 189 | report := image.PruneReport{} |
181 | 190 |
|
| 191 | + ctx, span := tracing.StartSpan(ctx, "ImageService.pruneAll") |
| 192 | + span.SetAttributes(tracing.Attribute("count", len(imagesToPrune))) |
| 193 | + defer span.End() |
| 194 | + |
182 | 195 | possiblyDeletedConfigs := map[digest.Digest]struct{}{} |
183 | 196 | var errs error |
184 | 197 |
|
|
0 commit comments