From 6f321a205b1dda8aa1b4b23be80f3c79502b6a66 Mon Sep 17 00:00:00 2001 From: william feng <> Date: Sun, 31 May 2020 09:51:24 +0800 Subject: [PATCH 1/2] update the comments in metrics --- metrics/prometheus/reporter.go | 15 +++++---------- metrics/reporter.go | 5 ++--- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 1636b14da2..1dce679ac2 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -23,12 +23,7 @@ import ( "strings" "sync" "time" -) -import ( - "github.com/prometheus/client_golang/prometheus" -) -import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" @@ -36,6 +31,7 @@ import ( "github.com/apache/dubbo-go/config" "github.com/apache/dubbo-go/metrics" "github.com/apache/dubbo-go/protocol" + "github.com/prometheus/client_golang/prometheus" ) const ( @@ -68,9 +64,8 @@ func init() { extension.SetMetricReporter(reporterName, newPrometheusReporter) } -// PrometheusReporter -// it will collect the data for Prometheus -// if you want to use this, you should initialize your prometheus. +// PrometheusReporter will collect the data for Prometheus +// if you want to use this feature, you need to initialize your prometheus. // https://prometheus.io/docs/guides/go-application/ type PrometheusReporter struct { @@ -85,7 +80,7 @@ type PrometheusReporter struct { consumerHistogramVec *prometheus.HistogramVec } -// Report report the duration to Prometheus +// Report reports the duration to Prometheus // the role in url must be consumer or provider // or it will be ignored func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration, res protocol.Result) { @@ -99,7 +94,7 @@ func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol sumVec = reporter.consumerSummaryVec hisVec = reporter.consumerHistogramVec } else { - logger.Warnf("The url is not the consumer's or provider's, "+ + logger.Warnf("The url belongs neither the consumer nor the provider, "+ "so the invocation will be ignored. url: %s", url.String()) return } diff --git a/metrics/reporter.go b/metrics/reporter.go index 85ef1dcdf0..aac961d7e7 100644 --- a/metrics/reporter.go +++ b/metrics/reporter.go @@ -20,8 +20,7 @@ package metrics import ( "context" "time" -) -import ( + "github.com/apache/dubbo-go/protocol" ) @@ -29,7 +28,7 @@ const ( NameSpace = "dubbo" ) -// it will be use to report the invocation's duration +// Reporter will be used to report the invocation's duration type Reporter interface { // report the duration of an invocation Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, From 3cd5fabcd824e101d52793c031e8e26a13fb2003 Mon Sep 17 00:00:00 2001 From: william feng <> Date: Mon, 1 Jun 2020 01:31:17 +0800 Subject: [PATCH 2/2] revert the import block --- metrics/prometheus/reporter.go | 6 +++++- metrics/reporter.go | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go index 1dce679ac2..bd1e7986ca 100644 --- a/metrics/prometheus/reporter.go +++ b/metrics/prometheus/reporter.go @@ -23,7 +23,12 @@ import ( "strings" "sync" "time" +) +import ( + "github.com/prometheus/client_golang/prometheus" +) +import ( "github.com/apache/dubbo-go/common" "github.com/apache/dubbo-go/common/constant" "github.com/apache/dubbo-go/common/extension" @@ -31,7 +36,6 @@ import ( "github.com/apache/dubbo-go/config" "github.com/apache/dubbo-go/metrics" "github.com/apache/dubbo-go/protocol" - "github.com/prometheus/client_golang/prometheus" ) const ( diff --git a/metrics/reporter.go b/metrics/reporter.go index aac961d7e7..9a7094fa62 100644 --- a/metrics/reporter.go +++ b/metrics/reporter.go @@ -20,7 +20,8 @@ package metrics import ( "context" "time" - +) +import ( "github.com/apache/dubbo-go/protocol" )