server: add prometheus metrics for CRI operations
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
9d3c442b7b
commit
b959f8996d
29 changed files with 324 additions and 54 deletions
|
@ -5,9 +5,11 @@ import (
|
|||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/cri-o/ocicni/pkg/ocicni"
|
||||
"github.com/kubernetes-incubator/cri-o/libkpod/sandbox"
|
||||
"github.com/kubernetes-incubator/cri-o/server/metrics"
|
||||
"github.com/opencontainers/runtime-tools/validate"
|
||||
"github.com/syndtr/gocapability/capability"
|
||||
)
|
||||
|
@ -181,3 +183,16 @@ func getOCICapabilitiesList() []string {
|
|||
}
|
||||
return caps
|
||||
}
|
||||
|
||||
func recordOperation(operation string, start time.Time) {
|
||||
metrics.CRIOOperations.WithLabelValues(operation).Inc()
|
||||
metrics.CRIOOperationsLatency.WithLabelValues(operation).Observe(metrics.SinceInMicroseconds(start))
|
||||
}
|
||||
|
||||
// recordError records error for metric if an error occurred.
|
||||
func recordError(operation string, err error) {
|
||||
if err != nil {
|
||||
// TODO(runcom): handle timeout from ctx as well
|
||||
metrics.CRIOOperationsErrors.WithLabelValues(operation).Inc()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue