Skip to content

Commit

Permalink
Move clone_progress t list
Browse files Browse the repository at this point in the history
Since clone_progress metric used for internal purposhould not document it in metri or test it in the metrics linter.
therefore clone_prog (not used by the doc list (not used by the doc and linter generators).

Signed-off-by: Aviv Litman <alitman@alitman-thinkpadp1gen4i.tlv.csb>
  • Loading branch information
Aviv Litman committed Oct 18, 2023
1 parent 55eac52 commit 32a02e8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions cmd/cdi-cloner/clone-source.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func startPrometheus() {
func createProgressReader(readCloser io.ReadCloser, ownerUID string, totalBytes uint64) io.ReadCloser {
progress := prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: monitoring.MetricOptsList[monitoring.CloneProgress].Name,
Help: monitoring.MetricOptsList[monitoring.CloneProgress].Help,
Name: monitoring.InternalMetricOptsList[monitoring.CloneProgress].Name,
Help: monitoring.InternalMetricOptsList[monitoring.CloneProgress].Help,
},
[]string{"ownerUID"},
)
Expand Down
2 changes: 0 additions & 2 deletions doc/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ This document aims to help users that are not familiar with metrics exposed by t
All metrics documented here are auto-generated by the utility tool `tools/metricsdocs` and reflects exactly what is being exposed.

## Containerized Data Importer Metrics List
### clone_progress
The clone progress in percentage. Type: Counter.
### kubevirt_cdi_clone_pods_high_restart
The number of CDI clone pods with high restart count. Type: Gauge.
### kubevirt_cdi_cr_ready
Expand Down
4 changes: 2 additions & 2 deletions pkg/image/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ var (

progress = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: monitoring.MetricOptsList[monitoring.CloneProgress].Name,
Help: monitoring.MetricOptsList[monitoring.CloneProgress].Help,
Name: monitoring.InternalMetricOptsList[monitoring.CloneProgress].Name,
Help: monitoring.InternalMetricOptsList[monitoring.CloneProgress].Help,
},
[]string{"ownerUID"},
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/importer/format-readers.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ import (
var (
progress = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: monitoring.MetricOptsList[monitoring.CloneProgress].Name,
Help: monitoring.MetricOptsList[monitoring.CloneProgress].Help,
Name: monitoring.InternalMetricOptsList[monitoring.CloneProgress].Name,
Help: monitoring.InternalMetricOptsList[monitoring.CloneProgress].Help,
},
[]string{"ownerUID"},
)
Expand Down
14 changes: 9 additions & 5 deletions pkg/monitoring/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ const (

// MetricOptsList list all CDI metrics
var MetricOptsList = map[MetricsKey]MetricOpts{
CloneProgress: {
Name: "clone_progress",
Help: "The clone progress in percentage",
Type: "Counter",
},
DataImportCronOutdated: {
Name: "kubevirt_cdi_dataimportcron_outdated",
Help: "DataImportCron has an outdated import",
Expand All @@ -55,6 +50,15 @@ var MetricOptsList = map[MetricsKey]MetricOpts{
},
}

// MetricOptsList list all CDI metrics used for internal purposes only
var InternalMetricOptsList = map[MetricsKey]MetricOpts{
CloneProgress: {
Name: "clone_progress",
Help: "The clone progress in percentage",
Type: "Counter",
},
}

// GetRecordRulesDesc returns CDI Prometheus Record Rules
func GetRecordRulesDesc(namespace string) []RecordRulesDesc {
return []RecordRulesDesc{
Expand Down
6 changes: 2 additions & 4 deletions tools/prom-metrics-collector/metrics_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ import (

// This should be used only for very rare cases where the naming conventions that are explained in the best practices:
// https://sdk.operatorframework.io/docs/best-practices/observability-best-practices/#metrics-guidelines
// should be ignored, open issue: https://github.com/kubevirt/containerized-data-importer/issues/2515.
var excludedMetrics = map[string]struct{}{
"clone_progress": {},
}
// should be ignored.
var excludedMetrics = map[string]struct{}{}

func recordRulesDescToMetricList(mdl []monitoring.RecordRulesDesc) []monitoring.MetricOpts {
res := make([]monitoring.MetricOpts, len(mdl))
Expand Down

0 comments on commit 32a02e8

Please sign in to comment.