From 41fdfbfcad5458a2c87e7e0cbedae705485365f8 Mon Sep 17 00:00:00 2001 From: WangGuan Date: Thu, 8 Jun 2023 11:01:56 +0800 Subject: [PATCH] fix: rename requests_processing to request_processing_total --- metrics/prometheus/after_invocation.go | 2 +- metrics/prometheus/before_invocation.go | 4 +++- metrics/prometheus/common.go | 2 +- metrics/prometheus/metric_set.go | 12 ++++++------ metrics/prometheus/reporter.go | 12 ++++++------ 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/metrics/prometheus/after_invocation.go b/metrics/prometheus/after_invocation.go index bfc13cbcb5..f1235a2d75 100644 --- a/metrics/prometheus/after_invocation.go +++ b/metrics/prometheus/after_invocation.go @@ -40,7 +40,7 @@ func (reporter *PrometheusReporter) ReportAfterInvocation(ctx context.Context, i reporter.reportRTSummaryVec(role, &labels, cost.Milliseconds()) reporter.reportRequestsTotalCounterVec(role, &labels) - reporter.decRequestsProcessingGaugeVec(role, &labels) + reporter.decRequestsProcessingTotalGaugeVec(role, &labels) if res != nil && res.Error() == nil { // succeed diff --git a/metrics/prometheus/before_invocation.go b/metrics/prometheus/before_invocation.go index 19e40dd5ae..7477b13626 100644 --- a/metrics/prometheus/before_invocation.go +++ b/metrics/prometheus/before_invocation.go @@ -19,6 +19,8 @@ package prometheus import ( "context" +) +import ( "dubbo.apache.org/dubbo-go/v3/protocol" ) @@ -34,5 +36,5 @@ func (reporter *PrometheusReporter) ReportBeforeInvocation(ctx context.Context, } labels := buildLabels(url) - reporter.incRequestsProcessingGaugeVec(role, &labels) + reporter.incRequestsProcessingTotalGaugeVec(role, &labels) } diff --git a/metrics/prometheus/common.go b/metrics/prometheus/common.go index edefc2c08f..a319c334a6 100644 --- a/metrics/prometheus/common.go +++ b/metrics/prometheus/common.go @@ -18,13 +18,13 @@ package prometheus import ( - "github.com/dubbogo/gost/log/logger" "strconv" "strings" "time" ) import ( + "github.com/dubbogo/gost/log/logger" "github.com/prometheus/client_golang/prometheus" ) diff --git a/metrics/prometheus/metric_set.go b/metrics/prometheus/metric_set.go index 91afa1bdf4..01f52284c3 100644 --- a/metrics/prometheus/metric_set.go +++ b/metrics/prometheus/metric_set.go @@ -39,14 +39,14 @@ type metricSet struct { // report the provider-side's request total counter data providerRequestsTotalCounterVec *prometheus.CounterVec // report the provider-side's processing request counter data - providerRequestsProcessingGaugeVec *prometheus.GaugeVec + providerRequestsProcessingTotalGaugeVec *prometheus.GaugeVec // The number of requests successfully received by the provider providerRequestsSucceedTotalCounterVec *prometheus.CounterVec // report the consumer-side's request total counter data consumerRequestsTotalCounterVec *prometheus.CounterVec // report the consumer-side's processing request counter data - consumerRequestsProcessingGaugeVec *prometheus.GaugeVec + consumerRequestsProcessingTotalGaugeVec *prometheus.GaugeVec // The number of successful requests sent by consumers consumerRequestsSucceedTotalCounterVec *prometheus.CounterVec } @@ -59,8 +59,8 @@ func (ms *metricSet) initAndRegister(reporterConfig *metrics.ReporterConfig) { ms.providerRTSummaryVec = newSummaryVec(buildMetricsName(providerField, rtField, milliSecondsField, summaryField), reporterConfig.Namespace, labelNames, reporterConfig.SummaryMaxAge) ms.consumerRequestsTotalCounterVec = newCounterVec(buildMetricsName(consumerField, requestsField, totalField), reporterConfig.Namespace, labelNames) ms.providerRequestsTotalCounterVec = newCounterVec(buildMetricsName(providerField, requestsField, totalField), reporterConfig.Namespace, labelNames) - ms.consumerRequestsProcessingGaugeVec = newGaugeVec(buildMetricsName(consumerField, requestsField, processingField), reporterConfig.Namespace, labelNames) - ms.providerRequestsProcessingGaugeVec = newGaugeVec(buildMetricsName(providerField, requestsField, processingField), reporterConfig.Namespace, labelNames) + ms.consumerRequestsProcessingTotalGaugeVec = newGaugeVec(buildMetricsName(consumerField, requestsField, processingField, totalField), reporterConfig.Namespace, labelNames) + ms.providerRequestsProcessingTotalGaugeVec = newGaugeVec(buildMetricsName(providerField, requestsField, processingField, totalField), reporterConfig.Namespace, labelNames) ms.consumerRequestsSucceedTotalCounterVec = newCounterVec(buildMetricsName(consumerField, requestsField, succeedField, totalField), reporterConfig.Namespace, labelNames) ms.providerRequestsSucceedTotalCounterVec = newCounterVec(buildMetricsName(providerField, requestsField, succeedField, totalField), reporterConfig.Namespace, labelNames) @@ -69,8 +69,8 @@ func (ms *metricSet) initAndRegister(reporterConfig *metrics.ReporterConfig) { ms.providerRTSummaryVec, ms.consumerRequestsTotalCounterVec, ms.providerRequestsTotalCounterVec, - ms.consumerRequestsProcessingGaugeVec, - ms.providerRequestsProcessingGaugeVec, + ms.consumerRequestsProcessingTotalGaugeVec, + ms.providerRequestsProcessingTotalGaugeVec, ms.consumerRequestsSucceedTotalCounterVec, ms.providerRequestsSucceedTotalCounterVec, ) diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 73135272e0..e733fda30c 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -129,21 +129,21 @@ func (reporter *PrometheusReporter) reportRequestsTotalCounterVec(role string, l } } -func (reporter *PrometheusReporter) incRequestsProcessingGaugeVec(role string, labels *prometheus.Labels) { +func (reporter *PrometheusReporter) incRequestsProcessingTotalGaugeVec(role string, labels *prometheus.Labels) { switch role { case providerField: - reporter.providerRequestsProcessingGaugeVec.With(*labels).Inc() + reporter.providerRequestsProcessingTotalGaugeVec.With(*labels).Inc() case consumerField: - reporter.consumerRequestsProcessingGaugeVec.With(*labels).Inc() + reporter.consumerRequestsProcessingTotalGaugeVec.With(*labels).Inc() } } -func (reporter *PrometheusReporter) decRequestsProcessingGaugeVec(role string, labels *prometheus.Labels) { +func (reporter *PrometheusReporter) decRequestsProcessingTotalGaugeVec(role string, labels *prometheus.Labels) { switch role { case providerField: - reporter.providerRequestsProcessingGaugeVec.With(*labels).Dec() + reporter.providerRequestsProcessingTotalGaugeVec.With(*labels).Dec() case consumerField: - reporter.consumerRequestsProcessingGaugeVec.With(*labels).Dec() + reporter.consumerRequestsProcessingTotalGaugeVec.With(*labels).Dec() } }