Adding new metric to relay

Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
This commit is contained in:
Pedro Tanaka 2022-04-21 11:47:19 +02:00
parent 60742e1bd6
commit 2d339b0853
No known key found for this signature in database
GPG key ID: D0D8389DA4EE060B

View file

@ -37,6 +37,7 @@ type Relay struct {
packetsTotal prometheus.Counter
longLinesTotal prometheus.Counter
relayedLinesTotal prometheus.Counter
}
var (
@ -54,6 +55,13 @@ var (
},
[]string{"target"},
)
relayLinesRelayedTotal = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "statsd_exporter_relay_lines_relayed_total",
Help: "The number of lines that were buffered to be relayed.",
},
[]string{"target"},
)
)
// NewRelay creates a statsd UDP relay. It can be used to send copies of statsd raw
@ -79,6 +87,7 @@ func NewRelay(l log.Logger, target string, packetLength uint) (*Relay, error) {
packetsTotal: relayPacketsTotal.WithLabelValues(target),
longLinesTotal: relayLongLinesTotal.WithLabelValues(target),
relayedLinesTotal: relayLinesRelayedTotal.WithLabelValues(target),
}
// Startup the UDP sender.
@ -152,5 +161,6 @@ func (r *Relay) RelayLine(l string) {
if !strings.HasSuffix(l, "\n") {
l = l + "\n"
}
r.relayedLinesTotal.Inc()
r.bufferChannel <- []byte(l)
}