diff --git a/CHANGELOG.md b/CHANGELOG.md index 4777b5276..8bdb106ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - (Feature) (Analytics) Metadata - (Feature) (Analytics) StatefulSet - (Feature) Imported ArangoBackup Cleanup +- (Feature) Global Metrics ## [1.2.40](https://github.com/arangodb/kube-arangodb/tree/1.2.40) (2024-04-10) - (Feature) Add Core fields to the Scheduler Container Spec diff --git a/Makefile b/Makefile index 8cf6b7355..d17fb7d7f 100644 --- a/Makefile +++ b/Makefile @@ -703,6 +703,7 @@ run-unit-tests: $(SOURCES) $(REPOPATH)/pkg/storage/... \ $(REPOPATH)/pkg/crd/... \ $(REPOPATH)/pkg/util/... \ + $(REPOPATH)/pkg/generated/metric_descriptions/... \ $(REPOPATH)/cmd/... \ $(REPOPATH)/pkg/handlers/... diff --git a/docs/generated/metrics/README.md b/docs/generated/metrics/README.md index 864fed6af..1b7551643 100644 --- a/docs/generated/metrics/README.md +++ b/docs/generated/metrics/README.md @@ -14,6 +14,7 @@ has_toc: false | Name | Namespace | Group | Type | Description | |:-------------------------------------------------------------------------------------------------------------------------------------:|:-----------------:|:-----------------:|:-------:|:--------------------------------------------------------------------------------------| +| [arango_operator_objects_processed](./arango_operator_objects_processed.md) | arango_operator | objects | Counter | Number of the processed objects | | [arangodb_operator_agency_errors](./arangodb_operator_agency_errors.md) | arangodb_operator | agency | Counter | Current count of agency cache fetch errors | | [arangodb_operator_agency_fetches](./arangodb_operator_agency_fetches.md) | arangodb_operator | agency | Counter | Current count of agency cache fetches | | [arangodb_operator_agency_index](./arangodb_operator_agency_index.md) | arangodb_operator | agency | Gauge | Current index of the agency cache | diff --git a/docs/generated/metrics/arango_operator_objects_processed.md b/docs/generated/metrics/arango_operator_objects_processed.md new file mode 100644 index 000000000..4d56061f3 --- /dev/null +++ b/docs/generated/metrics/arango_operator_objects_processed.md @@ -0,0 +1,17 @@ +--- +layout: page +title: arango_operator_objects_processed +parent: List of available metrics +--- + +# arango_operator_objects_processed (Counter) + +## Description + +Number of the processed objects + +## Labels + +| Label | Description | +|:-------------:|:--------------| +| operator_name | Operator Name | diff --git a/internal/metrics.go b/internal/metrics.go index 4a55afb77..466f544fe 100644 --- a/internal/metrics.go +++ b/internal/metrics.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -38,6 +38,9 @@ var metricsGoTemplate []byte //go:embed metrics.item.go.tmpl var metricsItemGoTemplate []byte +//go:embed metrics.item.go_test.tmpl +var metricsItemGoTestTemplate []byte + //go:embed metrics.item.tmpl var metricItemTemplate []byte @@ -98,6 +101,8 @@ type Metric struct { Type string `json:"type" yaml:"type"` ShortDescription string `json:"shortDescription" yaml:"shortDescription"` + Global bool `json:"global" yaml:"global"` + Labels []Label `json:"labels" yaml:"labels"` AlertingRules []Alerting `json:"alertingRules" yaml:"alertingRules"` } @@ -277,10 +282,15 @@ func generateLabels(labels []Label) string { func generateMetricsGO(root string, in MetricsDoc) error { i, err := template.New("metrics").Parse(string(metricsItemGoTemplate)) - if err != nil { return err } + + t, err := template.New("metrics").Parse(string(metricsItemGoTestTemplate)) + if err != nil { + return err + } + for _, namespace := range in.Namespaces.Keys() { for _, g := range in.Namespaces[namespace].Keys() { for _, metric := range in.Namespaces[namespace][g].Keys() { @@ -288,11 +298,6 @@ func generateMetricsGO(root string, in MetricsDoc) error { mname := fmt.Sprintf("%s_%s_%s", namespace, g, metric) - out, err := os.OpenFile(path.Join(root, fmt.Sprintf("%s.go", mname)), os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) - if err != nil { - return err - } - parts := strings.Split(mname, "_") tparts := strings.Split(strings.Title(strings.Join(parts, " ")), " ") @@ -311,6 +316,10 @@ func generateMetricsGO(root string, in MetricsDoc) error { params = append(params, "value float64") keys = append(keys, "value") + var mapTypes = map[string]string{} + var mapKeys []string + var mapIKeys = map[string]string{} + for _, label := range details.Labels { v := strings.Split(strings.ToLower(label.Key), "_") for id := range v { @@ -323,29 +332,60 @@ func generateMetricsGO(root string, in MetricsDoc) error { k := strings.Join(v, "") + v[0] = strings.Title(v[0]) + + kPublic := strings.Join(v, "") + keys = append(keys, k) + mapKeys = append(mapKeys, kPublic) + + mapIKeys[kPublic] = k if t := label.Type; t != nil { params = append(params, fmt.Sprintf("%s %s", k, *t)) + mapTypes[kPublic] = *t } else { params = append(params, fmt.Sprintf("%s string", k)) + mapTypes[kPublic] = "string" } } - if err := i.Execute(out, map[string]interface{}{ - "name": mname, - "fname": strings.Join(fnameParts, ""), - "ename": strings.Join(tparts, ""), - "shortDescription": details.ShortDescription, - "labels": generateLabels(details.Labels), - "type": details.Type, - "fparams": strings.Join(params, ", "), - "fkeys": strings.Join(keys, ", "), - }); err != nil { + save := func(template *template.Template, path string) error { + out, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) + if err != nil { + return err + } + + if err := template.Execute(out, map[string]interface{}{ + "name": mname, + "fname": strings.Join(fnameParts, ""), + "ename": strings.Join(tparts, ""), + "shortDescription": details.ShortDescription, + "global": details.Global, + "labels": generateLabels(details.Labels), + "type": details.Type, + "mapTypes": mapTypes, + "mapKeys": mapKeys, + "mapIKeys": mapIKeys, + "args": strings.Join(params[1:], ", "), + "fparams": strings.Join(params, ", "), + "fkeys": strings.Join(keys, ", "), + }); err != nil { + return err + } + + if err := out.Close(); err != nil { + return err + } + + return nil + } + + if err := save(i, path.Join(root, fmt.Sprintf("%s.go", mname))); err != nil { return err } - if err := out.Close(); err != nil { + if err := save(t, path.Join(root, fmt.Sprintf("%s_test.go", mname))); err != nil { return err } } diff --git a/internal/metrics.go.tmpl b/internal/metrics.go.tmpl index 325af68c3..e12c4bf32 100644 --- a/internal/metrics.go.tmpl +++ b/internal/metrics.go.tmpl @@ -28,6 +28,9 @@ import ( var ( descriptions []metrics.Description descriptionsLock sync.Mutex + + collectors []metrics.Collector + collectorsLock sync.Mutex ) func registerDescription( d ... metrics.Description) { @@ -41,9 +44,29 @@ func registerDescription( d ... metrics.Description) { descriptions = append(descriptions, d...) } +func registerCollector( d ... metrics.Collector) { + if len(d) == 0 { + return + } + + collectorsLock.Lock() + defer collectorsLock.Unlock() + + collectors = append(collectors, d...) +} + func Descriptions (c metrics.PushDescription) { descriptionsLock.Lock() defer descriptionsLock.Unlock() c.Push(descriptions...) +} + +func Collectors (c metrics.PushMetric) { + collectorsLock.Lock() + defer collectorsLock.Unlock() + + for _, collector := range collectors { + collector.CollectMetrics(c) + } } \ No newline at end of file diff --git a/internal/metrics.item.go.tmpl b/internal/metrics.item.go.tmpl index 47156c510..f042dfa8c 100644 --- a/internal/metrics.item.go.tmpl +++ b/internal/metrics.item.go.tmpl @@ -1,3 +1,4 @@ +{{- $root := . -}} // // DISCLAIMER // @@ -20,7 +21,13 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +{{- if .global }} + + "sync" +{{- end }} +) var ( {{ .fname }} = metrics.NewDescription("{{ .name }}", "{{ .shortDescription }}", {{ .labels }}, nil) @@ -28,12 +35,142 @@ var ( func init() { registerDescription({{ .fname }}) +{{- if .global }} + registerCollector({{ .fname }}Global) +{{- end }} } func {{ .ename }}() metrics.Description { return {{ .fname }} } +{{- if .global }} + +func {{ .ename }}Get({{ .args }}) float64 { + return {{ .fname }}Global.Get({{ .ename }}Item{ +{{- range $i, $field := .mapKeys }} + {{ $field }}: {{ index $root.mapIKeys $field }}, +{{- end }} + }) +} + +func {{ .ename }}Add({{ .fparams }}) { + {{ .fname }}Global.Add(value, {{ .ename }}Item{ +{{- range $i, $field := .mapKeys }} + {{ $field }}: {{ index $root.mapIKeys $field }}, +{{- end }} + }) +} +{{- if eq .type "Counter" }} + +func {{ .ename }}Inc({{ .args }}) { + {{ .fname }}Global.Inc({{ .ename }}Item{ +{{- range $i, $field := .mapKeys }} + {{ $field }}: {{ index $root.mapIKeys $field }}, +{{- end }} + }) +} +{{- end }} + +func Get{{ .ename }}Factory() {{ .ename }}Factory { + return {{ .fname }}Global +} + +var {{ .fname }}Global = &{{ .fname }}Factory{ + items: {{ .fname }}Items{}, +} + +type {{ .ename }}Factory interface { + Get(object {{ .ename }}Item) float64 + Add(value float64, object {{ .ename }}Item) + Remove(object {{ .ename }}Item) + Items() []{{ .ename }}Item +{{- if eq .type "Counter" }} + + Inc(object {{ .ename }}Item) +{{- end }} +} + +type {{ .fname }}Factory struct { + lock sync.RWMutex + + items {{ .fname }}Items +} + +func (a *{{ .fname }}Factory) Get(object {{ .ename }}Item) float64 { + a.lock.Lock() + defer a.lock.Unlock() + + v, ok := a.items[object] + if !ok { + return 0 + } + + return v +} + +func (a *{{ .fname }}Factory) Add(value float64, object {{ .ename }}Item) { + a.lock.Lock() + defer a.lock.Unlock() + + v, ok := a.items[object] + if !ok { + a.items[object] = value + return + } + + a.items[object] = value + v +} + +func (a *{{ .fname }}Factory) Remove(obj {{ .ename }}Item) { + a.lock.Lock() + defer a.lock.Unlock() + + delete(a.items, obj) +} + +func (a *{{ .fname }}Factory) Items() []{{ .ename }}Item { + a.lock.Lock() + defer a.lock.Unlock() + + var r = make([]{{ .ename }}Item, 0, len(a.items)) + + for k := range a.items { + r = append(r, k) + } + + return r +} +{{- if eq .type "Counter" }} + +func (a *{{ .fname }}Factory) Inc(object {{ .ename }}Item) { + a.Add(1, object) +} +{{- end }} + +func (a *{{ .fname }}Factory) CollectMetrics(in metrics.PushMetric) { + a.lock.RLock() + defer a.lock.RUnlock() + + for k, v := range a.items { + in.Push({{ .fname }}.{{ .type }}(v{{- range .mapKeys }}, k.{{ . }}{{- end }})) + } +} + +func (a *{{ .fname }}Factory) CollectDescriptions(in metrics.PushDescription) { + in.Push({{ .fname }}) +} + +type {{ .fname }}Items map[{{ .ename }}Item]float64 + +type {{ .ename }}Item struct { +{{- range .mapKeys }} + {{ . }} {{ index $root.mapTypes . }} +{{- end }} +} +{{- else }} + func {{ .ename }}{{ .type }}({{ .fparams }}) metrics.Metric { return {{ .ename }}().{{ .type }}({{ .fkeys }}) -} \ No newline at end of file +} +{{- end }} diff --git a/internal/metrics.item.go_test.tmpl b/internal/metrics.item.go_test.tmpl new file mode 100644 index 000000000..4167a7156 --- /dev/null +++ b/internal/metrics.item.go_test.tmpl @@ -0,0 +1,179 @@ +{{- $root := . -}} +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +{{- if .global }} + + "github.com/stretchr/testify/require" +{{- end }} +) + +func Test_{{ .ename }}_Descriptor(t *testing.T) { + {{ .ename }}() +} + +{{- if .global }} + +func Test_{{ .ename }}_Global(t *testing.T) { + global := Get{{ .ename }}Factory() + + object1 := {{ .ename }}Item{ +{{- range $i, $field := .mapKeys }} + {{ $field }}: "1", +{{- end }} + } + + object2 := {{ .ename }}Item{ +{{- range $i, $field := .mapKeys }} + {{ $field }}: "2", +{{- end }} + } + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 0) + }) + + t.Run("Precheck", func(t *testing.T) { + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("Add", func(t *testing.T) { + global.Add(10, object1) + + require.EqualValues(t, 10, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 1) + }) + + t.Run("Add", func(t *testing.T) { + global.Add(3, object2) + + require.EqualValues(t, 10, global.Get(object1)) + require.EqualValues(t, 3, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 2) + }) + + t.Run("Dec", func(t *testing.T) { + global.Add(-1, object1) + + require.EqualValues(t, 9, global.Get(object1)) + require.EqualValues(t, 3, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 2) + }) + + t.Run("Remove", func(t *testing.T) { + global.Remove(object1) + + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 3, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 1) + }) + + t.Run("Remove", func(t *testing.T) { + global.Remove(object1) + + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 3, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 1) + }) + + t.Run("Remove", func(t *testing.T) { + global.Remove(object2) + + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 0) + }) +} +{{- if eq .type "Counter" }} + +func Test_{{ .ename }}_Global_Counter(t *testing.T) { + global := Get{{ .ename }}Factory() + + object1 := {{ .ename }}Item{ +{{- range $i, $field := .mapKeys }} + {{ $field }}: "1", +{{- end }} + } + + object2 := {{ .ename }}Item{ +{{- range $i, $field := .mapKeys }} + {{ $field }}: "2", +{{- end }} + } + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 0) + }) + + t.Run("Precheck", func(t *testing.T) { + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("Add", func(t *testing.T) { + global.Add(10, object1) + + require.EqualValues(t, 10, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 1) + }) + + t.Run("Inc", func(t *testing.T) { + global.Inc(object1) + global.Inc(object2) + + require.EqualValues(t, 11, global.Get(object1)) + require.EqualValues(t, 1, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 2) + }) +} +{{- end }} + +{{- end }} diff --git a/internal/metrics.yaml b/internal/metrics.yaml index 18c66c464..c8bf25aa2 100644 --- a/internal/metrics.yaml +++ b/internal/metrics.yaml @@ -1,6 +1,16 @@ documentation: docs/generated/metrics destination: pkg/generated/metric_descriptions namespaces: + arango_operator: + objects: + processed: + shortDescription: "Number of the processed objects" + description: "Number of the processed objects" + type: "Counter" + global: true + labels: + - key: operator_name + description: "Operator Name" arangodb_operator: agency_cache: present: diff --git a/pkg/deployment/old_metrics.go b/pkg/deployment/old_metrics.go index 6477b0d22..ac1f496f7 100644 --- a/pkg/deployment/old_metrics.go +++ b/pkg/deployment/old_metrics.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2023 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -71,6 +71,8 @@ func (i *inventory) CollectDescriptions(in metrics.PushDescription) { } func (i *inventory) CollectMetrics(in metrics.PushMetric) { + metric_descriptions.Collectors(in) + for _, deployments := range i.deployments { for _, deployment := range deployments { in.Push(i.deploymentsMetric.Gauge(1, deployment.GetNamespace(), deployment.GetName())) diff --git a/pkg/generated/metric_descriptions/arango_operator_objects_processed.go b/pkg/generated/metric_descriptions/arango_operator_objects_processed.go new file mode 100644 index 000000000..6408598a2 --- /dev/null +++ b/pkg/generated/metric_descriptions/arango_operator_objects_processed.go @@ -0,0 +1,149 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "sync" + + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) + +var ( + arangoOperatorObjectsProcessed = metrics.NewDescription("arango_operator_objects_processed", "Number of the processed objects", []string{`operator_name`}, nil) +) + +func init() { + registerDescription(arangoOperatorObjectsProcessed) + registerCollector(arangoOperatorObjectsProcessedGlobal) +} + +func ArangoOperatorObjectsProcessed() metrics.Description { + return arangoOperatorObjectsProcessed +} + +func ArangoOperatorObjectsProcessedGet(operatorName string) float64 { + return arangoOperatorObjectsProcessedGlobal.Get(ArangoOperatorObjectsProcessedItem{ + OperatorName: operatorName, + }) +} + +func ArangoOperatorObjectsProcessedAdd(value float64, operatorName string) { + arangoOperatorObjectsProcessedGlobal.Add(value, ArangoOperatorObjectsProcessedItem{ + OperatorName: operatorName, + }) +} + +func ArangoOperatorObjectsProcessedInc(operatorName string) { + arangoOperatorObjectsProcessedGlobal.Inc(ArangoOperatorObjectsProcessedItem{ + OperatorName: operatorName, + }) +} + +func GetArangoOperatorObjectsProcessedFactory() ArangoOperatorObjectsProcessedFactory { + return arangoOperatorObjectsProcessedGlobal +} + +var arangoOperatorObjectsProcessedGlobal = &arangoOperatorObjectsProcessedFactory{ + items: arangoOperatorObjectsProcessedItems{}, +} + +type ArangoOperatorObjectsProcessedFactory interface { + Get(object ArangoOperatorObjectsProcessedItem) float64 + Add(value float64, object ArangoOperatorObjectsProcessedItem) + Remove(object ArangoOperatorObjectsProcessedItem) + Items() []ArangoOperatorObjectsProcessedItem + + Inc(object ArangoOperatorObjectsProcessedItem) +} + +type arangoOperatorObjectsProcessedFactory struct { + lock sync.RWMutex + + items arangoOperatorObjectsProcessedItems +} + +func (a *arangoOperatorObjectsProcessedFactory) Get(object ArangoOperatorObjectsProcessedItem) float64 { + a.lock.Lock() + defer a.lock.Unlock() + + v, ok := a.items[object] + if !ok { + return 0 + } + + return v +} + +func (a *arangoOperatorObjectsProcessedFactory) Add(value float64, object ArangoOperatorObjectsProcessedItem) { + a.lock.Lock() + defer a.lock.Unlock() + + v, ok := a.items[object] + if !ok { + a.items[object] = value + return + } + + a.items[object] = value + v +} + +func (a *arangoOperatorObjectsProcessedFactory) Remove(obj ArangoOperatorObjectsProcessedItem) { + a.lock.Lock() + defer a.lock.Unlock() + + delete(a.items, obj) +} + +func (a *arangoOperatorObjectsProcessedFactory) Items() []ArangoOperatorObjectsProcessedItem { + a.lock.Lock() + defer a.lock.Unlock() + + var r = make([]ArangoOperatorObjectsProcessedItem, 0, len(a.items)) + + for k := range a.items { + r = append(r, k) + } + + return r +} + +func (a *arangoOperatorObjectsProcessedFactory) Inc(object ArangoOperatorObjectsProcessedItem) { + a.Add(1, object) +} + +func (a *arangoOperatorObjectsProcessedFactory) CollectMetrics(in metrics.PushMetric) { + a.lock.RLock() + defer a.lock.RUnlock() + + for k, v := range a.items { + in.Push(arangoOperatorObjectsProcessed.Counter(v, k.OperatorName)) + } +} + +func (a *arangoOperatorObjectsProcessedFactory) CollectDescriptions(in metrics.PushDescription) { + in.Push(arangoOperatorObjectsProcessed) +} + +type arangoOperatorObjectsProcessedItems map[ArangoOperatorObjectsProcessedItem]float64 + +type ArangoOperatorObjectsProcessedItem struct { + OperatorName string +} diff --git a/pkg/generated/metric_descriptions/arango_operator_objects_processed_test.go b/pkg/generated/metric_descriptions/arango_operator_objects_processed_test.go new file mode 100644 index 000000000..107f21d30 --- /dev/null +++ b/pkg/generated/metric_descriptions/arango_operator_objects_processed_test.go @@ -0,0 +1,162 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func Test_ArangoOperatorObjectsProcessed_Descriptor(t *testing.T) { + ArangoOperatorObjectsProcessed() +} + +func Test_ArangoOperatorObjectsProcessed_Global(t *testing.T) { + global := GetArangoOperatorObjectsProcessedFactory() + + object1 := ArangoOperatorObjectsProcessedItem{ + OperatorName: "1", + } + + object2 := ArangoOperatorObjectsProcessedItem{ + OperatorName: "2", + } + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 0) + }) + + t.Run("Precheck", func(t *testing.T) { + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("Add", func(t *testing.T) { + global.Add(10, object1) + + require.EqualValues(t, 10, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 1) + }) + + t.Run("Add", func(t *testing.T) { + global.Add(3, object2) + + require.EqualValues(t, 10, global.Get(object1)) + require.EqualValues(t, 3, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 2) + }) + + t.Run("Dec", func(t *testing.T) { + global.Add(-1, object1) + + require.EqualValues(t, 9, global.Get(object1)) + require.EqualValues(t, 3, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 2) + }) + + t.Run("Remove", func(t *testing.T) { + global.Remove(object1) + + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 3, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 1) + }) + + t.Run("Remove", func(t *testing.T) { + global.Remove(object1) + + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 3, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 1) + }) + + t.Run("Remove", func(t *testing.T) { + global.Remove(object2) + + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 0) + }) +} + +func Test_ArangoOperatorObjectsProcessed_Global_Counter(t *testing.T) { + global := GetArangoOperatorObjectsProcessedFactory() + + object1 := ArangoOperatorObjectsProcessedItem{ + OperatorName: "1", + } + + object2 := ArangoOperatorObjectsProcessedItem{ + OperatorName: "2", + } + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 0) + }) + + t.Run("Precheck", func(t *testing.T) { + require.EqualValues(t, 0, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("Add", func(t *testing.T) { + global.Add(10, object1) + + require.EqualValues(t, 10, global.Get(object1)) + require.EqualValues(t, 0, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 1) + }) + + t.Run("Inc", func(t *testing.T) { + global.Inc(object1) + global.Inc(object2) + + require.EqualValues(t, 11, global.Get(object1)) + require.EqualValues(t, 1, global.Get(object2)) + }) + + t.Run("List", func(t *testing.T) { + require.Len(t, global.Items(), 2) + }) +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_health_present.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_health_present.go index c50fe4520..76943135d 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_health_present.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_health_present.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyCacheHealthPresent = metrics.NewDescription("arangodb_operator_agency_cache_health_present", "Determines if local agency cache health is present", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_health_present_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_health_present_test.go new file mode 100644 index 000000000..e5309f5be --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_health_present_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyCacheHealthPresent_Descriptor(t *testing.T) { + ArangodbOperatorAgencyCacheHealthPresent() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_healthy.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_healthy.go index 75f645dfe..a78f59495 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_healthy.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_healthy.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyCacheHealthy = metrics.NewDescription("arangodb_operator_agency_cache_healthy", "Determines if agency is healthy", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_healthy_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_healthy_test.go new file mode 100644 index 000000000..c1a6f057e --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_healthy_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyCacheHealthy_Descriptor(t *testing.T) { + ArangodbOperatorAgencyCacheHealthy() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_leaders.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_leaders.go index 6833d5a42..44d0d104a 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_leaders.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_leaders.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyCacheLeaders = metrics.NewDescription("arangodb_operator_agency_cache_leaders", "Determines agency leader vote count", []string{`namespace`, `name`, `agent`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_leaders_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_leaders_test.go new file mode 100644 index 000000000..358a9c6e3 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_leaders_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyCacheLeaders_Descriptor(t *testing.T) { + ArangodbOperatorAgencyCacheLeaders() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_commit_offset.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_commit_offset.go index bcd557ae7..b1d024ade 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_commit_offset.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_commit_offset.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyCacheMemberCommitOffset = metrics.NewDescription("arangodb_operator_agency_cache_member_commit_offset", "Determines agency member commit offset", []string{`namespace`, `name`, `agent`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_commit_offset_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_commit_offset_test.go new file mode 100644 index 000000000..575d30893 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_commit_offset_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyCacheMemberCommitOffset_Descriptor(t *testing.T) { + ArangodbOperatorAgencyCacheMemberCommitOffset() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_serving.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_serving.go index 05e296c8e..e61ade3ab 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_serving.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_serving.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyCacheMemberServing = metrics.NewDescription("arangodb_operator_agency_cache_member_serving", "Determines if agency member is reachable", []string{`namespace`, `name`, `agent`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_serving_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_serving_test.go new file mode 100644 index 000000000..34d1665c5 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_member_serving_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyCacheMemberServing_Descriptor(t *testing.T) { + ArangodbOperatorAgencyCacheMemberServing() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_present.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_present.go index 0d138dfe4..24cb88aed 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_present.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_present.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyCachePresent = metrics.NewDescription("arangodb_operator_agency_cache_present", "Determines if local agency cache is present", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_present_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_present_test.go new file mode 100644 index 000000000..04ef1b512 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_present_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyCachePresent_Descriptor(t *testing.T) { + ArangodbOperatorAgencyCachePresent() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_serving.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_serving.go index 62865a000..f38b126fd 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_serving.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_serving.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyCacheServing = metrics.NewDescription("arangodb_operator_agency_cache_serving", "Determines if agency is serving", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_serving_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_serving_test.go new file mode 100644 index 000000000..59daee1f6 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_cache_serving_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyCacheServing_Descriptor(t *testing.T) { + ArangodbOperatorAgencyCacheServing() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_errors.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_errors.go index 609e99964..232fbee0c 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_errors.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_errors.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyErrors = metrics.NewDescription("arangodb_operator_agency_errors", "Current count of agency cache fetch errors", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_errors_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_errors_test.go new file mode 100644 index 000000000..afbb31371 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_errors_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyErrors_Descriptor(t *testing.T) { + ArangodbOperatorAgencyErrors() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_fetches.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_fetches.go index 30f511443..bac0258b4 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_fetches.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_fetches.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyFetches = metrics.NewDescription("arangodb_operator_agency_fetches", "Current count of agency cache fetches", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_fetches_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_fetches_test.go new file mode 100644 index 000000000..f0a744812 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_fetches_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyFetches_Descriptor(t *testing.T) { + ArangodbOperatorAgencyFetches() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_index.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_index.go index ba65aed5e..4ca0b865a 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_agency_index.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_index.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorAgencyIndex = metrics.NewDescription("arangodb_operator_agency_index", "Current index of the agency cache", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_agency_index_test.go b/pkg/generated/metric_descriptions/arangodb_operator_agency_index_test.go new file mode 100644 index 000000000..4ae14ead1 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_agency_index_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorAgencyIndex_Descriptor(t *testing.T) { + ArangodbOperatorAgencyIndex() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_deployment_conditions.go b/pkg/generated/metric_descriptions/arangodb_operator_deployment_conditions.go index 1ed17ab63..75172048b 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_deployment_conditions.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_deployment_conditions.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorDeploymentConditions = metrics.NewDescription("arangodb_operator_deployment_conditions", "Representation of the ArangoDeployment condition state (true/false)", []string{`namespace`, `name`, `condition`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_deployment_conditions_test.go b/pkg/generated/metric_descriptions/arangodb_operator_deployment_conditions_test.go new file mode 100644 index 000000000..81360d516 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_deployment_conditions_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorDeploymentConditions_Descriptor(t *testing.T) { + ArangodbOperatorDeploymentConditions() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_engine_assertions.go b/pkg/generated/metric_descriptions/arangodb_operator_engine_assertions.go index 31f412c04..1d73982a8 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_engine_assertions.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_engine_assertions.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorEngineAssertions = metrics.NewDescription("arangodb_operator_engine_assertions", "Number of assertions invoked during Operator runtime", []string{`key`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_engine_assertions_test.go b/pkg/generated/metric_descriptions/arangodb_operator_engine_assertions_test.go new file mode 100644 index 000000000..84655550a --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_engine_assertions_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorEngineAssertions_Descriptor(t *testing.T) { + ArangodbOperatorEngineAssertions() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_engine_ops_alerts.go b/pkg/generated/metric_descriptions/arangodb_operator_engine_ops_alerts.go index d397c47c8..b44159890 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_engine_ops_alerts.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_engine_ops_alerts.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorEngineOpsAlerts = metrics.NewDescription("arangodb_operator_engine_ops_alerts", "Counter for actions which requires ops attention", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_engine_ops_alerts_test.go b/pkg/generated/metric_descriptions/arangodb_operator_engine_ops_alerts_test.go new file mode 100644 index 000000000..7042cf63a --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_engine_ops_alerts_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorEngineOpsAlerts_Descriptor(t *testing.T) { + ArangodbOperatorEngineOpsAlerts() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_engine_panics_recovered.go b/pkg/generated/metric_descriptions/arangodb_operator_engine_panics_recovered.go index a412f8022..5aae6d6fa 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_engine_panics_recovered.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_engine_panics_recovered.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorEnginePanicsRecovered = metrics.NewDescription("arangodb_operator_engine_panics_recovered", "Number of Panics recovered inside Operator reconciliation loop", []string{`section`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_engine_panics_recovered_test.go b/pkg/generated/metric_descriptions/arangodb_operator_engine_panics_recovered_test.go new file mode 100644 index 000000000..1fb1c4ef5 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_engine_panics_recovered_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorEnginePanicsRecovered_Descriptor(t *testing.T) { + ArangodbOperatorEnginePanicsRecovered() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_request_errors.go b/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_request_errors.go index 8ecf33823..406a0b24b 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_request_errors.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_request_errors.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorKubernetesClientRequestErrors = metrics.NewDescription("arangodb_operator_kubernetes_client_request_errors", "Number of Kubernetes Client request errors", []string{`component`, `verb`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_request_errors_test.go b/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_request_errors_test.go new file mode 100644 index 000000000..130dca568 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_request_errors_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorKubernetesClientRequestErrors_Descriptor(t *testing.T) { + ArangodbOperatorKubernetesClientRequestErrors() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_requests.go b/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_requests.go index be5e640a9..225cb2516 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_requests.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_requests.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorKubernetesClientRequests = metrics.NewDescription("arangodb_operator_kubernetes_client_requests", "Number of Kubernetes Client requests", []string{`component`, `verb`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_requests_test.go b/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_requests_test.go new file mode 100644 index 000000000..58709fb0f --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_kubernetes_client_requests_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorKubernetesClientRequests_Descriptor(t *testing.T) { + ArangodbOperatorKubernetesClientRequests() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_members_conditions.go b/pkg/generated/metric_descriptions/arangodb_operator_members_conditions.go index ff4782e87..453f5e35a 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_members_conditions.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_members_conditions.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorMembersConditions = metrics.NewDescription("arangodb_operator_members_conditions", "Representation of the ArangoMember condition state (true/false)", []string{`namespace`, `name`, `member`, `condition`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_members_conditions_test.go b/pkg/generated/metric_descriptions/arangodb_operator_members_conditions_test.go new file mode 100644 index 000000000..dd6973530 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_members_conditions_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorMembersConditions_Descriptor(t *testing.T) { + ArangodbOperatorMembersConditions() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_members_unexpected_container_exit_codes.go b/pkg/generated/metric_descriptions/arangodb_operator_members_unexpected_container_exit_codes.go index 9d0bfbad1..925ce528d 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_members_unexpected_container_exit_codes.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_members_unexpected_container_exit_codes.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorMembersUnexpectedContainerExitCodes = metrics.NewDescription("arangodb_operator_members_unexpected_container_exit_codes", "Counter of unexpected restarts in pod (Containers/InitContainers/EphemeralContainers)", []string{`namespace`, `name`, `member`, `container`, `container_type`, `code`, `reason`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_members_unexpected_container_exit_codes_test.go b/pkg/generated/metric_descriptions/arangodb_operator_members_unexpected_container_exit_codes_test.go new file mode 100644 index 000000000..1038437ec --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_members_unexpected_container_exit_codes_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorMembersUnexpectedContainerExitCodes_Descriptor(t *testing.T) { + ArangodbOperatorMembersUnexpectedContainerExitCodes() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_enabled.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_enabled.go index 8347d6180..703118745 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_enabled.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_enabled.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorRebalancerEnabled = metrics.NewDescription("arangodb_operator_rebalancer_enabled", "Determines if rebalancer is enabled", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_enabled_test.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_enabled_test.go new file mode 100644 index 000000000..305e04f0c --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_enabled_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorRebalancerEnabled_Descriptor(t *testing.T) { + ArangodbOperatorRebalancerEnabled() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_current.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_current.go index e96c3846a..417db54ac 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_current.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_current.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorRebalancerMovesCurrent = metrics.NewDescription("arangodb_operator_rebalancer_moves_current", "Define how many moves are currently in progress", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_current_test.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_current_test.go new file mode 100644 index 000000000..af13987d9 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_current_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorRebalancerMovesCurrent_Descriptor(t *testing.T) { + ArangodbOperatorRebalancerMovesCurrent() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_failed.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_failed.go index 6131f8336..928eec8d8 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_failed.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_failed.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorRebalancerMovesFailed = metrics.NewDescription("arangodb_operator_rebalancer_moves_failed", "Define how many moves failed", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_failed_test.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_failed_test.go new file mode 100644 index 000000000..825f8127c --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_failed_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorRebalancerMovesFailed_Descriptor(t *testing.T) { + ArangodbOperatorRebalancerMovesFailed() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_generated.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_generated.go index ef4b2b714..d4a43f083 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_generated.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_generated.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorRebalancerMovesGenerated = metrics.NewDescription("arangodb_operator_rebalancer_moves_generated", "Define how many moves were generated", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_generated_test.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_generated_test.go new file mode 100644 index 000000000..e5867b5bf --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_generated_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorRebalancerMovesGenerated_Descriptor(t *testing.T) { + ArangodbOperatorRebalancerMovesGenerated() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_succeeded.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_succeeded.go index 363734764..dadf0026f 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_succeeded.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_succeeded.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorRebalancerMovesSucceeded = metrics.NewDescription("arangodb_operator_rebalancer_moves_succeeded", "Define how many moves succeeded", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_succeeded_test.go b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_succeeded_test.go new file mode 100644 index 000000000..3c7873dcd --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_rebalancer_moves_succeeded_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorRebalancerMovesSucceeded_Descriptor(t *testing.T) { + ArangodbOperatorRebalancerMovesSucceeded() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_accepted.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_accepted.go index b1c1f2acb..c2d3159d8 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_accepted.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_accepted.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorResourcesArangodeploymentAccepted = metrics.NewDescription("arangodb_operator_resources_arangodeployment_accepted", "Defines if ArangoDeployment has been accepted", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_accepted_test.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_accepted_test.go new file mode 100644 index 000000000..1496ecb23 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_accepted_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorResourcesArangodeploymentAccepted_Descriptor(t *testing.T) { + ArangodbOperatorResourcesArangodeploymentAccepted() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_immutable_errors.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_immutable_errors.go index b31f1bb31..b3e103330 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_immutable_errors.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_immutable_errors.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorResourcesArangodeploymentImmutableErrors = metrics.NewDescription("arangodb_operator_resources_arangodeployment_immutable_errors", "Counter for deployment immutable errors", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_immutable_errors_test.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_immutable_errors_test.go new file mode 100644 index 000000000..92fc12790 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_immutable_errors_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorResourcesArangodeploymentImmutableErrors_Descriptor(t *testing.T) { + ArangodbOperatorResourcesArangodeploymentImmutableErrors() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_propagated.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_propagated.go index 431071c74..5bb79cbc0 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_propagated.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_propagated.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorResourcesArangodeploymentPropagated = metrics.NewDescription("arangodb_operator_resources_arangodeployment_propagated", "Defines if ArangoDeployment Spec is propagated", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_propagated_test.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_propagated_test.go new file mode 100644 index 000000000..8f7edc9f1 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_propagated_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorResourcesArangodeploymentPropagated_Descriptor(t *testing.T) { + ArangodbOperatorResourcesArangodeploymentPropagated() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_status_restores.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_status_restores.go index c615b99d5..453274d60 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_status_restores.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_status_restores.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorResourcesArangodeploymentStatusRestores = metrics.NewDescription("arangodb_operator_resources_arangodeployment_status_restores", "Counter for deployment status restored", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_status_restores_test.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_status_restores_test.go new file mode 100644 index 000000000..f87582f55 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_status_restores_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorResourcesArangodeploymentStatusRestores_Descriptor(t *testing.T) { + ArangodbOperatorResourcesArangodeploymentStatusRestores() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_uptodate.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_uptodate.go index a08da9815..801dae61c 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_uptodate.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_uptodate.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorResourcesArangodeploymentUptodate = metrics.NewDescription("arangodb_operator_resources_arangodeployment_uptodate", "Defines if ArangoDeployment is uptodate", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_uptodate_test.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_uptodate_test.go new file mode 100644 index 000000000..569d115e6 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_uptodate_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorResourcesArangodeploymentUptodate_Descriptor(t *testing.T) { + ArangodbOperatorResourcesArangodeploymentUptodate() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_validation_errors.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_validation_errors.go index 3517f672a..6f369280c 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_validation_errors.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_validation_errors.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorResourcesArangodeploymentValidationErrors = metrics.NewDescription("arangodb_operator_resources_arangodeployment_validation_errors", "Counter for deployment validation errors", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_validation_errors_test.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_validation_errors_test.go new file mode 100644 index 000000000..7f5db4a80 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeployment_validation_errors_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorResourcesArangodeploymentValidationErrors_Descriptor(t *testing.T) { + ArangodbOperatorResourcesArangodeploymentValidationErrors() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_active.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_active.go index 57288aede..2baabad0a 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_active.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_active.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorResourcesArangodeploymentreplicationActive = metrics.NewDescription("arangodb_operator_resources_arangodeploymentreplication_active", "Defines if ArangoDeploymentReplication is configured and running", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_active_test.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_active_test.go new file mode 100644 index 000000000..caf4fa142 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_active_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorResourcesArangodeploymentreplicationActive_Descriptor(t *testing.T) { + ArangodbOperatorResourcesArangodeploymentreplicationActive() +} diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_failed.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_failed.go index b5f95c3bf..cc1fd6ab3 100644 --- a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_failed.go +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_failed.go @@ -20,7 +20,9 @@ package metric_descriptions -import "github.com/arangodb/kube-arangodb/pkg/util/metrics" +import ( + "github.com/arangodb/kube-arangodb/pkg/util/metrics" +) var ( arangodbOperatorResourcesArangodeploymentreplicationFailed = metrics.NewDescription("arangodb_operator_resources_arangodeploymentreplication_failed", "Defines if ArangoDeploymentReplication is in Failed phase", []string{`namespace`, `name`}, nil) diff --git a/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_failed_test.go b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_failed_test.go new file mode 100644 index 000000000..bc723c658 --- /dev/null +++ b/pkg/generated/metric_descriptions/arangodb_operator_resources_arangodeploymentreplication_failed_test.go @@ -0,0 +1,29 @@ +// +// DISCLAIMER +// +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Copyright holder is ArangoDB GmbH, Cologne, Germany +// + +package metric_descriptions + +import ( + "testing" +) + +func Test_ArangodbOperatorResourcesArangodeploymentreplicationFailed_Descriptor(t *testing.T) { + ArangodbOperatorResourcesArangodeploymentreplicationFailed() +} diff --git a/pkg/generated/metric_descriptions/metrics.go b/pkg/generated/metric_descriptions/metrics.go index edff727c3..afdcc148a 100644 --- a/pkg/generated/metric_descriptions/metrics.go +++ b/pkg/generated/metric_descriptions/metrics.go @@ -29,6 +29,9 @@ import ( var ( descriptions []metrics.Description descriptionsLock sync.Mutex + + collectors []metrics.Collector + collectorsLock sync.Mutex ) func registerDescription(d ...metrics.Description) { @@ -42,9 +45,29 @@ func registerDescription(d ...metrics.Description) { descriptions = append(descriptions, d...) } +func registerCollector(d ...metrics.Collector) { + if len(d) == 0 { + return + } + + collectorsLock.Lock() + defer collectorsLock.Unlock() + + collectors = append(collectors, d...) +} + func Descriptions(c metrics.PushDescription) { descriptionsLock.Lock() defer descriptionsLock.Unlock() c.Push(descriptions...) } + +func Collectors(c metrics.PushMetric) { + collectorsLock.Lock() + defer collectorsLock.Unlock() + + for _, collector := range collectors { + collector.CollectMetrics(c) + } +} diff --git a/pkg/operatorV2/operator_worker.go b/pkg/operatorV2/operator_worker.go index aac85d0f0..30f6f72f2 100644 --- a/pkg/operatorV2/operator_worker.go +++ b/pkg/operatorV2/operator_worker.go @@ -25,6 +25,7 @@ import ( "fmt" "runtime/debug" + "github.com/arangodb/kube-arangodb/pkg/generated/metric_descriptions" "github.com/arangodb/kube-arangodb/pkg/operatorV2/operation" "github.com/arangodb/kube-arangodb/pkg/util/errors" "github.com/arangodb/kube-arangodb/pkg/util/globals" @@ -101,7 +102,7 @@ func (o *operator) processObject(obj interface{}) error { return nil } - o.objectProcessed.Inc() + metric_descriptions.ArangoOperatorObjectsProcessedInc(o.operator.name) loggerWorker.Trace("Received Item Action: %s, Type: %s/%s/%s, Namespace: %s, Name: %s", item.Operation, diff --git a/pkg/operatorV2/prometheus.go b/pkg/operatorV2/prometheus.go index 8bef923e6..904c84041 100644 --- a/pkg/operatorV2/prometheus.go +++ b/pkg/operatorV2/prometheus.go @@ -1,7 +1,7 @@ // // DISCLAIMER // -// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany +// Copyright 2016-2024 ArangoDB GmbH, Cologne, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -26,28 +26,16 @@ import ( type prometheusMetrics struct { operator *operator - - objectProcessed prometheus.Counter } func newCollector(operator *operator) *prometheusMetrics { return &prometheusMetrics{ operator: operator, - - objectProcessed: prometheus.NewCounter(prometheus.CounterOpts{ - Name: "arango_operator_objects_processed", - Help: "Count of the processed objects", - ConstLabels: map[string]string{ - "operator_name": operator.name, - }, - }), } } func (p *prometheusMetrics) connectors() []prometheus.Collector { - return []prometheus.Collector{ - p.objectProcessed, - } + return []prometheus.Collector{} } func (p *prometheusMetrics) Describe(r chan<- *prometheus.Desc) {