Only access meta data, when it gets used as tag

This commit is contained in:
Holger Obermaier 2023-09-19 14:06:20 +02:00
parent c472029c2d
commit c87c77a810

View File

@ -64,9 +64,11 @@ func (m *ccMetric) String() string {
// ToLineProtocol generates influxDB line protocol for data type ccMetric // ToLineProtocol generates influxDB line protocol for data type ccMetric
func (m *ccMetric) ToPoint(metaAsTags map[string]bool) (p *write.Point) { func (m *ccMetric) ToPoint(metaAsTags map[string]bool) (p *write.Point) {
p = influxdb2.NewPoint(m.name, m.tags, m.fields, m.tm) p = influxdb2.NewPoint(m.name, m.tags, m.fields, m.tm)
for key, ok1 := range metaAsTags { for key, use_as_tag := range metaAsTags {
if val, ok2 := m.GetMeta(key); ok1 && ok2 { if use_as_tag {
p.AddTag(key, val) if value, ok := m.GetMeta(key); ok {
p.AddTag(key, value)
}
} }
} }
return p return p
@ -264,8 +266,10 @@ func FromInfluxMetric(other lp.Metric) CCMetric {
} }
// convertField converts data types of fields by the following schemata: // convertField converts data types of fields by the following schemata:
//
// *float32, *float64, float32, float64 -> float64 // *float32, *float64, float32, float64 -> float64
// *int, *int8, *int16, *int32, *int64, int, int8, int16, int32, int64 -> int64 // *int, *int8, *int16, *int32, *int64, int, int8, int16, int32, int64 -> int64
//
// *uint, *uint8, *uint16, *uint32, *uint64, uint, uint8, uint16, uint32, uint64 -> uint64 // *uint, *uint8, *uint16, *uint32, *uint64, uint, uint8, uint16, uint32, uint64 -> uint64
// *[]byte, *string, []byte, string -> string // *[]byte, *string, []byte, string -> string
// *bool, bool -> bool // *bool, bool -> bool