Skip to content

Commit fa9bd84

Browse files
committed
fix: remove flags field
Helps open-telemetry/opentelemetry-collector-contrib#29896 The flags field is set as an unsigned integer, which is not compatible with InfluxDB 1.x. Luckily, the field is also not useful, as it stores a value chosen from an enum containing no useful values. In this change, the flags field is removed from conversion. If it needs to be added in the future, we can expect that enough time will have passed that retention policies will have removed the prior `flags` field.
1 parent 3e3c07a commit fa9bd84

12 files changed

+12
-103
lines changed

docs/logs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ timestamp | `time_unix_nano` fixed64
3939
`otel.log.dropped_attributes_count` field uint | `dropped_attributes_count` uint32
4040
`severity_number` tag uint | `severity_number` enum SeverityNumber | | `level` number | `PRI severity` integer | `PRI severity` integer
4141
`severity_text` field string | `severity_text` string
42-
`otel.log.flags` field uint | `flags` fixed32
42+
. | `flags` fixed32
4343
. | `attributes["fluent.tag"]` string | `tag` string
4444
. | `Resource.attributes["net.host.name"]` string | | `host` string | `HEADER hostname` string | `HOSTNAME` string
4545
. | `Resource.attributes["net.host.ip"]` string | | | `HEADER IP address` string | `HOSTNAME` string

influx2otel/metrics_telegraf_prometheus_v1.go

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ func (b *MetricsBatch) convertGaugeV1(measurement string, tags map[string]string
9494
}
9595
}
9696
}
97-
if flagsObj, ok := fields[common.AttributeFlags]; ok {
98-
if flagsUint64, ok := flagsObj.(uint64); ok {
99-
dataPoint.SetFlags(pmetric.DataPointFlags(flagsUint64))
100-
}
101-
}
10297

10398
if floatValue != nil {
10499
dataPoint.SetDoubleValue(*floatValue)
@@ -114,7 +109,7 @@ func (b *MetricsBatch) convertGaugeV1(measurement string, tags map[string]string
114109
var floatValue *float64
115110
var intValue *int64
116111

117-
if k == common.AttributeStartTimeStatsd || k == common.AttributeFlags {
112+
if k == common.AttributeStartTimeStatsd {
118113
continue
119114
}
120115
switch typedValue := fieldValue.(type) {
@@ -145,11 +140,6 @@ func (b *MetricsBatch) convertGaugeV1(measurement string, tags map[string]string
145140
}
146141
}
147142
}
148-
if flagsObj, ok := fields[common.AttributeFlags]; ok {
149-
if flagsUint64, ok := flagsObj.(uint64); ok {
150-
dataPoint.SetFlags(pmetric.DataPointFlags(flagsUint64))
151-
}
152-
}
153143

154144
if floatValue != nil {
155145
dataPoint.SetDoubleValue(*floatValue)
@@ -193,11 +183,6 @@ func (b *MetricsBatch) convertSumV1(measurement string, tags map[string]string,
193183
}
194184
}
195185
}
196-
if flagsObj, ok := fields[common.AttributeFlags]; ok {
197-
if flagsUint64, ok := flagsObj.(uint64); ok {
198-
dataPoint.SetFlags(pmetric.DataPointFlags(flagsUint64))
199-
}
200-
}
201186

202187
if floatValue != nil {
203188
dataPoint.SetDoubleValue(*floatValue)
@@ -211,7 +196,7 @@ func (b *MetricsBatch) convertSumV1(measurement string, tags map[string]string,
211196
}
212197

213198
for k, fieldValue := range fields {
214-
if k == common.AttributeStartTimeStatsd || k == common.AttributeFlags {
199+
if k == common.AttributeStartTimeStatsd {
215200
continue
216201
}
217202

@@ -245,11 +230,6 @@ func (b *MetricsBatch) convertSumV1(measurement string, tags map[string]string,
245230
}
246231
}
247232
}
248-
if flagsObj, ok := fields[common.AttributeFlags]; ok {
249-
if flagsUint64, ok := flagsObj.(uint64); ok {
250-
dataPoint.SetFlags(pmetric.DataPointFlags(flagsUint64))
251-
}
252-
}
253233

254234
if floatValue != nil {
255235
dataPoint.SetDoubleValue(*floatValue)
@@ -295,7 +275,7 @@ func (b *MetricsBatch) convertHistogramV1(measurement string, tags map[string]st
295275
bucketCounts = append(bucketCounts, uint64(vBucketCount))
296276
}
297277

298-
} else if k == common.AttributeStartTimeStatsd || k == common.AttributeFlags {
278+
} else if k == common.AttributeStartTimeStatsd {
299279
} else {
300280
b.logger.Debug("skipping unrecognized histogram field", "field", k, "value", vi)
301281
}
@@ -337,11 +317,6 @@ func (b *MetricsBatch) convertHistogramV1(measurement string, tags map[string]st
337317
}
338318
}
339319
}
340-
if flagsObj, ok := fields[common.AttributeFlags]; ok {
341-
if flagsUint64, ok := flagsObj.(uint64); ok {
342-
dataPoint.SetFlags(pmetric.DataPointFlags(flagsUint64))
343-
}
344-
}
345320

346321
dataPoint.SetCount(count)
347322
dataPoint.SetSum(sum)
@@ -382,7 +357,7 @@ func (b *MetricsBatch) convertSummaryV1(measurement string, tags map[string]stri
382357
valueAtQuantile.SetValue(value)
383358
}
384359

385-
} else if k == common.AttributeStartTimeStatsd || k == common.AttributeFlags {
360+
} else if k == common.AttributeStartTimeStatsd {
386361
} else {
387362
b.logger.Debug("skipping unrecognized summary field", "field", k, "value", vi)
388363
}
@@ -408,11 +383,6 @@ func (b *MetricsBatch) convertSummaryV1(measurement string, tags map[string]stri
408383
}
409384
}
410385
}
411-
if flagsObj, ok := fields[common.AttributeFlags]; ok {
412-
if flagsUint64, ok := flagsObj.(uint64); ok {
413-
dataPoint.SetFlags(pmetric.DataPointFlags(flagsUint64))
414-
}
415-
}
416386

417387
dataPoint.SetCount(count)
418388
dataPoint.SetSum(sum)

influx2otel/metrics_telegraf_prometheus_v1_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ func TestAddPoint_v1_gauge(t *testing.T) {
2727
},
2828
map[string]interface{}{
2929
"gauge": float64(23.9),
30-
"flags": uint64(1),
3130
},
3231
time.Unix(0, 1395066363000000123).UTC(),
3332
common.InfluxMetricValueTypeGauge)
@@ -60,12 +59,10 @@ func TestAddPoint_v1_gauge(t *testing.T) {
6059
dp.Attributes().PutStr("engine_id", "0")
6160
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 1395066363000000123)))
6261
dp.SetDoubleValue(23.9)
63-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(true))
6462
dp = m.Gauge().DataPoints().AppendEmpty()
6563
dp.Attributes().PutStr("engine_id", "1")
6664
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 1395066363000000123)))
6765
dp.SetDoubleValue(11.9)
68-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(false))
6966

7067
assertMetricsEqual(t, expect, b.GetMetrics())
7168
}
@@ -84,7 +81,6 @@ func TestAddPoint_v1_untypedGauge(t *testing.T) {
8481
},
8582
map[string]interface{}{
8683
"gauge": float64(23.9),
87-
"flags": uint64(1),
8884
},
8985
time.Unix(0, 1395066363000000123).UTC(),
9086
common.InfluxMetricValueTypeUntyped)
@@ -117,12 +113,10 @@ func TestAddPoint_v1_untypedGauge(t *testing.T) {
117113
dp.Attributes().PutStr("engine_id", "0")
118114
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 1395066363000000123)))
119115
dp.SetDoubleValue(23.9)
120-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(true))
121116
dp = m.Gauge().DataPoints().AppendEmpty()
122117
dp.Attributes().PutStr("engine_id", "1")
123118
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 1395066363000000123)))
124119
dp.SetDoubleValue(11.9)
125-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(false))
126120

127121
assertMetricsEqual(t, expect, b.GetMetrics())
128122
}
@@ -142,7 +136,6 @@ func TestAddPoint_v1_sum(t *testing.T) {
142136
},
143137
map[string]interface{}{
144138
"counter": float64(1027),
145-
"flags": uint64(1),
146139
},
147140
time.Unix(0, 1395066363000000123).UTC(),
148141
common.InfluxMetricValueTypeSum)
@@ -179,13 +172,11 @@ func TestAddPoint_v1_sum(t *testing.T) {
179172
dp.Attributes().PutStr("method", "post")
180173
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 1395066363000000123)))
181174
dp.SetDoubleValue(1027)
182-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(true))
183175
dp = m.Sum().DataPoints().AppendEmpty()
184176
dp.Attributes().PutStr("code", "400")
185177
dp.Attributes().PutStr("method", "post")
186178
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 1395066363000000123)))
187179
dp.SetDoubleValue(3)
188-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(false))
189180

190181
assertMetricsEqual(t, expect, b.GetMetrics())
191182
}
@@ -205,7 +196,6 @@ func TestAddPoint_v1_untypedSum(t *testing.T) {
205196
},
206197
map[string]interface{}{
207198
"counter": float64(1027),
208-
"flags": uint64(0),
209199
},
210200
time.Unix(0, 1395066363000000123).UTC(),
211201
common.InfluxMetricValueTypeUntyped)
@@ -242,13 +232,11 @@ func TestAddPoint_v1_untypedSum(t *testing.T) {
242232
dp.Attributes().PutStr("method", "post")
243233
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 1395066363000000123)))
244234
dp.SetDoubleValue(1027)
245-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(false))
246235
dp = m.Sum().DataPoints().AppendEmpty()
247236
dp.Attributes().PutStr("code", "400")
248237
dp.Attributes().PutStr("method", "post")
249238
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 1395066363000000123)))
250239
dp.SetDoubleValue(3)
251-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(false))
252240

253241
assertMetricsEqual(t, expect, b.GetMetrics())
254242
}
@@ -275,7 +263,6 @@ func TestAddPoint_v1_histogram(t *testing.T) {
275263
"0.5": float64(129389),
276264
"1": float64(133988),
277265
"+Inf": float64(144320),
278-
"flags": uint64(1),
279266
},
280267
time.Unix(0, 1395066363000000123).UTC(),
281268
common.InfluxMetricValueTypeHistogram)
@@ -299,7 +286,6 @@ func TestAddPoint_v1_histogram(t *testing.T) {
299286
dp.SetSum(53423)
300287
dp.BucketCounts().FromRaw([]uint64{24054, 9390, 66948, 28997, 4599, 10332})
301288
dp.ExplicitBounds().FromRaw([]float64{0.05, 0.1, 0.2, 0.5, 1})
302-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(true))
303289

304290
assertMetricsEqual(t, expect, b.GetMetrics())
305291
}
@@ -325,7 +311,6 @@ func TestAddPoint_v1_histogram_missingInfinityBucket(t *testing.T) {
325311
"0.2": float64(100392),
326312
"0.5": float64(129389),
327313
"1": float64(133988),
328-
"flags": uint64(0),
329314
},
330315
time.Unix(0, 1395066363000000123).UTC(),
331316
common.InfluxMetricValueTypeHistogram)
@@ -349,7 +334,6 @@ func TestAddPoint_v1_histogram_missingInfinityBucket(t *testing.T) {
349334
dp.SetSum(53423)
350335
dp.BucketCounts().FromRaw([]uint64{24054, 9390, 66948, 28997, 4599, 10332})
351336
dp.ExplicitBounds().FromRaw([]float64{0.05, 0.1, 0.2, 0.5, 1})
352-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(false))
353337

354338
assertMetricsEqual(t, expect, b.GetMetrics())
355339
}
@@ -375,7 +359,6 @@ func TestAddPoint_v1_untypedHistogram(t *testing.T) {
375359
"0.2": float64(100392),
376360
"0.5": float64(129389),
377361
"1": float64(133988),
378-
"flags": uint64(1),
379362
},
380363
time.Unix(0, 1395066363000000123).UTC(),
381364
common.InfluxMetricValueTypeUntyped)
@@ -399,7 +382,6 @@ func TestAddPoint_v1_untypedHistogram(t *testing.T) {
399382
dp.SetSum(53423)
400383
dp.BucketCounts().FromRaw([]uint64{24054, 9390, 66948, 28997, 4599, 10332})
401384
dp.ExplicitBounds().FromRaw([]float64{0.05, 0.1, 0.2, 0.5, 1})
402-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(true))
403385

404386
assertMetricsEqual(t, expect, b.GetMetrics())
405387
}
@@ -425,7 +407,6 @@ func TestAddPoint_v1_summary(t *testing.T) {
425407
"0.5": float64(4773),
426408
"0.9": float64(9001),
427409
"0.99": float64(76656),
428-
"flags": uint64(1),
429410
},
430411
time.Unix(0, 1395066363000000123),
431412
common.InfluxMetricValueTypeSummary)
@@ -446,7 +427,6 @@ func TestAddPoint_v1_summary(t *testing.T) {
446427
dp.SetTimestamp(pcommon.NewTimestampFromTime(time.Unix(0, 1395066363000000123)))
447428
dp.SetCount(2693)
448429
dp.SetSum(17560473)
449-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(true))
450430
qv := dp.QuantileValues().AppendEmpty()
451431
qv.SetQuantile(0.01)
452432
qv.SetValue(3102)
@@ -487,7 +467,6 @@ func TestAddPoint_v1_untypedSummary(t *testing.T) {
487467
"0.5": float64(4773),
488468
"0.9": float64(9001),
489469
"0.99": float64(76656),
490-
"flags": uint64(0),
491470
},
492471
time.Unix(0, 1395066363000000123).UTC(),
493472
common.InfluxMetricValueTypeUntyped)
@@ -511,7 +490,6 @@ func TestAddPoint_v1_untypedSummary(t *testing.T) {
511490
dp.SetSum(17560473)
512491
dp.BucketCounts().FromRaw([]uint64{3102, 170, 1501, 4228, 67655, 2693})
513492
dp.ExplicitBounds().FromRaw([]float64{0.01, 0.05, 0.5, 0.9, 0.99})
514-
dp.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(false))
515493

516494
assertMetricsEqual(t, expect, b.GetMetrics())
517495
}

otel2influx/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ For example:
6666
- `Metric.unit` is ignored
6767
- `Metric` values are assigned field keys `gauge`, `counter`, `count`, `sum`, `inf`
6868
- Metric conversion follows Prometheus conventions for compatibility
69-
- `LogRecord.flags` is ignored
70-
- This is an enum with no values defines yet
69+
- `flags` fields are ignored
70+
- These are enum with no values defines yet
7171

7272
## Example Line Protocol
7373

otel2influx/logs.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ func (c *OtelLogsToLineProtocol) enqueueLogRecord(ctx context.Context, resource
102102
tags := make(map[string]string, len(c.logRecordDimensions)+2)
103103
fields := make(map[string]interface{})
104104

105-
fields[common.AttributeFlags] = uint64(logRecord.Flags())
106105
if ots := logRecord.ObservedTimestamp().AsTime(); !ots.IsZero() && !ots.Equal(time.Unix(0, 0)) {
107106
fields[common.AttributeObservedTimeUnixNano] = ots.UnixNano()
108107
}

otel2influx/metrics.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,4 @@ type basicDataPoint interface {
7979
Timestamp() pcommon.Timestamp
8080
StartTimestamp() pcommon.Timestamp
8181
Attributes() pcommon.Map
82-
Flags() pmetric.DataPointFlags
8382
}

otel2influx/metrics_otel_v1.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ func (m *metricWriterOtelV1) enqueueSum(ctx context.Context, measurementName str
8585

8686
for i := 0; i < pm.Sum().DataPoints().Len(); i++ {
8787
// TODO datapoint exemplars
88-
// TODO datapoint flags
8988
dataPoint := pm.Sum().DataPoints().At(i)
9089

9190
fields := make(map[string]interface{}, 3)
@@ -116,7 +115,6 @@ func (m *metricWriterOtelV1) enqueueHistogram(ctx context.Context, measurementNa
116115

117116
for i := 0; i < pm.Histogram().DataPoints().Len(); i++ {
118117
// TODO datapoint exemplars
119-
// TODO datapoint flags
120118
dataPoint := pm.Histogram().DataPoints().At(i)
121119

122120
bucketCounts, explicitBounds := dataPoint.BucketCounts(), dataPoint.ExplicitBounds()

otel2influx/metrics_telegraf_prometheus_v1.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func (c *metricWriterTelegrafPrometheusV1) initMetricTagsAndTimestamp(dataPoint
4949
if dataPoint.StartTimestamp() != 0 {
5050
fields[common.AttributeStartTimeUnixNano] = int64(dataPoint.StartTimestamp())
5151
}
52-
fields[common.AttributeFlags] = uint64(dataPoint.Flags())
5352

5453
tags = maps.Clone(tags)
5554
dataPoint.Attributes().Range(func(k string, v pcommon.Value) bool {

0 commit comments

Comments
 (0)