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

Function metricToStatsd

internal/exporter/statsd.go:27–42  ·  view source on GitHub ↗

metricToStatsd encodes a metric in the statsd text protocol format. The metric lock is held before entering this function.

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

Source from the content-addressed store, hash-verified

25// metricToStatsd encodes a metric in the statsd text protocol format. The
26// metric lock is held before entering this function.
27func metricToStatsd(_ string, m *metrics.Metric, l *metrics.LabelSet, _ time.Duration) string {
28 var t string
29 switch m.Kind {
30 case metrics.Counter:
31 t = "c" // StatsD Counter
32 case metrics.Gauge:
33 t = "g" // StatsD Gauge
34 case metrics.Timer:
35 t = "ms" // StatsD Timer
36 }
37 return fmt.Sprintf("%s%s.%s:%s|%s",
38 *statsdPrefix,
39 m.Program,
40 formatLabels(m.Name, l.Labels, ".", ".", "_"),
41 l.Datum.ValueString(), t)
42}

Callers

nothing calls this directly

Calls 2

formatLabelsFunction · 0.85
ValueStringMethod · 0.65

Tested by

no test coverage detected