[#80] metrics: Make global description unexported

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
pull/82/head
Denis Kirillov 2023-04-07 17:58:36 +03:00
parent ee6118c3d7
commit 644524e8a5
5 changed files with 23 additions and 23 deletions

View File

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

View File

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

View File

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

View File

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

View File

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