Optionally translate OTEL histograms to NHCB

Signed-off-by: Carrie Edwards <edwrdscarrie@gmail.com>
This commit is contained in:
Carrie Edwards 2025-01-21 07:33:32 -08:00
parent 39d7242cfe
commit 5489b67f7a
6 changed files with 355 additions and 104 deletions

View file

@ -1442,6 +1442,7 @@ type OTLPConfig struct {
PromoteResourceAttributes []string `yaml:"promote_resource_attributes,omitempty"`
TranslationStrategy translationStrategyOption `yaml:"translation_strategy,omitempty"`
KeepIdentifyingResourceAttributes bool `yaml:"keep_identifying_resource_attributes,omitempty"`
ConvertHistogramsToNHCB bool `yaml:"convert_histograms_to_nhcb,omitempty"`
}
// UnmarshalYAML implements the yaml.Unmarshaler interface.

View file

@ -402,10 +402,11 @@ type Histogram struct {
ResetHint Histogram_ResetHint `protobuf:"varint,14,opt,name=reset_hint,json=resetHint,proto3,enum=prometheus.Histogram_ResetHint" json:"reset_hint,omitempty"`
// timestamp is in ms format, see model/timestamp/timestamp.go for
// conversion from time.Time to Prometheus timestamp.
Timestamp int64 `protobuf:"varint,15,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
Timestamp int64 `protobuf:"varint,15,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
CustomValues []float64 `protobuf:"fixed64,16,rep,packed,name=custom_values,json=customValues,proto3" json:"custom_values,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (m *Histogram) Reset() { *m = Histogram{} }
@ -588,6 +589,13 @@ func (m *Histogram) GetTimestamp() int64 {
return 0
}
func (m *Histogram) GetCustomValues() []float64 {
if m != nil {
return m.CustomValues
}
return nil
}
// XXX_OneofWrappers is for the internal use of the proto package.
func (*Histogram) XXX_OneofWrappers() []interface{} {
return []interface{}{
@ -1146,76 +1154,77 @@ func init() {
func init() { proto.RegisterFile("types.proto", fileDescriptor_d938547f84707355) }
var fileDescriptor_d938547f84707355 = []byte{
// 1092 bytes of a gzipped FileDescriptorProto
// 1114 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdb, 0x6e, 0xdb, 0x46,
0x13, 0x36, 0x49, 0x89, 0x12, 0x47, 0x87, 0xd0, 0xfb, 0x3b, 0xf9, 0x59, 0xa3, 0x71, 0x54, 0x02,
0x13, 0x36, 0x49, 0x89, 0x12, 0x47, 0x87, 0xd0, 0xfb, 0x3b, 0xf9, 0xd9, 0xa0, 0x71, 0x54, 0x16,
0x69, 0x85, 0xa2, 0x90, 0x11, 0xb7, 0x17, 0x0d, 0x1a, 0x14, 0xb0, 0x1d, 0xf9, 0x80, 0x5a, 0x12,
0xb2, 0x92, 0xd1, 0xa6, 0x37, 0xc2, 0x5a, 0x5a, 0x4b, 0x44, 0xc4, 0x43, 0xb9, 0xab, 0xc0, 0xea,
0x7b, 0xf4, 0xae, 0x2f, 0xd1, 0xb7, 0x08, 0xd0, 0x9b, 0xf6, 0x05, 0x8a, 0xc2, 0x57, 0x7d, 0x8c,
0x62, 0x87, 0xa4, 0x48, 0xc5, 0x29, 0xd0, 0xf4, 0x6e, 0xe7, 0x9b, 0x6f, 0x76, 0x3e, 0xee, 0xce,
0xcc, 0x12, 0x6a, 0x72, 0x15, 0x71, 0xd1, 0x89, 0xe2, 0x50, 0x86, 0x04, 0xa2, 0x38, 0xf4, 0xb9,
0x9c, 0xf3, 0xa5, 0xd8, 0xdd, 0x99, 0x85, 0xb3, 0x10, 0xe1, 0x7d, 0xb5, 0x4a, 0x18, 0xee, 0xcf,
0x3a, 0x34, 0x7b, 0x5c, 0xc6, 0xde, 0xa4, 0xc7, 0x25, 0x9b, 0x32, 0xc9, 0xc8, 0x53, 0x28, 0xa9,
0x3d, 0x1c, 0xad, 0xa5, 0xb5, 0x9b, 0x07, 0x8f, 0x3b, 0x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a, 0x52, 0x49, 0xb2, 0xa3, 0xdd, 0x13, 0xee,
0x6f, 0x1a, 0x94, 0x8f, 0xe6, 0xcb, 0xe0, 0x25, 0xd9, 0x85, 0x9a, 0xef, 0x05, 0x63, 0x75, 0xdf,
0x72, 0xcd, 0x96, 0xef, 0x05, 0xaa, 0x87, 0x7b, 0x02, 0xfd, 0xec, 0x7a, 0xed, 0x4f, 0x1f, 0x24,
0x9f, 0x5d, 0xa7, 0xfe, 0x4e, 0x7a, 0x08, 0x06, 0x1e, 0xc2, 0xfd, 0xe2, 0x21, 0x60, 0x81, 0x4e,
0x37, 0x98, 0x84, 0x53, 0x2f, 0x98, 0xe5, 0x27, 0xa0, 0x1e, 0x7a, 0xfc, 0xaa, 0x3a, 0xc5, 0xb5,
0xfb, 0x0c, 0xaa, 0x19, 0xeb, 0xd6, 0xe5, 0xfd, 0x6e, 0xa0, 0xde, 0xe1, 0x8d, 0xc7, 0x57, 0x27,
0xff, 0x83, 0x3b, 0xc7, 0xe7, 0x83, 0x83, 0xd1, 0xb8, 0xf0, 0x22, 0xbb, 0x3f, 0x40, 0x03, 0x2b,
0xf2, 0xe9, 0x7f, 0xbd, 0x7a, 0x7b, 0x60, 0x4e, 0x54, 0x86, 0xec, 0xe6, 0x6d, 0xdf, 0xfa, 0x9a,
0x2c, 0x20, 0xa1, 0x1d, 0xee, 0xbc, 0xbe, 0xd9, 0xd5, 0x7e, 0xbd, 0xd9, 0xd5, 0xfe, 0xb8, 0xd9,
0xd5, 0xbe, 0x37, 0x15, 0x3b, 0xba, 0xbc, 0x34, 0xf1, 0x3f, 0xe8, 0xb3, 0xbf, 0x03, 0x00, 0x00,
0xff, 0xff, 0x8b, 0x63, 0xd6, 0x2e, 0x38, 0x09, 0x00, 0x00,
}
func (m *MetricMetadata) Marshal() (dAtA []byte, err error) {
@ -1385,6 +1394,18 @@ func (m *Histogram) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i -= len(m.XXX_unrecognized)
copy(dAtA[i:], m.XXX_unrecognized)
}
if len(m.CustomValues) > 0 {
for iNdEx := len(m.CustomValues) - 1; iNdEx >= 0; iNdEx-- {
f1 := math.Float64bits(float64(m.CustomValues[iNdEx]))
i -= 8
encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f1))
}
i = encodeVarintTypes(dAtA, i, uint64(len(m.CustomValues)*8))
i--
dAtA[i] = 0x1
i--
dAtA[i] = 0x82
}
if m.Timestamp != 0 {
i = encodeVarintTypes(dAtA, i, uint64(m.Timestamp))
i--
@ -1397,30 +1418,30 @@ func (m *Histogram) MarshalToSizedBuffer(dAtA []byte) (int, error) {
}
if len(m.PositiveCounts) > 0 {
for iNdEx := len(m.PositiveCounts) - 1; iNdEx >= 0; iNdEx-- {
f1 := math.Float64bits(float64(m.PositiveCounts[iNdEx]))
f2 := math.Float64bits(float64(m.PositiveCounts[iNdEx]))
i -= 8
encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f1))
encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f2))
}
i = encodeVarintTypes(dAtA, i, uint64(len(m.PositiveCounts)*8))
i--
dAtA[i] = 0x6a
}
if len(m.PositiveDeltas) > 0 {
var j2 int
dAtA4 := make([]byte, len(m.PositiveDeltas)*10)
var j3 int
dAtA5 := make([]byte, len(m.PositiveDeltas)*10)
for _, num := range m.PositiveDeltas {
x3 := (uint64(num) << 1) ^ uint64((num >> 63))
for x3 >= 1<<7 {
dAtA4[j2] = uint8(uint64(x3)&0x7f | 0x80)
j2++
x3 >>= 7
x4 := (uint64(num) << 1) ^ uint64((num >> 63))
for x4 >= 1<<7 {
dAtA5[j3] = uint8(uint64(x4)&0x7f | 0x80)
j3++
x4 >>= 7
}
dAtA4[j2] = uint8(x3)
j2++
dAtA5[j3] = uint8(x4)
j3++
}
i -= j2
copy(dAtA[i:], dAtA4[:j2])
i = encodeVarintTypes(dAtA, i, uint64(j2))
i -= j3
copy(dAtA[i:], dAtA5[:j3])
i = encodeVarintTypes(dAtA, i, uint64(j3))
i--
dAtA[i] = 0x62
}
@ -1440,30 +1461,30 @@ func (m *Histogram) MarshalToSizedBuffer(dAtA []byte) (int, error) {
}
if len(m.NegativeCounts) > 0 {
for iNdEx := len(m.NegativeCounts) - 1; iNdEx >= 0; iNdEx-- {
f5 := math.Float64bits(float64(m.NegativeCounts[iNdEx]))
f6 := math.Float64bits(float64(m.NegativeCounts[iNdEx]))
i -= 8
encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f5))
encoding_binary.LittleEndian.PutUint64(dAtA[i:], uint64(f6))
}
i = encodeVarintTypes(dAtA, i, uint64(len(m.NegativeCounts)*8))
i--
dAtA[i] = 0x52
}
if len(m.NegativeDeltas) > 0 {
var j6 int
dAtA8 := make([]byte, len(m.NegativeDeltas)*10)
var j7 int
dAtA9 := make([]byte, len(m.NegativeDeltas)*10)
for _, num := range m.NegativeDeltas {
x7 := (uint64(num) << 1) ^ uint64((num >> 63))
for x7 >= 1<<7 {
dAtA8[j6] = uint8(uint64(x7)&0x7f | 0x80)
j6++
x7 >>= 7
x8 := (uint64(num) << 1) ^ uint64((num >> 63))
for x8 >= 1<<7 {
dAtA9[j7] = uint8(uint64(x8)&0x7f | 0x80)
j7++
x8 >>= 7
}
dAtA8[j6] = uint8(x7)
j6++
dAtA9[j7] = uint8(x8)
j7++
}
i -= j6
copy(dAtA[i:], dAtA8[:j6])
i = encodeVarintTypes(dAtA, i, uint64(j6))
i -= j7
copy(dAtA[i:], dAtA9[:j7])
i = encodeVarintTypes(dAtA, i, uint64(j7))
i--
dAtA[i] = 0x4a
}
@ -2133,6 +2154,9 @@ func (m *Histogram) Size() (n int) {
if m.Timestamp != 0 {
n += 1 + sovTypes(uint64(m.Timestamp))
}
if len(m.CustomValues) > 0 {
n += 2 + sovTypes(uint64(len(m.CustomValues)*8)) + len(m.CustomValues)*8
}
if m.XXX_unrecognized != nil {
n += len(m.XXX_unrecognized)
}
@ -3248,6 +3272,60 @@ func (m *Histogram) Unmarshal(dAtA []byte) error {
break
}
}
case 16:
if wireType == 1 {
var v uint64
if (iNdEx + 8) > l {
return io.ErrUnexpectedEOF
}
v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:]))
iNdEx += 8
v2 := float64(math.Float64frombits(v))
m.CustomValues = append(m.CustomValues, v2)
} else if wireType == 2 {
var packedLen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTypes
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
packedLen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if packedLen < 0 {
return ErrInvalidLengthTypes
}
postIndex := iNdEx + packedLen
if postIndex < 0 {
return ErrInvalidLengthTypes
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
var elementCount int
elementCount = packedLen / 8
if elementCount != 0 && len(m.CustomValues) == 0 {
m.CustomValues = make([]float64, 0, elementCount)
}
for iNdEx < postIndex {
var v uint64
if (iNdEx + 8) > l {
return io.ErrUnexpectedEOF
}
v = uint64(encoding_binary.LittleEndian.Uint64(dAtA[iNdEx:]))
iNdEx += 8
v2 := float64(math.Float64frombits(v))
m.CustomValues = append(m.CustomValues, v2)
}
} else {
return fmt.Errorf("proto: wrong wireType = %d for field CustomValues", wireType)
}
default:
iNdEx = preIndex
skippy, err := skipTypes(dAtA[iNdEx:])

View file

@ -107,6 +107,8 @@ message Histogram {
// timestamp is in ms format, see model/timestamp/timestamp.go for
// conversion from time.Time to Prometheus timestamp.
int64 timestamp = 15;
repeated double custom_values = 16;
}
// A BucketSpan defines a number of consecutive buckets with their

View file

@ -168,6 +168,7 @@ func convertBucketsLayout(buckets pmetric.ExponentialHistogramDataPointBuckets,
// The offset is scaled and adjusted by 1 as described above.
bucketIdx := buckets.Offset()>>scaleDown + 1
spans = append(spans, prompb.BucketSpan{
Offset: bucketIdx,
Length: 0,
@ -226,3 +227,159 @@ func convertBucketsLayout(buckets pmetric.ExponentialHistogramDataPointBuckets,
return spans, deltas
}
func (c *PrometheusConverter) addCustomBucketsHistogramDataPoints(ctx context.Context, dataPoints pmetric.HistogramDataPointSlice,
resource pcommon.Resource, settings Settings, promName string) (annotations.Annotations, error) {
var annots annotations.Annotations
for x := 0; x < dataPoints.Len(); x++ {
if err := c.everyN.checkContext(ctx); err != nil {
return annots, err
}
pt := dataPoints.At(x)
histogram, ws, err := histogramToCustomBucketsHistogram(pt)
annots.Merge(ws)
if err != nil {
return annots, err
}
lbls := createAttributes(
resource,
pt.Attributes(),
settings,
nil,
true,
model.MetricNameLabel,
promName,
)
ts, _ := c.getOrCreateTimeSeries(lbls)
ts.Histograms = append(ts.Histograms, histogram)
exemplars, err := getPromExemplars[pmetric.HistogramDataPoint](ctx, &c.everyN, pt)
if err != nil {
return annots, err
}
ts.Exemplars = append(ts.Exemplars, exemplars...)
}
return annots, nil
}
func histogramToCustomBucketsHistogram(p pmetric.HistogramDataPoint) (prompb.Histogram, annotations.Annotations, error) {
var annots annotations.Annotations
positiveSpans, positiveDeltas := convertHistogramBucketsToNHCBLayout(p.BucketCounts().AsRaw())
h := prompb.Histogram{
// The counter reset detection must be compatible with Prometheus to
// safely set ResetHint to NO. This is not ensured currently.
// Sending a sample that triggers counter reset but with ResetHint==NO
// would lead to Prometheus panic as it does not double check the hint.
// Thus we're explicitly saying UNKNOWN here, which is always safe.
// TODO: using created time stamp should be accurate, but we
// need to know here if it was used for the detection.
// Ref: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/28663#issuecomment-1810577303
// Counter reset detection in Prometheus: https://github.com/prometheus/prometheus/blob/f997c72f294c0f18ca13fa06d51889af04135195/tsdb/chunkenc/histogram.go#L232
ResetHint: prompb.Histogram_UNKNOWN,
Schema: -53,
PositiveSpans: positiveSpans,
PositiveDeltas: positiveDeltas,
CustomValues: p.ExplicitBounds().AsRaw(),
Timestamp: convertTimeStamp(p.Timestamp()),
}
if p.Flags().NoRecordedValue() {
h.Sum = math.Float64frombits(value.StaleNaN)
h.Count = &prompb.Histogram_CountInt{CountInt: value.StaleNaN}
} else {
if p.HasSum() {
h.Sum = p.Sum()
}
h.Count = &prompb.Histogram_CountInt{CountInt: p.Count()}
if p.Count() == 0 && h.Sum != 0 {
annots.Add(fmt.Errorf("histogram data point has zero count, but non-zero sum: %f", h.Sum))
}
}
return h, annots, nil
}
func convertHistogramBucketsToNHCBLayout(buckets []uint64) ([]prompb.BucketSpan, []int64) {
if len(buckets) == 0 {
return nil, nil
}
var (
spans []prompb.BucketSpan
deltas []int64
count int64
prevCount int64
)
appendDelta := func(count int64) {
spans[len(spans)-1].Length++
deltas = append(deltas, count-prevCount)
prevCount = count
}
var offset int
for offset < len(buckets) && buckets[offset] == 0 {
offset++
}
bucketCounts := buckets[offset:]
bucketIdx := offset + 1
spans = append(spans, prompb.BucketSpan{
Offset: int32(offset),
Length: 0,
})
for i := 0; i < len(bucketCounts); i++ {
nextBucketIdx := offset + i + 1
if bucketIdx == nextBucketIdx { // We have not collected enough buckets to merge yet.
count += int64(bucketCounts[i])
continue
}
if count == 0 {
count = int64(bucketCounts[i])
continue
}
iDelta := nextBucketIdx - bucketIdx - 1
if iDelta > 2 {
spans = append(spans, prompb.BucketSpan{
Offset: int32(iDelta),
Length: 0,
})
} else {
// Either no gap or a gap <= 2
for j := int32(0); j < int32(iDelta); j++ {
appendDelta(0)
}
}
appendDelta(count)
count = int64(bucketCounts[i])
bucketIdx = nextBucketIdx
}
iDelta := int32(len(bucketCounts)+offset-1) + 1 - int32(bucketIdx)
if iDelta > 2 {
spans = append(spans, prompb.BucketSpan{
Offset: iDelta,
Length: 0,
})
} else {
for j := int32(0); j < iDelta; j++ {
appendDelta(0)
}
}
appendDelta(count)
return spans, deltas
}

View file

@ -40,6 +40,7 @@ type Settings struct {
AllowUTF8 bool
PromoteResourceAttributes []string
KeepIdentifyingResourceAttributes bool
ConvertHistogramsToNHCB bool
}
// PrometheusConverter converts from OTel write format to Prometheus remote write format.
@ -142,10 +143,21 @@ func (c *PrometheusConverter) FromMetrics(ctx context.Context, md pmetric.Metric
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name()))
break
}
if err := c.addHistogramDataPoints(ctx, dataPoints, resource, settings, promName); err != nil {
errs = multierr.Append(errs, err)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return
if settings.ConvertHistogramsToNHCB {
ws, err := c.addCustomBucketsHistogramDataPoints(ctx, dataPoints, resource, settings, promName)
annots.Merge(ws)
if err != nil {
errs = multierr.Append(errs, err)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return
}
}
} else {
if err := c.addHistogramDataPoints(ctx, dataPoints, resource, settings, promName); err != nil {
errs = multierr.Append(errs, err)
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return
}
}
}
case pmetric.MetricTypeExponentialHistogram:

View file

@ -581,6 +581,7 @@ func (rw *rwExporter) ConsumeMetrics(ctx context.Context, md pmetric.Metrics) er
AllowUTF8: otlpCfg.TranslationStrategy == config.NoUTF8EscapingWithSuffixes,
PromoteResourceAttributes: otlpCfg.PromoteResourceAttributes,
KeepIdentifyingResourceAttributes: otlpCfg.KeepIdentifyingResourceAttributes,
ConvertHistogramsToNHCB: otlpCfg.ConvertHistogramsToNHCB,
})
if err != nil {
rw.logger.Warn("Error translating OTLP metrics to Prometheus write request", "err", err)