Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

refactor(metrics): Refactoring metrics package with prometheus metrics naming convention #64

Merged
merged 3 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ license-check:
.PHONY: sanity-test
sanity-test: sanity-test
@echo "--> Running sanity test";
go test -v ./tests/...
go test -v -timeout 20m ./tests/...

.PHONY: push
push:
Expand Down
27 changes: 17 additions & 10 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ import (
)

const (
// NfsProvisionerSubsystem is prometheus subsystem name.
NfsVolumeProvisionerSubsystem = "nfs_volume_provisioner"
// NfsProvisionerNamespace is namespace name for provisioner metrics.
NfsVolumeProvisionerNamespace = "nfs_volume_provisioner"

// PersistentVolumeSubsytem is subsystem name for persistentvolume metrics.
PersistentVolumeSubsytem = "persistentvolume"

// Metrics
// ProvisionerRequestCreate represents metrics related to create resource request.
Expand All @@ -38,35 +41,39 @@ var (
// PersistentVolumeDeleteTotal is used to collect accumulated count of persistent volumes deleted.
PersistentVolumeDeleteTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: NfsVolumeProvisionerSubsystem,
Name: "persistentvolume_delete_total",
Namespace: NfsVolumeProvisionerNamespace,
Subsystem: PersistentVolumeSubsytem,
Name: "delete_total",
Help: "Total number of persistent volumes deleted",
},
[]string{Process},
)
// PersistentVolumeDeleteFailedTotal is used to collect accumulated count of persistent volume delete failed attempts.
PersistentVolumeDeleteFailedTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: NfsVolumeProvisionerSubsystem,
Name: "persistentvolume_delete_failed_total",
Namespace: NfsVolumeProvisionerNamespace,
Subsystem: PersistentVolumeSubsytem,
Name: "delete_failed_total",
Help: "Total number of persistent volume delete failed attempts",
},
[]string{Process},
)
// PersistentVolumeCreateTotal is used to collect accumulated count of persistent volume created.
PersistentVolumeCreateTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: NfsVolumeProvisionerSubsystem,
Name: "persistentvolume_create_total",
Namespace: NfsVolumeProvisionerNamespace,
Subsystem: PersistentVolumeSubsytem,
Name: "create_total",
Help: "Total number of persistent volumes created",
},
[]string{Process},
)
// PersistentVolumeCreateFailedTotal is used to collect accumulated count of persistent volume create requests failed.
PersistentVolumeCreateFailedTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: NfsVolumeProvisionerSubsystem,
Name: "persistentvolume_create_failed_total",
Namespace: NfsVolumeProvisionerNamespace,
Subsystem: PersistentVolumeSubsytem,
Name: "create_failed_total",
Help: "Total number of persistent volume creation failed attempts",
},
[]string{Process},
Expand Down