This is an automated email from the ASF dual-hosted git repository.

rxl pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git


The following commit(s) were added to refs/heads/master by this push:
     new d84c4b4  Add error label to publish errors metric (#405)
d84c4b4 is described below

commit d84c4b42aae61aef5128e2b0d3911ac7f9a779f2
Author: cckellogg <[email protected]>
AuthorDate: Mon Nov 30 18:49:37 2020 -0700

    Add error label to publish errors metric (#405)
    
    Add an label to the pulsar_client_producer_errors metric to distinguish the 
error type.
---
 pulsar/producer_partition.go | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/pulsar/producer_partition.go b/pulsar/producer_partition.go
index 2a9093f..bea73aa 100644
--- a/pulsar/producer_partition.go
+++ b/pulsar/producer_partition.go
@@ -53,6 +53,12 @@ var (
        buffersPool sync.Pool
 )
 
+// metric error types
+const (
+       publishErrorTimeout     = "timeout"
+       publishErrorMsgTooLarge = "msg_too_large"
+)
+
 var (
        messagesPublished = promauto.NewCounter(prometheus.CounterOpts{
                Name: "pulsar_client_messages_published",
@@ -74,10 +80,10 @@ var (
                Help: "Counter of bytes pending to be published by the client",
        })
 
-       publishErrors = promauto.NewCounter(prometheus.CounterOpts{
+       publishErrors = promauto.NewCounterVec(prometheus.CounterOpts{
                Name: "pulsar_client_producer_errors",
                Help: "Counter of publish errors",
-       })
+       }, []string{"error"})
 
        publishLatency = promauto.NewHistogram(prometheus.HistogramOpts{
                Name:    "pulsar_client_producer_latency_seconds",
@@ -365,7 +371,7 @@ func (p *partitionProducer) internalSend(request 
*sendRequest) {
                        WithField("size", len(payload)).
                        WithField("properties", msg.Properties).
                        Error()
-               publishErrors.Inc()
+               publishErrors.WithLabelValues(publishErrorMsgTooLarge).Inc()
                return
        }
 
@@ -486,7 +492,7 @@ func (p *partitionProducer) failTimeoutMessages() {
                                p.publishSemaphore.Release()
                                messagesPending.Dec()
                                bytesPending.Sub(float64(size))
-                               publishErrors.Inc()
+                               
publishErrors.WithLabelValues(publishErrorTimeout).Inc()
                                p.log.WithError(errSendTimeout).
                                        WithField("size", size).
                                        WithField("properties", 
sr.msg.Properties)

Reply via email to