MCPcopy
hub / github.com/google/mtail / metricToCollectd

Function metricToCollectd

internal/exporter/collectd.go:33–43  ·  view source on GitHub ↗

metricToCollectd encodes the metric data in the collectd text protocol format. The metric lock is held before entering this function.

(hostname string, m *metrics.Metric, l *metrics.LabelSet, interval time.Duration)

Source from the content-addressed store, hash-verified

31// metricToCollectd encodes the metric data in the collectd text protocol format. The
32// metric lock is held before entering this function.
33func metricToCollectd(hostname string, m *metrics.Metric, l *metrics.LabelSet, interval time.Duration) string {
34 return fmt.Sprintf(collectdFormat,
35 hostname,
36 *collectdPrefix,
37 m.Program,
38 kindToCollectdType(m.Kind),
39 formatLabels(m.Name, l.Labels, "-", "-", "_"),
40 int64(interval.Seconds()),
41 l.Datum.TimeString(),
42 l.Datum.ValueString())
43}
44
45func kindToCollectdType(kind metrics.Kind) string {
46 if kind != metrics.Timer {

Callers

nothing calls this directly

Calls 4

kindToCollectdTypeFunction · 0.85
formatLabelsFunction · 0.85
TimeStringMethod · 0.65
ValueStringMethod · 0.65

Tested by

no test coverage detected