mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[Improvement] Improve metric handling (#1728)
This commit is contained in:
parent
ae663eaf9d
commit
bda998564b
83 changed files with 6060 additions and 360 deletions
|
@ -32,6 +32,7 @@
|
||||||
- (Bugfix) Versioning Alignment
|
- (Bugfix) Versioning Alignment
|
||||||
- (Feature) (Scheduler) Merge Strategy
|
- (Feature) (Scheduler) Merge Strategy
|
||||||
- (Feature) (Networking) Endpoints Destination
|
- (Feature) (Networking) Endpoints Destination
|
||||||
|
- (Improvement) Improve Metrics Handling
|
||||||
|
|
||||||
## [1.2.42](https://github.com/arangodb/kube-arangodb/tree/1.2.42) (2024-07-23)
|
## [1.2.42](https://github.com/arangodb/kube-arangodb/tree/1.2.42) (2024-07-23)
|
||||||
- (Maintenance) Go 1.22.4 & Kubernetes 1.29.6 libraries
|
- (Maintenance) Go 1.22.4 & Kubernetes 1.29.6 libraries
|
||||||
|
|
|
@ -12,39 +12,41 @@ has_toc: false
|
||||||
|
|
||||||
[START_INJECT]: # (metricsTable)
|
[START_INJECT]: # (metricsTable)
|
||||||
|
|
||||||
| Name | Namespace | Group | Type | Description |
|
| 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_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_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 |
|
||||||
| [arangodb_operator_agency_index](./arangodb_operator_agency_index.md) | arangodb_operator | agency | Gauge | Current index of the agency cache |
|
| [arangodb_operator_agency_cache_health_present](./arangodb_operator_agency_cache_health_present.md) | arangodb_operator | agency_cache | Gauge | Determines if local agency cache health is present |
|
||||||
| [arangodb_operator_agency_cache_health_present](./arangodb_operator_agency_cache_health_present.md) | arangodb_operator | agency_cache | Gauge | Determines if local agency cache health is present |
|
| [arangodb_operator_agency_cache_healthy](./arangodb_operator_agency_cache_healthy.md) | arangodb_operator | agency_cache | Gauge | Determines if agency is healthy |
|
||||||
| [arangodb_operator_agency_cache_healthy](./arangodb_operator_agency_cache_healthy.md) | arangodb_operator | agency_cache | Gauge | Determines if agency is healthy |
|
| [arangodb_operator_agency_cache_leaders](./arangodb_operator_agency_cache_leaders.md) | arangodb_operator | agency_cache | Gauge | Determines agency leader vote count |
|
||||||
| [arangodb_operator_agency_cache_leaders](./arangodb_operator_agency_cache_leaders.md) | arangodb_operator | agency_cache | Gauge | Determines agency leader vote count |
|
| [arangodb_operator_agency_cache_member_commit_offset](./arangodb_operator_agency_cache_member_commit_offset.md) | arangodb_operator | agency_cache | Gauge | Determines agency member commit offset |
|
||||||
| [arangodb_operator_agency_cache_member_commit_offset](./arangodb_operator_agency_cache_member_commit_offset.md) | arangodb_operator | agency_cache | Gauge | Determines agency member commit offset |
|
| [arangodb_operator_agency_cache_member_serving](./arangodb_operator_agency_cache_member_serving.md) | arangodb_operator | agency_cache | Gauge | Determines if agency member is reachable |
|
||||||
| [arangodb_operator_agency_cache_member_serving](./arangodb_operator_agency_cache_member_serving.md) | arangodb_operator | agency_cache | Gauge | Determines if agency member is reachable |
|
| [arangodb_operator_agency_cache_present](./arangodb_operator_agency_cache_present.md) | arangodb_operator | agency_cache | Gauge | Determines if local agency cache is present |
|
||||||
| [arangodb_operator_agency_cache_present](./arangodb_operator_agency_cache_present.md) | arangodb_operator | agency_cache | Gauge | Determines if local agency cache is present |
|
| [arangodb_operator_agency_cache_serving](./arangodb_operator_agency_cache_serving.md) | arangodb_operator | agency_cache | Gauge | Determines if agency is serving |
|
||||||
| [arangodb_operator_agency_cache_serving](./arangodb_operator_agency_cache_serving.md) | arangodb_operator | agency_cache | Gauge | Determines if agency is serving |
|
| [arangodb_operator_deployment_conditions](./arangodb_operator_deployment_conditions.md) | arangodb_operator | deployment | Gauge | Representation of the ArangoDeployment condition state (true/false) |
|
||||||
| [arangodb_operator_deployment_conditions](./arangodb_operator_deployment_conditions.md) | arangodb_operator | deployment | Gauge | Representation of the ArangoDeployment condition state (true/false) |
|
| [arangodb_operator_engine_assertions](./arangodb_operator_engine_assertions.md) | arangodb_operator | engine | Counter | Number of assertions invoked during Operator runtime |
|
||||||
| [arangodb_operator_engine_assertions](./arangodb_operator_engine_assertions.md) | arangodb_operator | engine | Counter | Number of assertions invoked during Operator runtime |
|
| [arangodb_operator_engine_ops_alerts](./arangodb_operator_engine_ops_alerts.md) | arangodb_operator | engine | Counter | Counter for actions which requires ops attention |
|
||||||
| [arangodb_operator_engine_ops_alerts](./arangodb_operator_engine_ops_alerts.md) | arangodb_operator | engine | Counter | Counter for actions which requires ops attention |
|
| [arangodb_operator_engine_panics_recovered](./arangodb_operator_engine_panics_recovered.md) | arangodb_operator | engine | Counter | Number of Panics recovered inside Operator reconciliation loop |
|
||||||
| [arangodb_operator_engine_panics_recovered](./arangodb_operator_engine_panics_recovered.md) | arangodb_operator | engine | Counter | Number of Panics recovered inside Operator reconciliation loop |
|
| [arangodb_operator_kubernetes_client_request_errors](./arangodb_operator_kubernetes_client_request_errors.md) | arangodb_operator | kubernetes_client | Counter | Number of Kubernetes Client request errors |
|
||||||
| [arangodb_operator_kubernetes_client_request_errors](./arangodb_operator_kubernetes_client_request_errors.md) | arangodb_operator | kubernetes_client | Counter | Number of Kubernetes Client request errors |
|
| [arangodb_operator_kubernetes_client_requests](./arangodb_operator_kubernetes_client_requests.md) | arangodb_operator | kubernetes_client | Counter | Number of Kubernetes Client requests |
|
||||||
| [arangodb_operator_kubernetes_client_requests](./arangodb_operator_kubernetes_client_requests.md) | arangodb_operator | kubernetes_client | Counter | Number of Kubernetes Client requests |
|
| [arangodb_operator_members_conditions](./arangodb_operator_members_conditions.md) | arangodb_operator | members | Gauge | Representation of the ArangoMember condition state (true/false) |
|
||||||
| [arangodb_operator_members_conditions](./arangodb_operator_members_conditions.md) | arangodb_operator | members | Gauge | Representation of the ArangoMember condition state (true/false) |
|
| [arangodb_operator_members_unexpected_container_exit_codes](./arangodb_operator_members_unexpected_container_exit_codes.md) | arangodb_operator | members | Counter | Counter of unexpected restarts in pod (Containers/InitContainers/EphemeralContainers) |
|
||||||
| [arangodb_operator_members_unexpected_container_exit_codes](./arangodb_operator_members_unexpected_container_exit_codes.md) | arangodb_operator | members | Counter | Counter of unexpected restarts in pod (Containers/InitContainers/EphemeralContainers) |
|
| [arangodb_operator_objects_processed](./arangodb_operator_objects_processed.md) | arangodb_operator | objects | Counter | Number of the processed objects |
|
||||||
| [arangodb_operator_rebalancer_enabled](./arangodb_operator_rebalancer_enabled.md) | arangodb_operator | rebalancer | Gauge | Determines if rebalancer is enabled |
|
| [arangodb_operator_rebalancer_enabled](./arangodb_operator_rebalancer_enabled.md) | arangodb_operator | rebalancer | Gauge | Determines if rebalancer is enabled |
|
||||||
| [arangodb_operator_rebalancer_moves_current](./arangodb_operator_rebalancer_moves_current.md) | arangodb_operator | rebalancer | Gauge | Define how many moves are currently in progress |
|
| [arangodb_operator_rebalancer_moves_current](./arangodb_operator_rebalancer_moves_current.md) | arangodb_operator | rebalancer | Gauge | Define how many moves are currently in progress |
|
||||||
| [arangodb_operator_rebalancer_moves_failed](./arangodb_operator_rebalancer_moves_failed.md) | arangodb_operator | rebalancer | Counter | Define how many moves failed |
|
| [arangodb_operator_rebalancer_moves_failed](./arangodb_operator_rebalancer_moves_failed.md) | arangodb_operator | rebalancer | Counter | Define how many moves failed |
|
||||||
| [arangodb_operator_rebalancer_moves_generated](./arangodb_operator_rebalancer_moves_generated.md) | arangodb_operator | rebalancer | Counter | Define how many moves were generated |
|
| [arangodb_operator_rebalancer_moves_generated](./arangodb_operator_rebalancer_moves_generated.md) | arangodb_operator | rebalancer | Counter | Define how many moves were generated |
|
||||||
| [arangodb_operator_rebalancer_moves_succeeded](./arangodb_operator_rebalancer_moves_succeeded.md) | arangodb_operator | rebalancer | Counter | Define how many moves succeeded |
|
| [arangodb_operator_rebalancer_moves_succeeded](./arangodb_operator_rebalancer_moves_succeeded.md) | arangodb_operator | rebalancer | Counter | Define how many moves succeeded |
|
||||||
| [arangodb_operator_resources_arangodeployment_accepted](./arangodb_operator_resources_arangodeployment_accepted.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment has been accepted |
|
| [arangodb_operator_resources_arangodeployment_accepted](./arangodb_operator_resources_arangodeployment_accepted.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment has been accepted |
|
||||||
| [arangodb_operator_resources_arangodeployment_immutable_errors](./arangodb_operator_resources_arangodeployment_immutable_errors.md) | arangodb_operator | resources | Counter | Counter for deployment immutable errors |
|
| [arangodb_operator_resources_arangodeployment_immutable_errors](./arangodb_operator_resources_arangodeployment_immutable_errors.md) | arangodb_operator | resources | Counter | Counter for deployment immutable errors |
|
||||||
| [arangodb_operator_resources_arangodeployment_propagated](./arangodb_operator_resources_arangodeployment_propagated.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment Spec is propagated |
|
| [arangodb_operator_resources_arangodeployment_propagated](./arangodb_operator_resources_arangodeployment_propagated.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment Spec is propagated |
|
||||||
| [arangodb_operator_resources_arangodeployment_status_restores](./arangodb_operator_resources_arangodeployment_status_restores.md) | arangodb_operator | resources | Counter | Counter for deployment status restored |
|
| [arangodb_operator_resources_arangodeployment_status_restores](./arangodb_operator_resources_arangodeployment_status_restores.md) | arangodb_operator | resources | Counter | Counter for deployment status restored |
|
||||||
| [arangodb_operator_resources_arangodeployment_uptodate](./arangodb_operator_resources_arangodeployment_uptodate.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment is uptodate |
|
| [arangodb_operator_resources_arangodeployment_uptodate](./arangodb_operator_resources_arangodeployment_uptodate.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeployment is uptodate |
|
||||||
| [arangodb_operator_resources_arangodeployment_validation_errors](./arangodb_operator_resources_arangodeployment_validation_errors.md) | arangodb_operator | resources | Counter | Counter for deployment validation errors |
|
| [arangodb_operator_resources_arangodeployment_validation_errors](./arangodb_operator_resources_arangodeployment_validation_errors.md) | arangodb_operator | resources | Counter | Counter for deployment validation errors |
|
||||||
| [arangodb_operator_resources_arangodeploymentreplication_active](./arangodb_operator_resources_arangodeploymentreplication_active.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeploymentReplication is configured and running |
|
| [arangodb_operator_resources_arangodeploymentreplication_active](./arangodb_operator_resources_arangodeploymentreplication_active.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeploymentReplication is configured and running |
|
||||||
| [arangodb_operator_resources_arangodeploymentreplication_failed](./arangodb_operator_resources_arangodeploymentreplication_failed.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeploymentReplication is in Failed phase |
|
| [arangodb_operator_resources_arangodeploymentreplication_failed](./arangodb_operator_resources_arangodeploymentreplication_failed.md) | arangodb_operator | resources | Gauge | Defines if ArangoDeploymentReplication is in Failed phase |
|
||||||
|
| [arangodb_resources_deployment_config_map_duration](./arangodb_resources_deployment_config_map_duration.md) | arangodb_resources | deployment_config_map | Gauge | Duration of inspected ConfigMaps by Deployment in seconds |
|
||||||
|
| [arangodb_resources_deployment_config_map_inspected](./arangodb_resources_deployment_config_map_inspected.md) | arangodb_resources | deployment_config_map | Counter | Number of inspected ConfigMaps by Deployment |
|
||||||
|
|
||||||
[END_INJECT]: # (metricsTable)
|
[END_INJECT]: # (metricsTable)
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
layout: page
|
||||||
|
title: arangodb_operator_objects_processed
|
||||||
|
parent: List of available metrics
|
||||||
|
---
|
||||||
|
|
||||||
|
# arangodb_operator_objects_processed (Counter)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Number of the processed objects
|
||||||
|
|
||||||
|
## Labels
|
||||||
|
|
||||||
|
| Label | Description |
|
||||||
|
|:-------------:|:--------------|
|
||||||
|
| operator_name | Operator Name |
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
layout: page
|
||||||
|
title: arangodb_resources_deployment_config_map_duration
|
||||||
|
parent: List of available metrics
|
||||||
|
---
|
||||||
|
|
||||||
|
# arangodb_resources_deployment_config_map_duration (Gauge)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Duration of inspected ConfigMaps by Deployment in seconds
|
||||||
|
|
||||||
|
## Labels
|
||||||
|
|
||||||
|
| Label | Description |
|
||||||
|
|:----------:|:----------------|
|
||||||
|
| deployment | Deployment Name |
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
layout: page
|
||||||
|
title: arangodb_resources_deployment_config_map_inspected
|
||||||
|
parent: List of available metrics
|
||||||
|
---
|
||||||
|
|
||||||
|
# arangodb_resources_deployment_config_map_inspected (Counter)
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
Number of inspected ConfigMaps by Deployment
|
||||||
|
|
||||||
|
## Labels
|
||||||
|
|
||||||
|
| Label | Description |
|
||||||
|
|:----------:|:----------------|
|
||||||
|
| deployment | Deployment Name |
|
|
@ -361,12 +361,12 @@ func generateMetricsGO(root string, in MetricsDoc) error {
|
||||||
"fname": strings.Join(fnameParts, ""),
|
"fname": strings.Join(fnameParts, ""),
|
||||||
"ename": strings.Join(tparts, ""),
|
"ename": strings.Join(tparts, ""),
|
||||||
"shortDescription": details.ShortDescription,
|
"shortDescription": details.ShortDescription,
|
||||||
"global": details.Global,
|
|
||||||
"labels": generateLabels(details.Labels),
|
"labels": generateLabels(details.Labels),
|
||||||
"type": details.Type,
|
"type": details.Type,
|
||||||
"mapTypes": mapTypes,
|
"mapTypes": mapTypes,
|
||||||
"mapKeys": mapKeys,
|
"mapKeys": mapKeys,
|
||||||
"mapIKeys": mapIKeys,
|
"mapIKeys": mapIKeys,
|
||||||
|
"global": details.Global,
|
||||||
"args": strings.Join(params[1:], ", "),
|
"args": strings.Join(params[1:], ", "),
|
||||||
"fparams": strings.Join(params, ", "),
|
"fparams": strings.Join(params, ", "),
|
||||||
"fkeys": strings.Join(keys, ", "),
|
"fkeys": strings.Join(keys, ", "),
|
||||||
|
|
|
@ -23,154 +23,61 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
{{- if .global }}
|
|
||||||
|
|
||||||
"sync"
|
|
||||||
{{- end }}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
{{ .fname }} = metrics.NewDescription("{{ .name }}", "{{ .shortDescription }}", {{ .labels }}, nil)
|
{{ .fname }} = metrics.NewDescription("{{ .name }}", "{{ .shortDescription }}", {{ .labels }}, nil)
|
||||||
|
{{- if .global }}
|
||||||
|
|
||||||
|
// Global Fields
|
||||||
|
global{{ .ename }}{{ .type }} = New{{ .ename }}{{ .type }}Factory()
|
||||||
|
{{- end }}
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
registerDescription({{ .fname }})
|
registerDescription({{ .fname }})
|
||||||
{{- if .global }}
|
{{- if .global }}
|
||||||
registerCollector({{ .fname }}Global)
|
registerCollector(global{{ .ename }}{{ .type }})
|
||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
|
{{- if .global }}
|
||||||
|
|
||||||
|
func Global{{ .ename }}{{ .type }}() metrics.Factory{{ .type }}[{{ .ename }}Input] {
|
||||||
|
return global{{ .ename }}{{ .type }}
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
|
||||||
|
func New{{ .ename }}{{ .type }}Factory() metrics.Factory{{ .type }}[{{ .ename }}Input] {
|
||||||
|
return metrics.NewFactory{{ .type }}[{{ .ename }}Input]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func New{{ .ename }}Input({{- range $i, $e := .mapKeys }}{{ if $i }}, {{ end }}{{ index $root.mapIKeys . }} {{ index $root.mapTypes . }}{{- end }}) {{ .ename }}Input {
|
||||||
|
return {{ .ename }}Input{
|
||||||
|
{{- range .mapKeys }}
|
||||||
|
{{ . }}: {{ index $root.mapIKeys . }},
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type {{ .ename }}Input struct {
|
||||||
|
{{- range .mapKeys }}
|
||||||
|
{{ . }} {{ index $root.mapTypes . }} `json:"{{ index $root.mapIKeys . }}"`
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i {{ .ename }}Input) {{ .type }}(value float64) metrics.Metric {
|
||||||
|
return {{ .ename }}{{ .type }}(value {{- range .mapKeys }}, i.{{ . }}{{- end }})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i {{ .ename }}Input) Desc() metrics.Description {
|
||||||
|
return {{ .ename }}()
|
||||||
|
}
|
||||||
|
|
||||||
func {{ .ename }}() metrics.Description {
|
func {{ .ename }}() metrics.Description {
|
||||||
return {{ .fname }}
|
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 {
|
func {{ .ename }}{{ .type }}({{ .fparams }}) metrics.Metric {
|
||||||
return {{ .ename }}().{{ .type }}({{ .fkeys }})
|
return {{ .ename }}().{{ .type }}({{ .fkeys }})
|
||||||
}
|
}
|
||||||
{{- end }}
|
|
||||||
|
|
|
@ -23,28 +23,24 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
{{- if .global }}
|
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
{{- end }}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_{{ .ename }}_Descriptor(t *testing.T) {
|
func Test_{{ .ename }}_Descriptor(t *testing.T) {
|
||||||
{{ .ename }}()
|
{{ .ename }}()
|
||||||
}
|
}
|
||||||
|
|
||||||
{{- if .global }}
|
func Test_{{ .ename }}_Factory(t *testing.T) {
|
||||||
|
global := New{{ .ename }}{{ .type }}Factory()
|
||||||
|
|
||||||
func Test_{{ .ename }}_Global(t *testing.T) {
|
object1 := {{ .ename }}Input{
|
||||||
global := Get{{ .ename }}Factory()
|
|
||||||
|
|
||||||
object1 := {{ .ename }}Item{
|
|
||||||
{{- range $i, $field := .mapKeys }}
|
{{- range $i, $field := .mapKeys }}
|
||||||
{{ $field }}: "1",
|
{{ $field }}: "1",
|
||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
object2 := {{ .ename }}Item{
|
object2 := {{ .ename }}Input{
|
||||||
{{- range $i, $field := .mapKeys }}
|
{{- range $i, $field := .mapKeys }}
|
||||||
{{ $field }}: "2",
|
{{ $field }}: "2",
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -60,7 +56,7 @@ func Test_{{ .ename }}_Global(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Add", func(t *testing.T) {
|
t.Run("Add", func(t *testing.T) {
|
||||||
global.Add(10, object1)
|
global.Add(object1, 10)
|
||||||
|
|
||||||
require.EqualValues(t, 10, global.Get(object1))
|
require.EqualValues(t, 10, global.Get(object1))
|
||||||
require.EqualValues(t, 0, global.Get(object2))
|
require.EqualValues(t, 0, global.Get(object2))
|
||||||
|
@ -71,7 +67,7 @@ func Test_{{ .ename }}_Global(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Add", func(t *testing.T) {
|
t.Run("Add", func(t *testing.T) {
|
||||||
global.Add(3, object2)
|
global.Add(object2, 3)
|
||||||
|
|
||||||
require.EqualValues(t, 10, global.Get(object1))
|
require.EqualValues(t, 10, global.Get(object1))
|
||||||
require.EqualValues(t, 3, global.Get(object2))
|
require.EqualValues(t, 3, global.Get(object2))
|
||||||
|
@ -82,7 +78,7 @@ func Test_{{ .ename }}_Global(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Dec", func(t *testing.T) {
|
t.Run("Dec", func(t *testing.T) {
|
||||||
global.Add(-1, object1)
|
global.Add(object1, -1)
|
||||||
|
|
||||||
require.EqualValues(t, 9, global.Get(object1))
|
require.EqualValues(t, 9, global.Get(object1))
|
||||||
require.EqualValues(t, 3, global.Get(object2))
|
require.EqualValues(t, 3, global.Get(object2))
|
||||||
|
@ -127,16 +123,16 @@ func Test_{{ .ename }}_Global(t *testing.T) {
|
||||||
}
|
}
|
||||||
{{- if eq .type "Counter" }}
|
{{- if eq .type "Counter" }}
|
||||||
|
|
||||||
func Test_{{ .ename }}_Global_Counter(t *testing.T) {
|
func Test_{{ .ename }}_Factory_Counter(t *testing.T) {
|
||||||
global := Get{{ .ename }}Factory()
|
global := New{{ .ename }}{{ .type }}Factory()
|
||||||
|
|
||||||
object1 := {{ .ename }}Item{
|
object1 := {{ .ename }}Input{
|
||||||
{{- range $i, $field := .mapKeys }}
|
{{- range $i, $field := .mapKeys }}
|
||||||
{{ $field }}: "1",
|
{{ $field }}: "1",
|
||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
object2 := {{ .ename }}Item{
|
object2 := {{ .ename }}Input{
|
||||||
{{- range $i, $field := .mapKeys }}
|
{{- range $i, $field := .mapKeys }}
|
||||||
{{ $field }}: "2",
|
{{ $field }}: "2",
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
@ -152,7 +148,7 @@ func Test_{{ .ename }}_Global_Counter(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Add", func(t *testing.T) {
|
t.Run("Add", func(t *testing.T) {
|
||||||
global.Add(10, object1)
|
global.Add(object1, 10)
|
||||||
|
|
||||||
require.EqualValues(t, 10, global.Get(object1))
|
require.EqualValues(t, 10, global.Get(object1))
|
||||||
require.EqualValues(t, 0, global.Get(object2))
|
require.EqualValues(t, 0, global.Get(object2))
|
||||||
|
@ -175,5 +171,54 @@ func Test_{{ .ename }}_Global_Counter(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if eq .type "Gauge" }}
|
||||||
|
|
||||||
|
func Test_{{ .ename }}_Factory_Gauge(t *testing.T) {
|
||||||
|
global := New{{ .ename }}{{ .type }}Factory()
|
||||||
|
|
||||||
|
object1 := {{ .ename }}Input{
|
||||||
|
{{- range $i, $field := .mapKeys }}
|
||||||
|
{{ $field }}: "1",
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := {{ .ename }}Input{
|
||||||
|
{{- 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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,25 @@
|
||||||
documentation: docs/generated/metrics
|
documentation: docs/generated/metrics
|
||||||
destination: pkg/generated/metric_descriptions
|
destination: pkg/generated/metric_descriptions
|
||||||
namespaces:
|
namespaces:
|
||||||
arango_operator:
|
arangodb_resources:
|
||||||
|
deployment_config_map:
|
||||||
|
inspected:
|
||||||
|
shortDescription: "Number of inspected ConfigMaps by Deployment"
|
||||||
|
description: "Number of inspected ConfigMaps by Deployment"
|
||||||
|
type: "Counter"
|
||||||
|
global: true
|
||||||
|
labels:
|
||||||
|
- key: deployment
|
||||||
|
description: "Deployment Name"
|
||||||
|
duration:
|
||||||
|
shortDescription: "Duration of inspected ConfigMaps by Deployment in seconds"
|
||||||
|
description: "Duration of inspected ConfigMaps by Deployment in seconds"
|
||||||
|
type: "Gauge"
|
||||||
|
global: true
|
||||||
|
labels:
|
||||||
|
- key: deployment
|
||||||
|
description: "Deployment Name"
|
||||||
|
arangodb_operator:
|
||||||
objects:
|
objects:
|
||||||
processed:
|
processed:
|
||||||
shortDescription: "Number of the processed objects"
|
shortDescription: "Number of the processed objects"
|
||||||
|
@ -11,7 +29,6 @@ namespaces:
|
||||||
labels:
|
labels:
|
||||||
- key: operator_name
|
- key: operator_name
|
||||||
description: "Operator Name"
|
description: "Operator Name"
|
||||||
arangodb_operator:
|
|
||||||
agency_cache:
|
agency_cache:
|
||||||
present:
|
present:
|
||||||
shortDescription: "Determines if local agency cache is present"
|
shortDescription: "Determines if local agency cache is present"
|
||||||
|
|
|
@ -22,35 +22,28 @@ package resources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
|
"github.com/arangodb/kube-arangodb/pkg/deployment/features"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/metrics"
|
"github.com/arangodb/kube-arangodb/pkg/generated/metric_descriptions"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
"github.com/arangodb/kube-arangodb/pkg/util/errors"
|
||||||
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
|
||||||
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
|
inspectorInterface "github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector"
|
||||||
)
|
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
|
|
||||||
var (
|
|
||||||
inspectedConfigMapsCounters = metrics.MustRegisterCounterVec(metricsComponent, "inspected_config_maps", "Number of ConfigMaps inspections per deployment", metrics.DeploymentName)
|
|
||||||
inspectConfigMapsDurationGauges = metrics.MustRegisterGaugeVec(metricsComponent, "inspect_config_maps_duration", "Amount of time taken by a single inspection of all ConfigMaps for a deployment (in sec)", metrics.DeploymentName)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// EnsureConfigMaps creates all ConfigMaps needed to run the given deployment
|
// EnsureConfigMaps creates all ConfigMaps needed to run the given deployment
|
||||||
func (r *Resources) EnsureConfigMaps(ctx context.Context, cachedStatus inspectorInterface.Inspector) error {
|
func (r *Resources) EnsureConfigMaps(ctx context.Context, cachedStatus inspectorInterface.Inspector) error {
|
||||||
start := time.Now()
|
|
||||||
spec := r.context.GetSpec()
|
spec := r.context.GetSpec()
|
||||||
configMaps := cachedStatus.ConfigMapsModInterface().V1()
|
configMaps := cachedStatus.ConfigMapsModInterface().V1()
|
||||||
apiObject := r.context.GetAPIObject()
|
apiObject := r.context.GetAPIObject()
|
||||||
deploymentName := apiObject.GetName()
|
deploymentName := apiObject.GetName()
|
||||||
|
|
||||||
defer metrics.SetDuration(inspectConfigMapsDurationGauges.WithLabelValues(deploymentName), start)
|
defer metrics.WithDuration(metric_descriptions.GlobalArangodbResourcesDeploymentConfigMapDurationGauge(), metric_descriptions.NewArangodbResourcesDeploymentConfigMapDurationInput(deploymentName))
|
||||||
counterMetric := inspectedConfigMapsCounters.WithLabelValues(deploymentName)
|
|
||||||
|
|
||||||
reconcileRequired := k8sutil.NewReconcile(cachedStatus)
|
reconcileRequired := k8sutil.NewReconcile(cachedStatus)
|
||||||
|
|
||||||
if features.IsGatewayEnabled(spec) {
|
if features.IsGatewayEnabled(spec) {
|
||||||
counterMetric.Inc()
|
metric_descriptions.GlobalArangodbResourcesDeploymentConfigMapInspectedCounter().Inc(metric_descriptions.NewArangodbResourcesDeploymentConfigMapInspectedInput(deploymentName))
|
||||||
if err := reconcileRequired.WithError(r.ensureGatewayConfig(ctx, cachedStatus, configMaps)); err != nil {
|
if err := reconcileRequired.WithError(r.ensureGatewayConfig(ctx, cachedStatus, configMaps)); err != nil {
|
||||||
return errors.Section(err, "Gateway ConfigMap")
|
return errors.Section(err, "Gateway ConfigMap")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,149 +0,0 @@
|
||||||
//
|
|
||||||
// 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
|
|
||||||
}
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyCacheHealthPresent)
|
registerDescription(arangodbOperatorAgencyCacheHealthPresent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheHealthPresentGaugeFactory() metrics.FactoryGauge[ArangodbOperatorAgencyCacheHealthPresentInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorAgencyCacheHealthPresentInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheHealthPresentInput(namespace string, name string) ArangodbOperatorAgencyCacheHealthPresentInput {
|
||||||
|
return ArangodbOperatorAgencyCacheHealthPresentInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyCacheHealthPresentInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheHealthPresentInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyCacheHealthPresentGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheHealthPresentInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyCacheHealthPresent()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyCacheHealthPresent() metrics.Description {
|
func ArangodbOperatorAgencyCacheHealthPresent() metrics.Description {
|
||||||
return arangodbOperatorAgencyCacheHealthPresent
|
return arangodbOperatorAgencyCacheHealthPresent
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyCacheHealthPresent_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyCacheHealthPresent_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyCacheHealthPresent()
|
ArangodbOperatorAgencyCacheHealthPresent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyCacheHealthPresent_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheHealthPresentGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheHealthPresentInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheHealthPresentInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyCacheHealthPresent_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheHealthPresentGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheHealthPresentInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheHealthPresentInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyCacheHealthy)
|
registerDescription(arangodbOperatorAgencyCacheHealthy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheHealthyGaugeFactory() metrics.FactoryGauge[ArangodbOperatorAgencyCacheHealthyInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorAgencyCacheHealthyInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheHealthyInput(namespace string, name string) ArangodbOperatorAgencyCacheHealthyInput {
|
||||||
|
return ArangodbOperatorAgencyCacheHealthyInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyCacheHealthyInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheHealthyInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyCacheHealthyGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheHealthyInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyCacheHealthy()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyCacheHealthy() metrics.Description {
|
func ArangodbOperatorAgencyCacheHealthy() metrics.Description {
|
||||||
return arangodbOperatorAgencyCacheHealthy
|
return arangodbOperatorAgencyCacheHealthy
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyCacheHealthy_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyCacheHealthy_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyCacheHealthy()
|
ArangodbOperatorAgencyCacheHealthy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyCacheHealthy_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheHealthyGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheHealthyInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheHealthyInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyCacheHealthy_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheHealthyGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheHealthyInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheHealthyInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,32 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyCacheLeaders)
|
registerDescription(arangodbOperatorAgencyCacheLeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheLeadersGaugeFactory() metrics.FactoryGauge[ArangodbOperatorAgencyCacheLeadersInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorAgencyCacheLeadersInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheLeadersInput(namespace string, name string, agent string) ArangodbOperatorAgencyCacheLeadersInput {
|
||||||
|
return ArangodbOperatorAgencyCacheLeadersInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
Agent: agent,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyCacheLeadersInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Agent string `json:"agent"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheLeadersInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyCacheLeadersGauge(value, i.Namespace, i.Name, i.Agent)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheLeadersInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyCacheLeaders()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyCacheLeaders() metrics.Description {
|
func ArangodbOperatorAgencyCacheLeaders() metrics.Description {
|
||||||
return arangodbOperatorAgencyCacheLeaders
|
return arangodbOperatorAgencyCacheLeaders
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,149 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyCacheLeaders_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyCacheLeaders_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyCacheLeaders()
|
ArangodbOperatorAgencyCacheLeaders()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyCacheLeaders_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheLeadersGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheLeadersInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Agent: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheLeadersInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Agent: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyCacheLeaders_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheLeadersGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheLeadersInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Agent: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheLeadersInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Agent: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,32 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyCacheMemberCommitOffset)
|
registerDescription(arangodbOperatorAgencyCacheMemberCommitOffset)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheMemberCommitOffsetGaugeFactory() metrics.FactoryGauge[ArangodbOperatorAgencyCacheMemberCommitOffsetInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorAgencyCacheMemberCommitOffsetInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheMemberCommitOffsetInput(namespace string, name string, agent string) ArangodbOperatorAgencyCacheMemberCommitOffsetInput {
|
||||||
|
return ArangodbOperatorAgencyCacheMemberCommitOffsetInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
Agent: agent,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyCacheMemberCommitOffsetInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Agent string `json:"agent"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheMemberCommitOffsetInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyCacheMemberCommitOffsetGauge(value, i.Namespace, i.Name, i.Agent)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheMemberCommitOffsetInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyCacheMemberCommitOffset()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyCacheMemberCommitOffset() metrics.Description {
|
func ArangodbOperatorAgencyCacheMemberCommitOffset() metrics.Description {
|
||||||
return arangodbOperatorAgencyCacheMemberCommitOffset
|
return arangodbOperatorAgencyCacheMemberCommitOffset
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,149 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyCacheMemberCommitOffset_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyCacheMemberCommitOffset_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyCacheMemberCommitOffset()
|
ArangodbOperatorAgencyCacheMemberCommitOffset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyCacheMemberCommitOffset_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheMemberCommitOffsetGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheMemberCommitOffsetInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Agent: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheMemberCommitOffsetInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Agent: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyCacheMemberCommitOffset_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheMemberCommitOffsetGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheMemberCommitOffsetInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Agent: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheMemberCommitOffsetInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Agent: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,32 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyCacheMemberServing)
|
registerDescription(arangodbOperatorAgencyCacheMemberServing)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheMemberServingGaugeFactory() metrics.FactoryGauge[ArangodbOperatorAgencyCacheMemberServingInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorAgencyCacheMemberServingInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheMemberServingInput(namespace string, name string, agent string) ArangodbOperatorAgencyCacheMemberServingInput {
|
||||||
|
return ArangodbOperatorAgencyCacheMemberServingInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
Agent: agent,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyCacheMemberServingInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Agent string `json:"agent"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheMemberServingInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyCacheMemberServingGauge(value, i.Namespace, i.Name, i.Agent)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheMemberServingInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyCacheMemberServing()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyCacheMemberServing() metrics.Description {
|
func ArangodbOperatorAgencyCacheMemberServing() metrics.Description {
|
||||||
return arangodbOperatorAgencyCacheMemberServing
|
return arangodbOperatorAgencyCacheMemberServing
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,149 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyCacheMemberServing_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyCacheMemberServing_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyCacheMemberServing()
|
ArangodbOperatorAgencyCacheMemberServing()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyCacheMemberServing_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheMemberServingGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheMemberServingInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Agent: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheMemberServingInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Agent: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyCacheMemberServing_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheMemberServingGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheMemberServingInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Agent: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheMemberServingInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Agent: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyCachePresent)
|
registerDescription(arangodbOperatorAgencyCachePresent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCachePresentGaugeFactory() metrics.FactoryGauge[ArangodbOperatorAgencyCachePresentInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorAgencyCachePresentInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCachePresentInput(namespace string, name string) ArangodbOperatorAgencyCachePresentInput {
|
||||||
|
return ArangodbOperatorAgencyCachePresentInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyCachePresentInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCachePresentInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyCachePresentGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCachePresentInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyCachePresent()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyCachePresent() metrics.Description {
|
func ArangodbOperatorAgencyCachePresent() metrics.Description {
|
||||||
return arangodbOperatorAgencyCachePresent
|
return arangodbOperatorAgencyCachePresent
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyCachePresent_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyCachePresent_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyCachePresent()
|
ArangodbOperatorAgencyCachePresent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyCachePresent_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCachePresentGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCachePresentInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCachePresentInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyCachePresent_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCachePresentGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCachePresentInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCachePresentInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyCacheServing)
|
registerDescription(arangodbOperatorAgencyCacheServing)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheServingGaugeFactory() metrics.FactoryGauge[ArangodbOperatorAgencyCacheServingInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorAgencyCacheServingInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyCacheServingInput(namespace string, name string) ArangodbOperatorAgencyCacheServingInput {
|
||||||
|
return ArangodbOperatorAgencyCacheServingInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyCacheServingInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheServingInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyCacheServingGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyCacheServingInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyCacheServing()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyCacheServing() metrics.Description {
|
func ArangodbOperatorAgencyCacheServing() metrics.Description {
|
||||||
return arangodbOperatorAgencyCacheServing
|
return arangodbOperatorAgencyCacheServing
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyCacheServing_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyCacheServing_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyCacheServing()
|
ArangodbOperatorAgencyCacheServing()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyCacheServing_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheServingGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheServingInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheServingInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyCacheServing_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyCacheServingGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyCacheServingInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyCacheServingInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyErrors)
|
registerDescription(arangodbOperatorAgencyErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyErrorsCounterFactory() metrics.FactoryCounter[ArangodbOperatorAgencyErrorsInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorAgencyErrorsInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyErrorsInput(namespace string, name string) ArangodbOperatorAgencyErrorsInput {
|
||||||
|
return ArangodbOperatorAgencyErrorsInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyErrorsInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyErrorsInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyErrorsCounter(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyErrorsInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyErrors()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyErrors() metrics.Description {
|
func ArangodbOperatorAgencyErrors() metrics.Description {
|
||||||
return arangodbOperatorAgencyErrors
|
return arangodbOperatorAgencyErrors
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyErrors_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyErrors_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyErrors()
|
ArangodbOperatorAgencyErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyErrors_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyErrorsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyErrorsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyErrorsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyErrors_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyErrorsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyErrorsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyErrorsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyFetches)
|
registerDescription(arangodbOperatorAgencyFetches)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyFetchesCounterFactory() metrics.FactoryCounter[ArangodbOperatorAgencyFetchesInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorAgencyFetchesInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyFetchesInput(namespace string, name string) ArangodbOperatorAgencyFetchesInput {
|
||||||
|
return ArangodbOperatorAgencyFetchesInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyFetchesInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyFetchesInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyFetchesCounter(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyFetchesInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyFetches()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyFetches() metrics.Description {
|
func ArangodbOperatorAgencyFetches() metrics.Description {
|
||||||
return arangodbOperatorAgencyFetches
|
return arangodbOperatorAgencyFetches
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyFetches_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyFetches_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyFetches()
|
ArangodbOperatorAgencyFetches()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyFetches_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyFetchesCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyFetchesInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyFetchesInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyFetches_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyFetchesCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyFetchesInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyFetchesInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorAgencyIndex)
|
registerDescription(arangodbOperatorAgencyIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyIndexGaugeFactory() metrics.FactoryGauge[ArangodbOperatorAgencyIndexInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorAgencyIndexInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorAgencyIndexInput(namespace string, name string) ArangodbOperatorAgencyIndexInput {
|
||||||
|
return ArangodbOperatorAgencyIndexInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorAgencyIndexInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyIndexInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorAgencyIndexGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorAgencyIndexInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorAgencyIndex()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorAgencyIndex() metrics.Description {
|
func ArangodbOperatorAgencyIndex() metrics.Description {
|
||||||
return arangodbOperatorAgencyIndex
|
return arangodbOperatorAgencyIndex
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorAgencyIndex_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorAgencyIndex_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorAgencyIndex()
|
ArangodbOperatorAgencyIndex()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorAgencyIndex_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyIndexGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyIndexInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyIndexInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorAgencyIndex_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorAgencyIndexGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorAgencyIndexInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorAgencyIndexInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,32 @@ func init() {
|
||||||
registerDescription(arangodbOperatorDeploymentConditions)
|
registerDescription(arangodbOperatorDeploymentConditions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorDeploymentConditionsGaugeFactory() metrics.FactoryGauge[ArangodbOperatorDeploymentConditionsInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorDeploymentConditionsInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorDeploymentConditionsInput(namespace string, name string, condition string) ArangodbOperatorDeploymentConditionsInput {
|
||||||
|
return ArangodbOperatorDeploymentConditionsInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
Condition: condition,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorDeploymentConditionsInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Condition string `json:"condition"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorDeploymentConditionsInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorDeploymentConditionsGauge(value, i.Namespace, i.Name, i.Condition)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorDeploymentConditionsInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorDeploymentConditions()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorDeploymentConditions() metrics.Description {
|
func ArangodbOperatorDeploymentConditions() metrics.Description {
|
||||||
return arangodbOperatorDeploymentConditions
|
return arangodbOperatorDeploymentConditions
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,149 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorDeploymentConditions_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorDeploymentConditions_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorDeploymentConditions()
|
ArangodbOperatorDeploymentConditions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorDeploymentConditions_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorDeploymentConditionsGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorDeploymentConditionsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Condition: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorDeploymentConditionsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Condition: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorDeploymentConditions_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorDeploymentConditionsGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorDeploymentConditionsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Condition: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorDeploymentConditionsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Condition: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,28 @@ func init() {
|
||||||
registerDescription(arangodbOperatorEngineAssertions)
|
registerDescription(arangodbOperatorEngineAssertions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorEngineAssertionsCounterFactory() metrics.FactoryCounter[ArangodbOperatorEngineAssertionsInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorEngineAssertionsInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorEngineAssertionsInput(key string) ArangodbOperatorEngineAssertionsInput {
|
||||||
|
return ArangodbOperatorEngineAssertionsInput{
|
||||||
|
Key: key,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorEngineAssertionsInput struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorEngineAssertionsInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorEngineAssertionsCounter(value, i.Key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorEngineAssertionsInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorEngineAssertions()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorEngineAssertions() metrics.Description {
|
func ArangodbOperatorEngineAssertions() metrics.Description {
|
||||||
return arangodbOperatorEngineAssertions
|
return arangodbOperatorEngineAssertions
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,141 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorEngineAssertions_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorEngineAssertions_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorEngineAssertions()
|
ArangodbOperatorEngineAssertions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorEngineAssertions_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorEngineAssertionsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorEngineAssertionsInput{
|
||||||
|
Key: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorEngineAssertionsInput{
|
||||||
|
Key: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorEngineAssertions_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorEngineAssertionsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorEngineAssertionsInput{
|
||||||
|
Key: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorEngineAssertionsInput{
|
||||||
|
Key: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorEngineOpsAlerts)
|
registerDescription(arangodbOperatorEngineOpsAlerts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorEngineOpsAlertsCounterFactory() metrics.FactoryCounter[ArangodbOperatorEngineOpsAlertsInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorEngineOpsAlertsInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorEngineOpsAlertsInput(namespace string, name string) ArangodbOperatorEngineOpsAlertsInput {
|
||||||
|
return ArangodbOperatorEngineOpsAlertsInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorEngineOpsAlertsInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorEngineOpsAlertsInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorEngineOpsAlertsCounter(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorEngineOpsAlertsInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorEngineOpsAlerts()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorEngineOpsAlerts() metrics.Description {
|
func ArangodbOperatorEngineOpsAlerts() metrics.Description {
|
||||||
return arangodbOperatorEngineOpsAlerts
|
return arangodbOperatorEngineOpsAlerts
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorEngineOpsAlerts_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorEngineOpsAlerts_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorEngineOpsAlerts()
|
ArangodbOperatorEngineOpsAlerts()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorEngineOpsAlerts_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorEngineOpsAlertsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorEngineOpsAlertsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorEngineOpsAlertsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorEngineOpsAlerts_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorEngineOpsAlertsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorEngineOpsAlertsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorEngineOpsAlertsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,28 @@ func init() {
|
||||||
registerDescription(arangodbOperatorEnginePanicsRecovered)
|
registerDescription(arangodbOperatorEnginePanicsRecovered)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorEnginePanicsRecoveredCounterFactory() metrics.FactoryCounter[ArangodbOperatorEnginePanicsRecoveredInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorEnginePanicsRecoveredInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorEnginePanicsRecoveredInput(section string) ArangodbOperatorEnginePanicsRecoveredInput {
|
||||||
|
return ArangodbOperatorEnginePanicsRecoveredInput{
|
||||||
|
Section: section,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorEnginePanicsRecoveredInput struct {
|
||||||
|
Section string `json:"section"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorEnginePanicsRecoveredInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorEnginePanicsRecoveredCounter(value, i.Section)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorEnginePanicsRecoveredInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorEnginePanicsRecovered()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorEnginePanicsRecovered() metrics.Description {
|
func ArangodbOperatorEnginePanicsRecovered() metrics.Description {
|
||||||
return arangodbOperatorEnginePanicsRecovered
|
return arangodbOperatorEnginePanicsRecovered
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,141 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorEnginePanicsRecovered_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorEnginePanicsRecovered_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorEnginePanicsRecovered()
|
ArangodbOperatorEnginePanicsRecovered()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorEnginePanicsRecovered_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorEnginePanicsRecoveredCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorEnginePanicsRecoveredInput{
|
||||||
|
Section: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorEnginePanicsRecoveredInput{
|
||||||
|
Section: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorEnginePanicsRecovered_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorEnginePanicsRecoveredCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorEnginePanicsRecoveredInput{
|
||||||
|
Section: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorEnginePanicsRecoveredInput{
|
||||||
|
Section: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorKubernetesClientRequestErrors)
|
registerDescription(arangodbOperatorKubernetesClientRequestErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorKubernetesClientRequestErrorsCounterFactory() metrics.FactoryCounter[ArangodbOperatorKubernetesClientRequestErrorsInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorKubernetesClientRequestErrorsInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorKubernetesClientRequestErrorsInput(component string, verb string) ArangodbOperatorKubernetesClientRequestErrorsInput {
|
||||||
|
return ArangodbOperatorKubernetesClientRequestErrorsInput{
|
||||||
|
Component: component,
|
||||||
|
Verb: verb,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorKubernetesClientRequestErrorsInput struct {
|
||||||
|
Component string `json:"component"`
|
||||||
|
Verb string `json:"verb"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorKubernetesClientRequestErrorsInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorKubernetesClientRequestErrorsCounter(value, i.Component, i.Verb)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorKubernetesClientRequestErrorsInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorKubernetesClientRequestErrors()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorKubernetesClientRequestErrors() metrics.Description {
|
func ArangodbOperatorKubernetesClientRequestErrors() metrics.Description {
|
||||||
return arangodbOperatorKubernetesClientRequestErrors
|
return arangodbOperatorKubernetesClientRequestErrors
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorKubernetesClientRequestErrors_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorKubernetesClientRequestErrors_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorKubernetesClientRequestErrors()
|
ArangodbOperatorKubernetesClientRequestErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorKubernetesClientRequestErrors_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorKubernetesClientRequestErrorsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorKubernetesClientRequestErrorsInput{
|
||||||
|
Component: "1",
|
||||||
|
Verb: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorKubernetesClientRequestErrorsInput{
|
||||||
|
Component: "2",
|
||||||
|
Verb: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorKubernetesClientRequestErrors_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorKubernetesClientRequestErrorsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorKubernetesClientRequestErrorsInput{
|
||||||
|
Component: "1",
|
||||||
|
Verb: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorKubernetesClientRequestErrorsInput{
|
||||||
|
Component: "2",
|
||||||
|
Verb: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorKubernetesClientRequests)
|
registerDescription(arangodbOperatorKubernetesClientRequests)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorKubernetesClientRequestsCounterFactory() metrics.FactoryCounter[ArangodbOperatorKubernetesClientRequestsInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorKubernetesClientRequestsInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorKubernetesClientRequestsInput(component string, verb string) ArangodbOperatorKubernetesClientRequestsInput {
|
||||||
|
return ArangodbOperatorKubernetesClientRequestsInput{
|
||||||
|
Component: component,
|
||||||
|
Verb: verb,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorKubernetesClientRequestsInput struct {
|
||||||
|
Component string `json:"component"`
|
||||||
|
Verb string `json:"verb"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorKubernetesClientRequestsInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorKubernetesClientRequestsCounter(value, i.Component, i.Verb)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorKubernetesClientRequestsInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorKubernetesClientRequests()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorKubernetesClientRequests() metrics.Description {
|
func ArangodbOperatorKubernetesClientRequests() metrics.Description {
|
||||||
return arangodbOperatorKubernetesClientRequests
|
return arangodbOperatorKubernetesClientRequests
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorKubernetesClientRequests_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorKubernetesClientRequests_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorKubernetesClientRequests()
|
ArangodbOperatorKubernetesClientRequests()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorKubernetesClientRequests_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorKubernetesClientRequestsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorKubernetesClientRequestsInput{
|
||||||
|
Component: "1",
|
||||||
|
Verb: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorKubernetesClientRequestsInput{
|
||||||
|
Component: "2",
|
||||||
|
Verb: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorKubernetesClientRequests_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorKubernetesClientRequestsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorKubernetesClientRequestsInput{
|
||||||
|
Component: "1",
|
||||||
|
Verb: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorKubernetesClientRequestsInput{
|
||||||
|
Component: "2",
|
||||||
|
Verb: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,34 @@ func init() {
|
||||||
registerDescription(arangodbOperatorMembersConditions)
|
registerDescription(arangodbOperatorMembersConditions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorMembersConditionsGaugeFactory() metrics.FactoryGauge[ArangodbOperatorMembersConditionsInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorMembersConditionsInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorMembersConditionsInput(namespace string, name string, member string, condition string) ArangodbOperatorMembersConditionsInput {
|
||||||
|
return ArangodbOperatorMembersConditionsInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
Member: member,
|
||||||
|
Condition: condition,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorMembersConditionsInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Member string `json:"member"`
|
||||||
|
Condition string `json:"condition"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorMembersConditionsInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorMembersConditionsGauge(value, i.Namespace, i.Name, i.Member, i.Condition)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorMembersConditionsInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorMembersConditions()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorMembersConditions() metrics.Description {
|
func ArangodbOperatorMembersConditions() metrics.Description {
|
||||||
return arangodbOperatorMembersConditions
|
return arangodbOperatorMembersConditions
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,153 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorMembersConditions_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorMembersConditions_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorMembersConditions()
|
ArangodbOperatorMembersConditions()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorMembersConditions_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorMembersConditionsGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorMembersConditionsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Member: "1",
|
||||||
|
Condition: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorMembersConditionsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Member: "2",
|
||||||
|
Condition: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorMembersConditions_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorMembersConditionsGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorMembersConditionsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Member: "1",
|
||||||
|
Condition: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorMembersConditionsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Member: "2",
|
||||||
|
Condition: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,40 @@ func init() {
|
||||||
registerDescription(arangodbOperatorMembersUnexpectedContainerExitCodes)
|
registerDescription(arangodbOperatorMembersUnexpectedContainerExitCodes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorMembersUnexpectedContainerExitCodesCounterFactory() metrics.FactoryCounter[ArangodbOperatorMembersUnexpectedContainerExitCodesInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorMembersUnexpectedContainerExitCodesInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorMembersUnexpectedContainerExitCodesInput(namespace string, name string, member string, container string, containerType string, code string, reason string) ArangodbOperatorMembersUnexpectedContainerExitCodesInput {
|
||||||
|
return ArangodbOperatorMembersUnexpectedContainerExitCodesInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
Member: member,
|
||||||
|
Container: container,
|
||||||
|
ContainerType: containerType,
|
||||||
|
Code: code,
|
||||||
|
Reason: reason,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorMembersUnexpectedContainerExitCodesInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Member string `json:"member"`
|
||||||
|
Container string `json:"container"`
|
||||||
|
ContainerType string `json:"containerType"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Reason string `json:"reason"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorMembersUnexpectedContainerExitCodesInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorMembersUnexpectedContainerExitCodesCounter(value, i.Namespace, i.Name, i.Member, i.Container, i.ContainerType, i.Code, i.Reason)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorMembersUnexpectedContainerExitCodesInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorMembersUnexpectedContainerExitCodes()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorMembersUnexpectedContainerExitCodes() metrics.Description {
|
func ArangodbOperatorMembersUnexpectedContainerExitCodes() metrics.Description {
|
||||||
return arangodbOperatorMembersUnexpectedContainerExitCodes
|
return arangodbOperatorMembersUnexpectedContainerExitCodes
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,165 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorMembersUnexpectedContainerExitCodes_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorMembersUnexpectedContainerExitCodes_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorMembersUnexpectedContainerExitCodes()
|
ArangodbOperatorMembersUnexpectedContainerExitCodes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorMembersUnexpectedContainerExitCodes_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorMembersUnexpectedContainerExitCodesCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorMembersUnexpectedContainerExitCodesInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Member: "1",
|
||||||
|
Container: "1",
|
||||||
|
ContainerType: "1",
|
||||||
|
Code: "1",
|
||||||
|
Reason: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorMembersUnexpectedContainerExitCodesInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Member: "2",
|
||||||
|
Container: "2",
|
||||||
|
ContainerType: "2",
|
||||||
|
Code: "2",
|
||||||
|
Reason: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorMembersUnexpectedContainerExitCodes_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorMembersUnexpectedContainerExitCodesCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorMembersUnexpectedContainerExitCodesInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
Member: "1",
|
||||||
|
Container: "1",
|
||||||
|
ContainerType: "1",
|
||||||
|
Code: "1",
|
||||||
|
Reason: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorMembersUnexpectedContainerExitCodesInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "2",
|
||||||
|
Member: "2",
|
||||||
|
Container: "2",
|
||||||
|
ContainerType: "2",
|
||||||
|
Code: "2",
|
||||||
|
Reason: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
71
pkg/generated/metric_descriptions/arangodb_operator_objects_processed.go
generated
Normal file
71
pkg/generated/metric_descriptions/arangodb_operator_objects_processed.go
generated
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
//
|
||||||
|
// 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 (
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
arangodbOperatorObjectsProcessed = metrics.NewDescription("arangodb_operator_objects_processed", "Number of the processed objects", []string{`operator_name`}, nil)
|
||||||
|
|
||||||
|
// Global Fields
|
||||||
|
globalArangodbOperatorObjectsProcessedCounter = NewArangodbOperatorObjectsProcessedCounterFactory()
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerDescription(arangodbOperatorObjectsProcessed)
|
||||||
|
registerCollector(globalArangodbOperatorObjectsProcessedCounter)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GlobalArangodbOperatorObjectsProcessedCounter() metrics.FactoryCounter[ArangodbOperatorObjectsProcessedInput] {
|
||||||
|
return globalArangodbOperatorObjectsProcessedCounter
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorObjectsProcessedCounterFactory() metrics.FactoryCounter[ArangodbOperatorObjectsProcessedInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorObjectsProcessedInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorObjectsProcessedInput(operatorName string) ArangodbOperatorObjectsProcessedInput {
|
||||||
|
return ArangodbOperatorObjectsProcessedInput{
|
||||||
|
OperatorName: operatorName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorObjectsProcessedInput struct {
|
||||||
|
OperatorName string `json:"operatorName"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorObjectsProcessedInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorObjectsProcessedCounter(value, i.OperatorName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorObjectsProcessedInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorObjectsProcessed()
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbOperatorObjectsProcessed() metrics.Description {
|
||||||
|
return arangodbOperatorObjectsProcessed
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbOperatorObjectsProcessedCounter(value float64, operatorName string) metrics.Metric {
|
||||||
|
return ArangodbOperatorObjectsProcessed().Counter(value, operatorName)
|
||||||
|
}
|
|
@ -26,18 +26,18 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangoOperatorObjectsProcessed_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorObjectsProcessed_Descriptor(t *testing.T) {
|
||||||
ArangoOperatorObjectsProcessed()
|
ArangodbOperatorObjectsProcessed()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ArangoOperatorObjectsProcessed_Global(t *testing.T) {
|
func Test_ArangodbOperatorObjectsProcessed_Factory(t *testing.T) {
|
||||||
global := GetArangoOperatorObjectsProcessedFactory()
|
global := NewArangodbOperatorObjectsProcessedCounterFactory()
|
||||||
|
|
||||||
object1 := ArangoOperatorObjectsProcessedItem{
|
object1 := ArangodbOperatorObjectsProcessedInput{
|
||||||
OperatorName: "1",
|
OperatorName: "1",
|
||||||
}
|
}
|
||||||
|
|
||||||
object2 := ArangoOperatorObjectsProcessedItem{
|
object2 := ArangodbOperatorObjectsProcessedInput{
|
||||||
OperatorName: "2",
|
OperatorName: "2",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ func Test_ArangoOperatorObjectsProcessed_Global(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Add", func(t *testing.T) {
|
t.Run("Add", func(t *testing.T) {
|
||||||
global.Add(10, object1)
|
global.Add(object1, 10)
|
||||||
|
|
||||||
require.EqualValues(t, 10, global.Get(object1))
|
require.EqualValues(t, 10, global.Get(object1))
|
||||||
require.EqualValues(t, 0, global.Get(object2))
|
require.EqualValues(t, 0, global.Get(object2))
|
||||||
|
@ -62,7 +62,7 @@ func Test_ArangoOperatorObjectsProcessed_Global(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Add", func(t *testing.T) {
|
t.Run("Add", func(t *testing.T) {
|
||||||
global.Add(3, object2)
|
global.Add(object2, 3)
|
||||||
|
|
||||||
require.EqualValues(t, 10, global.Get(object1))
|
require.EqualValues(t, 10, global.Get(object1))
|
||||||
require.EqualValues(t, 3, global.Get(object2))
|
require.EqualValues(t, 3, global.Get(object2))
|
||||||
|
@ -73,7 +73,7 @@ func Test_ArangoOperatorObjectsProcessed_Global(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Dec", func(t *testing.T) {
|
t.Run("Dec", func(t *testing.T) {
|
||||||
global.Add(-1, object1)
|
global.Add(object1, -1)
|
||||||
|
|
||||||
require.EqualValues(t, 9, global.Get(object1))
|
require.EqualValues(t, 9, global.Get(object1))
|
||||||
require.EqualValues(t, 3, global.Get(object2))
|
require.EqualValues(t, 3, global.Get(object2))
|
||||||
|
@ -117,14 +117,14 @@ func Test_ArangoOperatorObjectsProcessed_Global(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_ArangoOperatorObjectsProcessed_Global_Counter(t *testing.T) {
|
func Test_ArangodbOperatorObjectsProcessed_Factory_Counter(t *testing.T) {
|
||||||
global := GetArangoOperatorObjectsProcessedFactory()
|
global := NewArangodbOperatorObjectsProcessedCounterFactory()
|
||||||
|
|
||||||
object1 := ArangoOperatorObjectsProcessedItem{
|
object1 := ArangodbOperatorObjectsProcessedInput{
|
||||||
OperatorName: "1",
|
OperatorName: "1",
|
||||||
}
|
}
|
||||||
|
|
||||||
object2 := ArangoOperatorObjectsProcessedItem{
|
object2 := ArangodbOperatorObjectsProcessedInput{
|
||||||
OperatorName: "2",
|
OperatorName: "2",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ func Test_ArangoOperatorObjectsProcessed_Global_Counter(t *testing.T) {
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("Add", func(t *testing.T) {
|
t.Run("Add", func(t *testing.T) {
|
||||||
global.Add(10, object1)
|
global.Add(object1, 10)
|
||||||
|
|
||||||
require.EqualValues(t, 10, global.Get(object1))
|
require.EqualValues(t, 10, global.Get(object1))
|
||||||
require.EqualValues(t, 0, global.Get(object2))
|
require.EqualValues(t, 0, global.Get(object2))
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorRebalancerEnabled)
|
registerDescription(arangodbOperatorRebalancerEnabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerEnabledGaugeFactory() metrics.FactoryGauge[ArangodbOperatorRebalancerEnabledInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorRebalancerEnabledInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerEnabledInput(namespace string, name string) ArangodbOperatorRebalancerEnabledInput {
|
||||||
|
return ArangodbOperatorRebalancerEnabledInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorRebalancerEnabledInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerEnabledInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorRebalancerEnabledGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerEnabledInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorRebalancerEnabled()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorRebalancerEnabled() metrics.Description {
|
func ArangodbOperatorRebalancerEnabled() metrics.Description {
|
||||||
return arangodbOperatorRebalancerEnabled
|
return arangodbOperatorRebalancerEnabled
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorRebalancerEnabled_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorRebalancerEnabled_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorRebalancerEnabled()
|
ArangodbOperatorRebalancerEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorRebalancerEnabled_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerEnabledGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerEnabledInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerEnabledInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorRebalancerEnabled_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerEnabledGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerEnabledInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerEnabledInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorRebalancerMovesCurrent)
|
registerDescription(arangodbOperatorRebalancerMovesCurrent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerMovesCurrentGaugeFactory() metrics.FactoryGauge[ArangodbOperatorRebalancerMovesCurrentInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorRebalancerMovesCurrentInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerMovesCurrentInput(namespace string, name string) ArangodbOperatorRebalancerMovesCurrentInput {
|
||||||
|
return ArangodbOperatorRebalancerMovesCurrentInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorRebalancerMovesCurrentInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerMovesCurrentInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorRebalancerMovesCurrentGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerMovesCurrentInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorRebalancerMovesCurrent()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorRebalancerMovesCurrent() metrics.Description {
|
func ArangodbOperatorRebalancerMovesCurrent() metrics.Description {
|
||||||
return arangodbOperatorRebalancerMovesCurrent
|
return arangodbOperatorRebalancerMovesCurrent
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorRebalancerMovesCurrent_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorRebalancerMovesCurrent_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorRebalancerMovesCurrent()
|
ArangodbOperatorRebalancerMovesCurrent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorRebalancerMovesCurrent_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerMovesCurrentGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerMovesCurrentInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerMovesCurrentInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorRebalancerMovesCurrent_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerMovesCurrentGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerMovesCurrentInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerMovesCurrentInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorRebalancerMovesFailed)
|
registerDescription(arangodbOperatorRebalancerMovesFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerMovesFailedCounterFactory() metrics.FactoryCounter[ArangodbOperatorRebalancerMovesFailedInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorRebalancerMovesFailedInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerMovesFailedInput(namespace string, name string) ArangodbOperatorRebalancerMovesFailedInput {
|
||||||
|
return ArangodbOperatorRebalancerMovesFailedInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorRebalancerMovesFailedInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerMovesFailedInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorRebalancerMovesFailedCounter(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerMovesFailedInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorRebalancerMovesFailed()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorRebalancerMovesFailed() metrics.Description {
|
func ArangodbOperatorRebalancerMovesFailed() metrics.Description {
|
||||||
return arangodbOperatorRebalancerMovesFailed
|
return arangodbOperatorRebalancerMovesFailed
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorRebalancerMovesFailed_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorRebalancerMovesFailed_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorRebalancerMovesFailed()
|
ArangodbOperatorRebalancerMovesFailed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorRebalancerMovesFailed_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerMovesFailedCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerMovesFailedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerMovesFailedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorRebalancerMovesFailed_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerMovesFailedCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerMovesFailedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerMovesFailedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorRebalancerMovesGenerated)
|
registerDescription(arangodbOperatorRebalancerMovesGenerated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerMovesGeneratedCounterFactory() metrics.FactoryCounter[ArangodbOperatorRebalancerMovesGeneratedInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorRebalancerMovesGeneratedInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerMovesGeneratedInput(namespace string, name string) ArangodbOperatorRebalancerMovesGeneratedInput {
|
||||||
|
return ArangodbOperatorRebalancerMovesGeneratedInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorRebalancerMovesGeneratedInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerMovesGeneratedInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorRebalancerMovesGeneratedCounter(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerMovesGeneratedInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorRebalancerMovesGenerated()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorRebalancerMovesGenerated() metrics.Description {
|
func ArangodbOperatorRebalancerMovesGenerated() metrics.Description {
|
||||||
return arangodbOperatorRebalancerMovesGenerated
|
return arangodbOperatorRebalancerMovesGenerated
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorRebalancerMovesGenerated_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorRebalancerMovesGenerated_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorRebalancerMovesGenerated()
|
ArangodbOperatorRebalancerMovesGenerated()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorRebalancerMovesGenerated_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerMovesGeneratedCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerMovesGeneratedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerMovesGeneratedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorRebalancerMovesGenerated_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerMovesGeneratedCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerMovesGeneratedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerMovesGeneratedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorRebalancerMovesSucceeded)
|
registerDescription(arangodbOperatorRebalancerMovesSucceeded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerMovesSucceededCounterFactory() metrics.FactoryCounter[ArangodbOperatorRebalancerMovesSucceededInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorRebalancerMovesSucceededInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorRebalancerMovesSucceededInput(namespace string, name string) ArangodbOperatorRebalancerMovesSucceededInput {
|
||||||
|
return ArangodbOperatorRebalancerMovesSucceededInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorRebalancerMovesSucceededInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerMovesSucceededInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorRebalancerMovesSucceededCounter(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorRebalancerMovesSucceededInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorRebalancerMovesSucceeded()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorRebalancerMovesSucceeded() metrics.Description {
|
func ArangodbOperatorRebalancerMovesSucceeded() metrics.Description {
|
||||||
return arangodbOperatorRebalancerMovesSucceeded
|
return arangodbOperatorRebalancerMovesSucceeded
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorRebalancerMovesSucceeded_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorRebalancerMovesSucceeded_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorRebalancerMovesSucceeded()
|
ArangodbOperatorRebalancerMovesSucceeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorRebalancerMovesSucceeded_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerMovesSucceededCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerMovesSucceededInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerMovesSucceededInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorRebalancerMovesSucceeded_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorRebalancerMovesSucceededCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorRebalancerMovesSucceededInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorRebalancerMovesSucceededInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorResourcesArangodeploymentAccepted)
|
registerDescription(arangodbOperatorResourcesArangodeploymentAccepted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentAcceptedGaugeFactory() metrics.FactoryGauge[ArangodbOperatorResourcesArangodeploymentAcceptedInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorResourcesArangodeploymentAcceptedInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentAcceptedInput(namespace string, name string) ArangodbOperatorResourcesArangodeploymentAcceptedInput {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentAcceptedInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorResourcesArangodeploymentAcceptedInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentAcceptedInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentAcceptedGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentAcceptedInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentAccepted()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorResourcesArangodeploymentAccepted() metrics.Description {
|
func ArangodbOperatorResourcesArangodeploymentAccepted() metrics.Description {
|
||||||
return arangodbOperatorResourcesArangodeploymentAccepted
|
return arangodbOperatorResourcesArangodeploymentAccepted
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorResourcesArangodeploymentAccepted_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorResourcesArangodeploymentAccepted_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorResourcesArangodeploymentAccepted()
|
ArangodbOperatorResourcesArangodeploymentAccepted()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorResourcesArangodeploymentAccepted_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentAcceptedGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentAcceptedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentAcceptedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorResourcesArangodeploymentAccepted_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentAcceptedGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentAcceptedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentAcceptedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorResourcesArangodeploymentImmutableErrors)
|
registerDescription(arangodbOperatorResourcesArangodeploymentImmutableErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentImmutableErrorsCounterFactory() metrics.FactoryCounter[ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentImmutableErrorsInput(namespace string, name string) ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentImmutableErrorsCounter(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentImmutableErrors()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorResourcesArangodeploymentImmutableErrors() metrics.Description {
|
func ArangodbOperatorResourcesArangodeploymentImmutableErrors() metrics.Description {
|
||||||
return arangodbOperatorResourcesArangodeploymentImmutableErrors
|
return arangodbOperatorResourcesArangodeploymentImmutableErrors
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorResourcesArangodeploymentImmutableErrors_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorResourcesArangodeploymentImmutableErrors_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorResourcesArangodeploymentImmutableErrors()
|
ArangodbOperatorResourcesArangodeploymentImmutableErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorResourcesArangodeploymentImmutableErrors_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentImmutableErrorsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorResourcesArangodeploymentImmutableErrors_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentImmutableErrorsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentImmutableErrorsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorResourcesArangodeploymentPropagated)
|
registerDescription(arangodbOperatorResourcesArangodeploymentPropagated)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentPropagatedGaugeFactory() metrics.FactoryGauge[ArangodbOperatorResourcesArangodeploymentPropagatedInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorResourcesArangodeploymentPropagatedInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentPropagatedInput(namespace string, name string) ArangodbOperatorResourcesArangodeploymentPropagatedInput {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentPropagatedInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorResourcesArangodeploymentPropagatedInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentPropagatedInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentPropagatedGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentPropagatedInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentPropagated()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorResourcesArangodeploymentPropagated() metrics.Description {
|
func ArangodbOperatorResourcesArangodeploymentPropagated() metrics.Description {
|
||||||
return arangodbOperatorResourcesArangodeploymentPropagated
|
return arangodbOperatorResourcesArangodeploymentPropagated
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorResourcesArangodeploymentPropagated_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorResourcesArangodeploymentPropagated_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorResourcesArangodeploymentPropagated()
|
ArangodbOperatorResourcesArangodeploymentPropagated()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorResourcesArangodeploymentPropagated_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentPropagatedGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentPropagatedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentPropagatedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorResourcesArangodeploymentPropagated_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentPropagatedGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentPropagatedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentPropagatedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorResourcesArangodeploymentStatusRestores)
|
registerDescription(arangodbOperatorResourcesArangodeploymentStatusRestores)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentStatusRestoresCounterFactory() metrics.FactoryCounter[ArangodbOperatorResourcesArangodeploymentStatusRestoresInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorResourcesArangodeploymentStatusRestoresInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentStatusRestoresInput(namespace string, name string) ArangodbOperatorResourcesArangodeploymentStatusRestoresInput {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentStatusRestoresInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorResourcesArangodeploymentStatusRestoresInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentStatusRestoresInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentStatusRestoresCounter(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentStatusRestoresInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentStatusRestores()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorResourcesArangodeploymentStatusRestores() metrics.Description {
|
func ArangodbOperatorResourcesArangodeploymentStatusRestores() metrics.Description {
|
||||||
return arangodbOperatorResourcesArangodeploymentStatusRestores
|
return arangodbOperatorResourcesArangodeploymentStatusRestores
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorResourcesArangodeploymentStatusRestores_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorResourcesArangodeploymentStatusRestores_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorResourcesArangodeploymentStatusRestores()
|
ArangodbOperatorResourcesArangodeploymentStatusRestores()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorResourcesArangodeploymentStatusRestores_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentStatusRestoresCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentStatusRestoresInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentStatusRestoresInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorResourcesArangodeploymentStatusRestores_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentStatusRestoresCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentStatusRestoresInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentStatusRestoresInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorResourcesArangodeploymentUptodate)
|
registerDescription(arangodbOperatorResourcesArangodeploymentUptodate)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentUptodateGaugeFactory() metrics.FactoryGauge[ArangodbOperatorResourcesArangodeploymentUptodateInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorResourcesArangodeploymentUptodateInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentUptodateInput(namespace string, name string) ArangodbOperatorResourcesArangodeploymentUptodateInput {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentUptodateInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorResourcesArangodeploymentUptodateInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentUptodateInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentUptodateGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentUptodateInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentUptodate()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorResourcesArangodeploymentUptodate() metrics.Description {
|
func ArangodbOperatorResourcesArangodeploymentUptodate() metrics.Description {
|
||||||
return arangodbOperatorResourcesArangodeploymentUptodate
|
return arangodbOperatorResourcesArangodeploymentUptodate
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorResourcesArangodeploymentUptodate_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorResourcesArangodeploymentUptodate_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorResourcesArangodeploymentUptodate()
|
ArangodbOperatorResourcesArangodeploymentUptodate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorResourcesArangodeploymentUptodate_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentUptodateGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentUptodateInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentUptodateInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorResourcesArangodeploymentUptodate_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentUptodateGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentUptodateInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentUptodateInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorResourcesArangodeploymentValidationErrors)
|
registerDescription(arangodbOperatorResourcesArangodeploymentValidationErrors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentValidationErrorsCounterFactory() metrics.FactoryCounter[ArangodbOperatorResourcesArangodeploymentValidationErrorsInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbOperatorResourcesArangodeploymentValidationErrorsInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentValidationErrorsInput(namespace string, name string) ArangodbOperatorResourcesArangodeploymentValidationErrorsInput {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentValidationErrorsInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorResourcesArangodeploymentValidationErrorsInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentValidationErrorsInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentValidationErrorsCounter(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentValidationErrorsInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentValidationErrors()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorResourcesArangodeploymentValidationErrors() metrics.Description {
|
func ArangodbOperatorResourcesArangodeploymentValidationErrors() metrics.Description {
|
||||||
return arangodbOperatorResourcesArangodeploymentValidationErrors
|
return arangodbOperatorResourcesArangodeploymentValidationErrors
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorResourcesArangodeploymentValidationErrors_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorResourcesArangodeploymentValidationErrors_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorResourcesArangodeploymentValidationErrors()
|
ArangodbOperatorResourcesArangodeploymentValidationErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorResourcesArangodeploymentValidationErrors_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentValidationErrorsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentValidationErrorsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentValidationErrorsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorResourcesArangodeploymentValidationErrors_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentValidationErrorsCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentValidationErrorsInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentValidationErrorsInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorResourcesArangodeploymentreplicationActive)
|
registerDescription(arangodbOperatorResourcesArangodeploymentreplicationActive)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentreplicationActiveGaugeFactory() metrics.FactoryGauge[ArangodbOperatorResourcesArangodeploymentreplicationActiveInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorResourcesArangodeploymentreplicationActiveInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentreplicationActiveInput(namespace string, name string) ArangodbOperatorResourcesArangodeploymentreplicationActiveInput {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentreplicationActiveInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorResourcesArangodeploymentreplicationActiveInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentreplicationActiveInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentreplicationActiveGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentreplicationActiveInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentreplicationActive()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorResourcesArangodeploymentreplicationActive() metrics.Description {
|
func ArangodbOperatorResourcesArangodeploymentreplicationActive() metrics.Description {
|
||||||
return arangodbOperatorResourcesArangodeploymentreplicationActive
|
return arangodbOperatorResourcesArangodeploymentreplicationActive
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorResourcesArangodeploymentreplicationActive_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorResourcesArangodeploymentreplicationActive_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorResourcesArangodeploymentreplicationActive()
|
ArangodbOperatorResourcesArangodeploymentreplicationActive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorResourcesArangodeploymentreplicationActive_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentreplicationActiveGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentreplicationActiveInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentreplicationActiveInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorResourcesArangodeploymentreplicationActive_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentreplicationActiveGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentreplicationActiveInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentreplicationActiveInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -32,6 +32,30 @@ func init() {
|
||||||
registerDescription(arangodbOperatorResourcesArangodeploymentreplicationFailed)
|
registerDescription(arangodbOperatorResourcesArangodeploymentreplicationFailed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentreplicationFailedGaugeFactory() metrics.FactoryGauge[ArangodbOperatorResourcesArangodeploymentreplicationFailedInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbOperatorResourcesArangodeploymentreplicationFailedInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbOperatorResourcesArangodeploymentreplicationFailedInput(namespace string, name string) ArangodbOperatorResourcesArangodeploymentreplicationFailedInput {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentreplicationFailedInput{
|
||||||
|
Namespace: namespace,
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbOperatorResourcesArangodeploymentreplicationFailedInput struct {
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentreplicationFailedInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentreplicationFailedGauge(value, i.Namespace, i.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbOperatorResourcesArangodeploymentreplicationFailedInput) Desc() metrics.Description {
|
||||||
|
return ArangodbOperatorResourcesArangodeploymentreplicationFailed()
|
||||||
|
}
|
||||||
|
|
||||||
func ArangodbOperatorResourcesArangodeploymentreplicationFailed() metrics.Description {
|
func ArangodbOperatorResourcesArangodeploymentreplicationFailed() metrics.Description {
|
||||||
return arangodbOperatorResourcesArangodeploymentreplicationFailed
|
return arangodbOperatorResourcesArangodeploymentreplicationFailed
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,145 @@ package metric_descriptions
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ArangodbOperatorResourcesArangodeploymentreplicationFailed_Descriptor(t *testing.T) {
|
func Test_ArangodbOperatorResourcesArangodeploymentreplicationFailed_Descriptor(t *testing.T) {
|
||||||
ArangodbOperatorResourcesArangodeploymentreplicationFailed()
|
ArangodbOperatorResourcesArangodeploymentreplicationFailed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbOperatorResourcesArangodeploymentreplicationFailed_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentreplicationFailedGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentreplicationFailedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentreplicationFailedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbOperatorResourcesArangodeploymentreplicationFailed_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbOperatorResourcesArangodeploymentreplicationFailedGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbOperatorResourcesArangodeploymentreplicationFailedInput{
|
||||||
|
Namespace: "1",
|
||||||
|
Name: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbOperatorResourcesArangodeploymentreplicationFailedInput{
|
||||||
|
Namespace: "2",
|
||||||
|
Name: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
71
pkg/generated/metric_descriptions/arangodb_resources_deployment_config_map_duration.go
generated
Normal file
71
pkg/generated/metric_descriptions/arangodb_resources_deployment_config_map_duration.go
generated
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
//
|
||||||
|
// 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 (
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
arangodbResourcesDeploymentConfigMapDuration = metrics.NewDescription("arangodb_resources_deployment_config_map_duration", "Duration of inspected ConfigMaps by Deployment in seconds", []string{`deployment`}, nil)
|
||||||
|
|
||||||
|
// Global Fields
|
||||||
|
globalArangodbResourcesDeploymentConfigMapDurationGauge = NewArangodbResourcesDeploymentConfigMapDurationGaugeFactory()
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerDescription(arangodbResourcesDeploymentConfigMapDuration)
|
||||||
|
registerCollector(globalArangodbResourcesDeploymentConfigMapDurationGauge)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GlobalArangodbResourcesDeploymentConfigMapDurationGauge() metrics.FactoryGauge[ArangodbResourcesDeploymentConfigMapDurationInput] {
|
||||||
|
return globalArangodbResourcesDeploymentConfigMapDurationGauge
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbResourcesDeploymentConfigMapDurationGaugeFactory() metrics.FactoryGauge[ArangodbResourcesDeploymentConfigMapDurationInput] {
|
||||||
|
return metrics.NewFactoryGauge[ArangodbResourcesDeploymentConfigMapDurationInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbResourcesDeploymentConfigMapDurationInput(deployment string) ArangodbResourcesDeploymentConfigMapDurationInput {
|
||||||
|
return ArangodbResourcesDeploymentConfigMapDurationInput{
|
||||||
|
Deployment: deployment,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbResourcesDeploymentConfigMapDurationInput struct {
|
||||||
|
Deployment string `json:"deployment"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbResourcesDeploymentConfigMapDurationInput) Gauge(value float64) metrics.Metric {
|
||||||
|
return ArangodbResourcesDeploymentConfigMapDurationGauge(value, i.Deployment)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbResourcesDeploymentConfigMapDurationInput) Desc() metrics.Description {
|
||||||
|
return ArangodbResourcesDeploymentConfigMapDuration()
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbResourcesDeploymentConfigMapDuration() metrics.Description {
|
||||||
|
return arangodbResourcesDeploymentConfigMapDuration
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbResourcesDeploymentConfigMapDurationGauge(value float64, deployment string) metrics.Metric {
|
||||||
|
return ArangodbResourcesDeploymentConfigMapDuration().Gauge(value, deployment)
|
||||||
|
}
|
162
pkg/generated/metric_descriptions/arangodb_resources_deployment_config_map_duration_test.go
generated
Normal file
162
pkg/generated/metric_descriptions/arangodb_resources_deployment_config_map_duration_test.go
generated
Normal 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_ArangodbResourcesDeploymentConfigMapDuration_Descriptor(t *testing.T) {
|
||||||
|
ArangodbResourcesDeploymentConfigMapDuration()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbResourcesDeploymentConfigMapDuration_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbResourcesDeploymentConfigMapDurationGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbResourcesDeploymentConfigMapDurationInput{
|
||||||
|
Deployment: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbResourcesDeploymentConfigMapDurationInput{
|
||||||
|
Deployment: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbResourcesDeploymentConfigMapDuration_Factory_Gauge(t *testing.T) {
|
||||||
|
global := NewArangodbResourcesDeploymentConfigMapDurationGaugeFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbResourcesDeploymentConfigMapDurationInput{
|
||||||
|
Deployment: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbResourcesDeploymentConfigMapDurationInput{
|
||||||
|
Deployment: "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(object1, 10)
|
||||||
|
|
||||||
|
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("Set", func(t *testing.T) {
|
||||||
|
global.Set(object1, 3)
|
||||||
|
global.Set(object2, 1)
|
||||||
|
|
||||||
|
require.EqualValues(t, 3, global.Get(object1))
|
||||||
|
require.EqualValues(t, 1, global.Get(object2))
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("List", func(t *testing.T) {
|
||||||
|
require.Len(t, global.Items(), 2)
|
||||||
|
})
|
||||||
|
}
|
71
pkg/generated/metric_descriptions/arangodb_resources_deployment_config_map_inspected.go
generated
Normal file
71
pkg/generated/metric_descriptions/arangodb_resources_deployment_config_map_inspected.go
generated
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
//
|
||||||
|
// 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 (
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util/metrics"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
arangodbResourcesDeploymentConfigMapInspected = metrics.NewDescription("arangodb_resources_deployment_config_map_inspected", "Number of inspected ConfigMaps by Deployment", []string{`deployment`}, nil)
|
||||||
|
|
||||||
|
// Global Fields
|
||||||
|
globalArangodbResourcesDeploymentConfigMapInspectedCounter = NewArangodbResourcesDeploymentConfigMapInspectedCounterFactory()
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
registerDescription(arangodbResourcesDeploymentConfigMapInspected)
|
||||||
|
registerCollector(globalArangodbResourcesDeploymentConfigMapInspectedCounter)
|
||||||
|
}
|
||||||
|
|
||||||
|
func GlobalArangodbResourcesDeploymentConfigMapInspectedCounter() metrics.FactoryCounter[ArangodbResourcesDeploymentConfigMapInspectedInput] {
|
||||||
|
return globalArangodbResourcesDeploymentConfigMapInspectedCounter
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbResourcesDeploymentConfigMapInspectedCounterFactory() metrics.FactoryCounter[ArangodbResourcesDeploymentConfigMapInspectedInput] {
|
||||||
|
return metrics.NewFactoryCounter[ArangodbResourcesDeploymentConfigMapInspectedInput]()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewArangodbResourcesDeploymentConfigMapInspectedInput(deployment string) ArangodbResourcesDeploymentConfigMapInspectedInput {
|
||||||
|
return ArangodbResourcesDeploymentConfigMapInspectedInput{
|
||||||
|
Deployment: deployment,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type ArangodbResourcesDeploymentConfigMapInspectedInput struct {
|
||||||
|
Deployment string `json:"deployment"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbResourcesDeploymentConfigMapInspectedInput) Counter(value float64) metrics.Metric {
|
||||||
|
return ArangodbResourcesDeploymentConfigMapInspectedCounter(value, i.Deployment)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ArangodbResourcesDeploymentConfigMapInspectedInput) Desc() metrics.Description {
|
||||||
|
return ArangodbResourcesDeploymentConfigMapInspected()
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbResourcesDeploymentConfigMapInspected() metrics.Description {
|
||||||
|
return arangodbResourcesDeploymentConfigMapInspected
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArangodbResourcesDeploymentConfigMapInspectedCounter(value float64, deployment string) metrics.Metric {
|
||||||
|
return ArangodbResourcesDeploymentConfigMapInspected().Counter(value, deployment)
|
||||||
|
}
|
162
pkg/generated/metric_descriptions/arangodb_resources_deployment_config_map_inspected_test.go
generated
Normal file
162
pkg/generated/metric_descriptions/arangodb_resources_deployment_config_map_inspected_test.go
generated
Normal 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_ArangodbResourcesDeploymentConfigMapInspected_Descriptor(t *testing.T) {
|
||||||
|
ArangodbResourcesDeploymentConfigMapInspected()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_ArangodbResourcesDeploymentConfigMapInspected_Factory(t *testing.T) {
|
||||||
|
global := NewArangodbResourcesDeploymentConfigMapInspectedCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbResourcesDeploymentConfigMapInspectedInput{
|
||||||
|
Deployment: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbResourcesDeploymentConfigMapInspectedInput{
|
||||||
|
Deployment: "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(object1, 10)
|
||||||
|
|
||||||
|
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(object2, 3)
|
||||||
|
|
||||||
|
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(object1, -1)
|
||||||
|
|
||||||
|
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_ArangodbResourcesDeploymentConfigMapInspected_Factory_Counter(t *testing.T) {
|
||||||
|
global := NewArangodbResourcesDeploymentConfigMapInspectedCounterFactory()
|
||||||
|
|
||||||
|
object1 := ArangodbResourcesDeploymentConfigMapInspectedInput{
|
||||||
|
Deployment: "1",
|
||||||
|
}
|
||||||
|
|
||||||
|
object2 := ArangodbResourcesDeploymentConfigMapInspectedInput{
|
||||||
|
Deployment: "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(object1, 10)
|
||||||
|
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
|
@ -102,7 +102,7 @@ func (o *operator) processObject(obj interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
metric_descriptions.ArangoOperatorObjectsProcessedInc(o.operator.name)
|
metric_descriptions.GlobalArangodbOperatorObjectsProcessedCounter().Inc(metric_descriptions.NewArangodbOperatorObjectsProcessedInput(o.operator.name))
|
||||||
|
|
||||||
loggerWorker.Trace("Received Item Action: %s, Type: %s/%s/%s, Namespace: %s, Name: %s",
|
loggerWorker.Trace("Received Item Action: %s, Type: %s/%s/%s, Namespace: %s, Name: %s",
|
||||||
item.Operation,
|
item.Operation,
|
||||||
|
|
30
pkg/util/metrics/duration.go
Normal file
30
pkg/util/metrics/duration.go
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 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 metrics
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
|
func WithDuration[T FactoryTypeGauge](f FactoryGauge[T], v T) func() {
|
||||||
|
start := time.Now()
|
||||||
|
return func() {
|
||||||
|
f.Add(v, float64(time.Since(start))/float64(time.Second))
|
||||||
|
}
|
||||||
|
}
|
109
pkg/util/metrics/factory_counter.go
Normal file
109
pkg/util/metrics/factory_counter.go
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 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 metrics
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FactoryTypeCounter interface {
|
||||||
|
comparable
|
||||||
|
|
||||||
|
Desc() Description
|
||||||
|
Counter(value float64) Metric
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFactoryCounter[T FactoryTypeCounter]() FactoryCounter[T] {
|
||||||
|
return &factoryCounter[T]{
|
||||||
|
desc: util.Default[T]().Desc(),
|
||||||
|
metrics: map[T]float64{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type FactoryCounter[T FactoryTypeCounter] interface {
|
||||||
|
Collector
|
||||||
|
|
||||||
|
Items() []T
|
||||||
|
Get(v T) float64
|
||||||
|
Remove(v T)
|
||||||
|
Add(v T, value float64)
|
||||||
|
Inc(v T)
|
||||||
|
}
|
||||||
|
|
||||||
|
type factoryCounter[T FactoryTypeCounter] struct {
|
||||||
|
lock sync.Mutex
|
||||||
|
|
||||||
|
desc Description
|
||||||
|
metrics map[T]float64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryCounter[T]) CollectMetrics(in PushMetric) {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
for k, v := range f.metrics {
|
||||||
|
in.Push(k.Counter(v))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryCounter[T]) CollectDescriptions(in PushDescription) {
|
||||||
|
in.Push(f.desc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryCounter[T]) Items() []T {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
r := make([]T, 0, len(f.metrics))
|
||||||
|
|
||||||
|
for k := range f.metrics {
|
||||||
|
r = append(r, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryCounter[T]) Get(v T) float64 {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
return f.metrics[v]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryCounter[T]) Remove(v T) {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
delete(f.metrics, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryCounter[T]) Add(v T, value float64) {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
f.metrics[v] = value + f.metrics[v]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryCounter[T]) Inc(v T) {
|
||||||
|
f.Add(v, 1)
|
||||||
|
}
|
112
pkg/util/metrics/factory_gauge.go
Normal file
112
pkg/util/metrics/factory_gauge.go
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
//
|
||||||
|
// DISCLAIMER
|
||||||
|
//
|
||||||
|
// Copyright 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 metrics
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
type FactoryTypeGauge interface {
|
||||||
|
comparable
|
||||||
|
|
||||||
|
Desc() Description
|
||||||
|
Gauge(value float64) Metric
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFactoryGauge[T FactoryTypeGauge]() FactoryGauge[T] {
|
||||||
|
return &factoryGauge[T]{
|
||||||
|
desc: util.Default[T]().Desc(),
|
||||||
|
metrics: map[T]float64{},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type FactoryGauge[T FactoryTypeGauge] interface {
|
||||||
|
Collector
|
||||||
|
|
||||||
|
Items() []T
|
||||||
|
Get(v T) float64
|
||||||
|
Remove(v T)
|
||||||
|
Set(v T, value float64)
|
||||||
|
Add(v T, value float64)
|
||||||
|
}
|
||||||
|
|
||||||
|
type factoryGauge[T FactoryTypeGauge] struct {
|
||||||
|
lock sync.Mutex
|
||||||
|
|
||||||
|
desc Description
|
||||||
|
metrics map[T]float64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryGauge[T]) CollectMetrics(in PushMetric) {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
for k, v := range f.metrics {
|
||||||
|
in.Push(k.Gauge(v))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryGauge[T]) CollectDescriptions(in PushDescription) {
|
||||||
|
in.Push(f.desc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryGauge[T]) Items() []T {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
r := make([]T, 0, len(f.metrics))
|
||||||
|
|
||||||
|
for k := range f.metrics {
|
||||||
|
r = append(r, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryGauge[T]) Get(v T) float64 {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
return f.metrics[v]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryGauge[T]) Remove(v T) {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
delete(f.metrics, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryGauge[T]) Set(v T, value float64) {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
f.metrics[v] = value
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *factoryGauge[T]) Add(v T, value float64) {
|
||||||
|
f.lock.Lock()
|
||||||
|
defer f.lock.Unlock()
|
||||||
|
|
||||||
|
f.metrics[v] = value + f.metrics[v]
|
||||||
|
}
|
Loading…
Reference in a new issue