This repository has been archived by the owner on Aug 23, 2023. It is now read-only.
/
out.go
45 lines (37 loc) · 1.88 KB
/
out.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package out
import (
"fmt"
"github.com/grafana/metrictank/schema"
"github.com/raintank/met"
)
// Out submits metricdata to a destination
type Out interface {
Close() error
// Flush completely handles the metrics, does not keep references into it, so that caller can reuse
// Filter outputs reserve the right to make in-place modifications
Flush(metrics []*schema.MetricData) error
}
// OutStats tracks metrics related to an Output
type OutStats struct {
FlushDuration met.Timer // duration of Flush()
PublishQueued met.Gauge // not every output uses this
PublishErrors met.Count // not every output uses this
PublishDuration met.Timer // duration of writing a message to underlying storage
PublishedMetrics met.Count // number of metrics written to underlying storage
PublishedMessages met.Count // number of messages written to underlying storage
MessageBytes met.Meter // number of bytes per message
MessageMetrics met.Meter // number of metrics per message
}
// NewStats creates a new OutStats
func NewStats(stats met.Backend, output string) OutStats {
return OutStats{
FlushDuration: stats.NewTimer(fmt.Sprintf("metricpublisher.out.%s.flush_duration", output), 0),
PublishQueued: stats.NewGauge(fmt.Sprintf("metricpublisher.out.%s.publish_queued", output), 0),
PublishErrors: stats.NewCount(fmt.Sprintf("metricpublisher.out.%s.publish_errors", output)),
PublishDuration: stats.NewTimer(fmt.Sprintf("metricpublisher.out.%s.publish_duration", output), 0),
PublishedMetrics: stats.NewCount(fmt.Sprintf("metricpublisher.out.%s.published_metrics", output)),
PublishedMessages: stats.NewCount(fmt.Sprintf("metricpublisher.out.%s.published_messages", output)),
MessageBytes: stats.NewMeter(fmt.Sprintf("metricpublisher.out.%s.message_bytes", output), 0),
MessageMetrics: stats.NewMeter(fmt.Sprintf("metricpublisher.out.%s.message_metrics", output), 0),
}
}