Add tracing spans in CRI image service and pull.go
Signed-off-by: Swagat Bora <sbora@amazon.com> Add spans around image unpack operations Use image.ref to denote image name and image.id for the image config digest Add top-level spand and record errors in the CRI instrumentation service
This commit is contained in:
		| @@ -22,6 +22,8 @@ import ( | ||||
|  | ||||
| 	"github.com/containerd/containerd/errdefs" | ||||
| 	"github.com/containerd/containerd/images" | ||||
| 	"github.com/containerd/containerd/tracing" | ||||
| 	"go.opentelemetry.io/otel/attribute" | ||||
|  | ||||
| 	runtime "k8s.io/cri-api/pkg/apis/runtime/v1" | ||||
| ) | ||||
| @@ -33,15 +35,17 @@ import ( | ||||
| // Remove the whole image no matter the it's image id or reference. This is the | ||||
| // semantic defined in CRI now. | ||||
| func (c *criService) RemoveImage(ctx context.Context, r *runtime.RemoveImageRequest) (*runtime.RemoveImageResponse, error) { | ||||
| 	span := tracing.CurrentSpan(ctx) | ||||
| 	image, err := c.localResolve(r.GetImage().GetImage()) | ||||
| 	if err != nil { | ||||
| 		if errdefs.IsNotFound(err) { | ||||
| 			span.AddEvent(err.Error()) | ||||
| 			// return empty without error when image not found. | ||||
| 			return &runtime.RemoveImageResponse{}, nil | ||||
| 		} | ||||
| 		return nil, fmt.Errorf("can not resolve %q locally: %w", r.GetImage().GetImage(), err) | ||||
| 	} | ||||
|  | ||||
| 	span.SetAttributes(attribute.String("image.id", image.ID)) | ||||
| 	// Remove all image references. | ||||
| 	for i, ref := range image.References { | ||||
| 		var opts []images.DeleteOpt | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Swagat Bora
					Swagat Bora