forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
writer.go
32 lines (28 loc) · 1.03 KB
/
writer.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
package opentelemetry
import (
"context"
"fmt"
"time"
"github.com/influxdata/influxdb-observability/otel2influx"
"github.com/influxdata/telegraf"
)
type writeToAccumulator struct {
accumulator telegraf.Accumulator
}
func (w *writeToAccumulator) WritePoint(_ context.Context, measurement string, tags map[string]string, fields map[string]interface{}, ts time.Time, vType otel2influx.InfluxWriterValueType) error {
switch vType {
case otel2influx.InfluxWriterValueTypeUntyped:
w.accumulator.AddFields(measurement, fields, tags, ts)
case otel2influx.InfluxWriterValueTypeGauge:
w.accumulator.AddGauge(measurement, fields, tags, ts)
case otel2influx.InfluxWriterValueTypeSum:
w.accumulator.AddCounter(measurement, fields, tags, ts)
case otel2influx.InfluxWriterValueTypeHistogram:
w.accumulator.AddHistogram(measurement, fields, tags, ts)
case otel2influx.InfluxWriterValueTypeSummary:
w.accumulator.AddSummary(measurement, fields, tags, ts)
default:
return fmt.Errorf("unrecognized InfluxWriterValueType %q", vType)
}
return nil
}