statreceiver: Add name of buffer for better logging/debugging

Change-Id: If845908543c951111ac13ac6262b4e7c50dcd22c
This commit is contained in:
Isaac Hess 2020-03-19 13:49:28 -06:00 committed by Isaac Hess
parent 1b6ab173a8
commit 05da31a97b
3 changed files with 15 additions and 14 deletions

View File

@ -102,21 +102,25 @@ type Metric struct {
// metrics to buffer in memory to deal with potentially variable processing
// speeds. MetricBuffers drop metrics if the buffer is full.
type MetricBuffer struct {
ch chan Metric
name string
ch chan Metric
}
// NewMetricBuffer makes a metric buffer with a buffer size of bufsize
func NewMetricBuffer(p MetricDest, bufsize int) *MetricBuffer {
func NewMetricBuffer(name string, p MetricDest, bufsize int) *MetricBuffer {
ch := make(chan Metric, bufsize)
go func() {
for pkt := range ch {
err := p.Metric(pkt.Application, pkt.Instance, pkt.Key, pkt.Val, pkt.TS)
if err != nil {
log.Printf("failed delivering buffered metric: %v", err)
log.Printf("failed delivering %s buffered metric: %v", name, err)
}
}
}()
return &MetricBuffer{ch: ch}
return &MetricBuffer{
name: name,
ch: ch,
}
}
// Metric implements the MetricDest interface
@ -131,7 +135,7 @@ func (p *MetricBuffer) Metric(application, instance string, key []byte,
TS: ts}:
return nil
default:
return fmt.Errorf("metric buffer overrun")
return fmt.Errorf("%s metric buffer overrun", p.name)
}
}

View File

@ -84,7 +84,7 @@ keyRange:
break
}
if !added {
log.Printf("metric dropped: %q", key)
log.Printf("influx metric dropped: %q", key)
return nil
}

View File

@ -28,14 +28,11 @@ pbufsize = 1000
-- * print() goes to stdout
-- * db("sqlite3", path) goes to sqlite
-- * db("postgres", connstring) goes to postgres
influx_out = graphite("influx-internal.datasci.storj.io.:2003")
graphite_out = graphite("graphite-internal.datasci.storj.io.:2003")
influx_out_old = graphite("influx-internal.datasci.storj.io.:2003")
influx_out_v3 = influx("http://influx-internal.datasci.storj.io:8086/write?db=v3_stats_new")
v2_metric_handlers = sanitize(mbufprep(mcopy(
-- send all satellite data to graphite
mbuf(influx_out, mbufsize),
mbuf(graphite_out, mbufsize))))
v2_metric_handlers = sanitize(mbufprep(mbuf("influx_old", influx_out_old, mbufsize)))
-- mbuf(graphite_out_stefan, mbufsize),
-- send specific storagenode data to the db
--keyfilter(
@ -48,8 +45,8 @@ v2_metric_handlers = sanitize(mbufprep(mcopy(
v3_metric_handlers = mbufprep(mcopy(
mbuf(downgrade(v2_metric_handlers), mbufsize),
mbuf(influx_out_v3, mbufsize)
mbuf("downgrade", downgrade(v2_metric_handlers), mbufsize),
mbuf("influx_new", influx_out_v3, mbufsize)
))
-- create a metric parser.