mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #19646 from gmarek/master
Add Equal funtion to metrics
This commit is contained in:
commit
f91101e092
@ -50,6 +50,10 @@ var KnownApiServerMetrics = map[string][]string{
|
|||||||
|
|
||||||
type ApiServerMetrics Metrics
|
type ApiServerMetrics Metrics
|
||||||
|
|
||||||
|
func (m *ApiServerMetrics) Equal(o ApiServerMetrics) bool {
|
||||||
|
return (*Metrics)(m).Equal(Metrics(o))
|
||||||
|
}
|
||||||
|
|
||||||
func NewApiServerMetrics() ApiServerMetrics {
|
func NewApiServerMetrics() ApiServerMetrics {
|
||||||
result := NewMetrics()
|
result := NewMetrics()
|
||||||
for metric := range KnownApiServerMetrics {
|
for metric := range KnownApiServerMetrics {
|
||||||
|
@ -42,6 +42,10 @@ var KnownControllerManagerMetrics = map[string][]string{
|
|||||||
|
|
||||||
type ControllerManagerMetrics Metrics
|
type ControllerManagerMetrics Metrics
|
||||||
|
|
||||||
|
func (m *ControllerManagerMetrics) Equal(o ControllerManagerMetrics) bool {
|
||||||
|
return (*Metrics)(m).Equal(Metrics(o))
|
||||||
|
}
|
||||||
|
|
||||||
func NewControllerManagerMetrics() ControllerManagerMetrics {
|
func NewControllerManagerMetrics() ControllerManagerMetrics {
|
||||||
result := NewMetrics()
|
result := NewMetrics()
|
||||||
for metric := range KnownControllerManagerMetrics {
|
for metric := range KnownControllerManagerMetrics {
|
||||||
|
@ -19,6 +19,7 @@ package metrics
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/util/sets"
|
"k8s.io/kubernetes/pkg/util/sets"
|
||||||
@ -58,6 +59,26 @@ var CommonMetrics = map[string][]string{
|
|||||||
|
|
||||||
type Metrics map[string]model.Samples
|
type Metrics map[string]model.Samples
|
||||||
|
|
||||||
|
func (m *Metrics) Equal(o Metrics) bool {
|
||||||
|
leftKeySet := []string{}
|
||||||
|
rightKeySet := []string{}
|
||||||
|
for k := range *m {
|
||||||
|
leftKeySet = append(leftKeySet, k)
|
||||||
|
}
|
||||||
|
for k := range o {
|
||||||
|
rightKeySet = append(rightKeySet, k)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(leftKeySet, rightKeySet) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for _, k := range leftKeySet {
|
||||||
|
if !(*m)[k].Equal(o[k]) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func PrintSample(sample *model.Sample) string {
|
func PrintSample(sample *model.Sample) string {
|
||||||
buf := make([]string, 0)
|
buf := make([]string, 0)
|
||||||
// Id is a VERY special label. For 'normal' container it's usless, but it's necessary
|
// Id is a VERY special label. For 'normal' container it's usless, but it's necessary
|
||||||
|
@ -110,6 +110,10 @@ var KubeletMetricsLabelsToSkip = sets.NewString(
|
|||||||
|
|
||||||
type KubeletMetrics Metrics
|
type KubeletMetrics Metrics
|
||||||
|
|
||||||
|
func (m *KubeletMetrics) Equal(o KubeletMetrics) bool {
|
||||||
|
return (*Metrics)(m).Equal(Metrics(o))
|
||||||
|
}
|
||||||
|
|
||||||
func NewKubeletMetrics() KubeletMetrics {
|
func NewKubeletMetrics() KubeletMetrics {
|
||||||
result := NewMetrics()
|
result := NewMetrics()
|
||||||
for metric := range KnownKubeletMetrics {
|
for metric := range KnownKubeletMetrics {
|
||||||
|
@ -41,6 +41,10 @@ var KnownSchedulerMetrics = map[string][]string{
|
|||||||
|
|
||||||
type SchedulerMetrics Metrics
|
type SchedulerMetrics Metrics
|
||||||
|
|
||||||
|
func (m *SchedulerMetrics) Equal(o SchedulerMetrics) bool {
|
||||||
|
return (*Metrics)(m).Equal(Metrics(o))
|
||||||
|
}
|
||||||
|
|
||||||
func NewSchedulerMetrics() SchedulerMetrics {
|
func NewSchedulerMetrics() SchedulerMetrics {
|
||||||
result := NewMetrics()
|
result := NewMetrics()
|
||||||
for metric := range KnownSchedulerMetrics {
|
for metric := range KnownSchedulerMetrics {
|
||||||
|
Loading…
Reference in New Issue
Block a user