forked from mirrors/statsd_exporter
Adding new metric to relay
Signed-off-by: Pedro Tanaka <pedro.tanaka@shopify.com>
This commit is contained in:
parent
60742e1bd6
commit
2d339b0853
1 changed files with 14 additions and 4 deletions
|
@ -35,8 +35,9 @@ type Relay struct {
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
packetLength uint
|
packetLength uint
|
||||||
|
|
||||||
packetsTotal prometheus.Counter
|
packetsTotal prometheus.Counter
|
||||||
longLinesTotal prometheus.Counter
|
longLinesTotal prometheus.Counter
|
||||||
|
relayedLinesTotal prometheus.Counter
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -54,6 +55,13 @@ var (
|
||||||
},
|
},
|
||||||
[]string{"target"},
|
[]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
|
// NewRelay creates a statsd UDP relay. It can be used to send copies of statsd raw
|
||||||
|
@ -77,8 +85,9 @@ func NewRelay(l log.Logger, target string, packetLength uint) (*Relay, error) {
|
||||||
logger: l,
|
logger: l,
|
||||||
packetLength: packetLength,
|
packetLength: packetLength,
|
||||||
|
|
||||||
packetsTotal: relayPacketsTotal.WithLabelValues(target),
|
packetsTotal: relayPacketsTotal.WithLabelValues(target),
|
||||||
longLinesTotal: relayLongLinesTotal.WithLabelValues(target),
|
longLinesTotal: relayLongLinesTotal.WithLabelValues(target),
|
||||||
|
relayedLinesTotal: relayLinesRelayedTotal.WithLabelValues(target),
|
||||||
}
|
}
|
||||||
|
|
||||||
// Startup the UDP sender.
|
// Startup the UDP sender.
|
||||||
|
@ -152,5 +161,6 @@ func (r *Relay) RelayLine(l string) {
|
||||||
if !strings.HasSuffix(l, "\n") {
|
if !strings.HasSuffix(l, "\n") {
|
||||||
l = l + "\n"
|
l = l + "\n"
|
||||||
}
|
}
|
||||||
|
r.relayedLinesTotal.Inc()
|
||||||
r.bufferChannel <- []byte(l)
|
r.bufferChannel <- []byte(l)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue