Add runtime label to metrics

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko
2021-07-23 10:04:46 -07:00
parent 34fb8d8967
commit efa8ab7158
6 changed files with 65 additions and 31 deletions

View File

@@ -18,10 +18,11 @@ package runtime
// TaskMonitor provides an interface for monitoring of containers within containerd
type TaskMonitor interface {
// Monitor adds the provided container to the monitor
Monitor(Task) error
// Monitor adds the provided container to the monitor.
// Labels are optional (can be nil) key value pairs to be added to the metrics namespace.
Monitor(task Task, labels map[string]string) error
// Stop stops and removes the provided container from the monitor
Stop(Task) error
Stop(task Task) error
}
// NewMultiTaskMonitor returns a new TaskMonitor broadcasting to the provided monitors
@@ -39,7 +40,7 @@ func NewNoopMonitor() TaskMonitor {
type noopTaskMonitor struct {
}
func (mm *noopTaskMonitor) Monitor(c Task) error {
func (mm *noopTaskMonitor) Monitor(c Task, labels map[string]string) error {
return nil
}
@@ -51,9 +52,9 @@ type multiTaskMonitor struct {
monitors []TaskMonitor
}
func (mm *multiTaskMonitor) Monitor(c Task) error {
func (mm *multiTaskMonitor) Monitor(task Task, labels map[string]string) error {
for _, m := range mm.monitors {
if err := m.Monitor(c); err != nil {
if err := m.Monitor(task, labels); err != nil {
return err
}
}