diff --git a/metrics/billing.go b/metrics/billing.go index 2d75961c..7bd36393 100644 --- a/metrics/billing.go +++ b/metrics/billing.go @@ -197,8 +197,8 @@ type billingMetrics struct { func newBillingMetrics() *billingMetrics { return &billingMetrics{ registry: prometheus.NewRegistry(), - userRequestsDesc: NewDesc(AppMetricsDesc[billingSubsystem][userRequestsMetric]), - userTrafficDesc: NewDesc(AppMetricsDesc[billingSubsystem][userTrafficMetric]), + userRequestsDesc: newDesc(appMetricsDesc[billingSubsystem][userRequestsMetric]), + userTrafficDesc: newDesc(appMetricsDesc[billingSubsystem][userTrafficMetric]), apiStat: UsersAPIStats{}, } } diff --git a/metrics/desc.go b/metrics/desc.go index 84f2f53e..c3cc9f6a 100644 --- a/metrics/desc.go +++ b/metrics/desc.go @@ -6,7 +6,7 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -var AppMetricsDesc = map[string]map[string]Description{ +var appMetricsDesc = map[string]map[string]Description{ poolSubsystem: { overallErrorsMetric: Description{ Namespace: namespace, @@ -161,7 +161,7 @@ func (d *Description) ConstLabelsMap() map[string]string { // DescribeAll returns descriptions for metrics. func DescribeAll() []Description { var list []Description - for _, m := range AppMetricsDesc { + for _, m := range appMetricsDesc { for _, description := range m { list = append(list, description) } @@ -170,7 +170,7 @@ func DescribeAll() []Description { return list } -func NewOpts(description Description) prometheus.Opts { +func newOpts(description Description) prometheus.Opts { return prometheus.Opts{ Namespace: description.Namespace, Subsystem: description.Subsystem, @@ -180,7 +180,7 @@ func NewOpts(description Description) prometheus.Opts { } } -func NewDesc(description Description) *prometheus.Desc { +func newDesc(description Description) *prometheus.Desc { return prometheus.NewDesc( description.BuildFQName(), description.Help, @@ -188,15 +188,15 @@ func NewDesc(description Description) *prometheus.Desc { description.ConstLabelsMap()) } -func NewGauge(description Description) prometheus.Gauge { +func newGauge(description Description) prometheus.Gauge { return prometheus.NewGauge( - prometheus.GaugeOpts(NewOpts(description)), + prometheus.GaugeOpts(newOpts(description)), ) } -func NewGaugeVec(description Description) *prometheus.GaugeVec { +func newGaugeVec(description Description) *prometheus.GaugeVec { return prometheus.NewGaugeVec( - prometheus.GaugeOpts(NewOpts(description)), + prometheus.GaugeOpts(newOpts(description)), description.VariableLabels, ) } diff --git a/metrics/pool.go b/metrics/pool.go index 83929912..b71f4793 100644 --- a/metrics/pool.go +++ b/metrics/pool.go @@ -47,11 +47,11 @@ type poolMetricsCollector struct { func newPoolMetricsCollector(scraper StatisticScraper) *poolMetricsCollector { return &poolMetricsCollector{ poolStatScraper: scraper, - overallErrors: NewGauge(AppMetricsDesc[poolSubsystem][overallErrorsMetric]), - overallNodeErrors: NewGaugeVec(AppMetricsDesc[poolSubsystem][overallNodeErrorsMetric]), - overallNodeRequests: NewGaugeVec(AppMetricsDesc[poolSubsystem][overallNodeRequestsMetric]), - currentErrors: NewGaugeVec(AppMetricsDesc[poolSubsystem][currentErrorMetric]), - requestDuration: NewGaugeVec(AppMetricsDesc[poolSubsystem][avgRequestDurationMetric]), + overallErrors: newGauge(appMetricsDesc[poolSubsystem][overallErrorsMetric]), + overallNodeErrors: newGaugeVec(appMetricsDesc[poolSubsystem][overallNodeErrorsMetric]), + overallNodeRequests: newGaugeVec(appMetricsDesc[poolSubsystem][overallNodeRequestsMetric]), + currentErrors: newGaugeVec(appMetricsDesc[poolSubsystem][currentErrorMetric]), + requestDuration: newGaugeVec(appMetricsDesc[poolSubsystem][avgRequestDurationMetric]), } } diff --git a/metrics/state.go b/metrics/state.go index 8aa8624e..fe71aaaf 100644 --- a/metrics/state.go +++ b/metrics/state.go @@ -28,8 +28,8 @@ type StateMetrics struct { func newStateMetrics() *StateMetrics { return &StateMetrics{ - healthCheck: NewGauge(AppMetricsDesc[stateSubsystem][healthMetric]), - versionInfo: NewGaugeVec(AppMetricsDesc[stateSubsystem][versionInfoMetric]), + healthCheck: newGauge(appMetricsDesc[stateSubsystem][healthMetric]), + versionInfo: newGaugeVec(appMetricsDesc[stateSubsystem][versionInfoMetric]), } } diff --git a/metrics/stats.go b/metrics/stats.go index 462e7d54..2666029b 100644 --- a/metrics/stats.go +++ b/metrics/stats.go @@ -52,7 +52,7 @@ const ( ) func newAPIStatMetrics() *APIStatMetrics { - histogramDesc := AppMetricsDesc[statisticSubsystem][requestsSecondsMetric] + histogramDesc := appMetricsDesc[statisticSubsystem][requestsSecondsMetric] return &APIStatMetrics{ stats: newHTTPStats(), @@ -154,11 +154,11 @@ func (a *APIStatMetrics) Collect(ch chan<- prometheus.Metric) { func newHTTPStats() *httpStats { return &httpStats{ - currentS3RequestsDesc: NewDesc(AppMetricsDesc[statisticSubsystem][requestsCurrentMetric]), - totalS3RequestsDesc: NewDesc(AppMetricsDesc[statisticSubsystem][requestsTotalMetric]), - totalS3ErrorsDesc: NewDesc(AppMetricsDesc[statisticSubsystem][errorsTotalMetric]), - txBytesTotalDesc: NewDesc(AppMetricsDesc[statisticSubsystem][txBytesTotalMetric]), - rxBytesTotalDesc: NewDesc(AppMetricsDesc[statisticSubsystem][rxBytesTotalMetric]), + currentS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsCurrentMetric]), + totalS3RequestsDesc: newDesc(appMetricsDesc[statisticSubsystem][requestsTotalMetric]), + totalS3ErrorsDesc: newDesc(appMetricsDesc[statisticSubsystem][errorsTotalMetric]), + txBytesTotalDesc: newDesc(appMetricsDesc[statisticSubsystem][txBytesTotalMetric]), + rxBytesTotalDesc: newDesc(appMetricsDesc[statisticSubsystem][rxBytesTotalMetric]), } }