images: Export the image actions prometheus counter

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
This commit is contained in:
Djordje Lukic 2024-03-12 15:46:12 +01:00
parent b8165a9cd1
commit 0ce714a085
No known key found for this signature in database
5 changed files with 9 additions and 6 deletions

View file

@ -173,7 +173,7 @@ func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force,
return nil, err
}
imageActions.WithValues("delete").UpdateSince(start)
ImageActions.WithValues("delete").UpdateSince(start)
return records, nil
}

View file

@ -76,6 +76,6 @@ func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*image.
break
}
}
imageActions.WithValues("history").UpdateSince(start)
ImageActions.WithValues("history").UpdateSince(start)
return history, nil
}

View file

@ -26,7 +26,7 @@ func (i *ImageService) PullImage(ctx context.Context, ref reference.Named, platf
start := time.Now()
err := i.pullImageWithReference(ctx, ref, platform, metaHeaders, authConfig, outStream)
imageActions.WithValues("pull").UpdateSince(start)
ImageActions.WithValues("pull").UpdateSince(start)
if err != nil {
return err
}

View file

@ -48,6 +48,6 @@ func (i *ImageService) PushImage(ctx context.Context, ref reference.Named, metaH
err := distribution.Push(ctx, ref, imagePushConfig)
close(progressChan)
<-writesDone
imageActions.WithValues("push").UpdateSince(start)
ImageActions.WithValues("push").UpdateSince(start)
return err
}

View file

@ -4,11 +4,14 @@ import (
metrics "github.com/docker/go-metrics"
)
var imageActions metrics.LabeledTimer
// ImagesActions measures the time it takes to process some image actions.
// Exported for use in the containerd-backed image store and it is not intended
// for external consumption. Do not use!
var ImageActions metrics.LabeledTimer
func init() {
ns := metrics.NewNamespace("engine", "daemon", nil)
imageActions = ns.NewLabeledTimer("image_actions", "The number of seconds it takes to process each image action", "action")
ImageActions = ns.NewLabeledTimer("image_actions", "The number of seconds it takes to process each image action", "action")
// TODO: is it OK to register a namespace with the same name? Or does this
// need to be exported from somewhere?
metrics.Register(ns)