1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

[Feature] Global Metrics (#1668)

This commit is contained in:
Adam Janikowski 2024-05-21 14:09:50 +02:00 committed by GitHub
parent a571a19cdc
commit ebc4b6786f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
77 changed files with 1762 additions and 67 deletions

View file

@ -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

View file

@ -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/...

View file

@ -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 |

View file

@ -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 |

View file

@ -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
}
}

View file

@ -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)
}
}

View file

@ -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 }})
}
}
{{- end }}

View file

@ -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 }}

View file

@ -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:

View file

@ -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()))

View file

@ -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
}

View file

@ -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)
})
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)

View file

@ -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()
}

View file

@ -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)
}
}

View file

@ -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,

View file

@ -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) {