mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
WIP
This commit is contained in:
parent
ad20b23cf1
commit
b1096fe71b
|
@ -234,7 +234,7 @@ func StreamChunkedReadResponses(
|
|||
for ss.Next() {
|
||||
series := ss.At()
|
||||
iter = series.Iterator(iter)
|
||||
lbls = MergeLabels(prompb.FromLabels(series.Labels(), lbls), sortedExternalLabels)
|
||||
lbls = MergeLabels(prompb.FromLabels(series.Labels(), lbls), sortedExternalLabels)
|
||||
|
||||
maxDataLength := maxBytesInFrame
|
||||
for _, lbl := range lbls {
|
||||
|
|
|
@ -20,12 +20,12 @@ import (
|
|||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"go.opentelemetry.io/collector/pdata/pcommon"
|
||||
"go.opentelemetry.io/collector/pdata/pmetric"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/prometheus/common/model"
|
||||
|
||||
|
|
|
@ -448,9 +448,9 @@ func TestExponentialToNativeHistogram(t *testing.T) {
|
|||
Schema: 1,
|
||||
ZeroThreshold: defaultZeroThreshold,
|
||||
ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: 1},
|
||||
NegativeSpans: []prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
NegativeSpans: []*prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
NegativeDeltas: []int64{1, 0},
|
||||
PositiveSpans: []prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
PositiveSpans: []*prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
PositiveDeltas: []int64{1, 0},
|
||||
Timestamp: 500,
|
||||
}
|
||||
|
@ -481,9 +481,9 @@ func TestExponentialToNativeHistogram(t *testing.T) {
|
|||
Schema: 1,
|
||||
ZeroThreshold: defaultZeroThreshold,
|
||||
ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: 1},
|
||||
NegativeSpans: []prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
NegativeSpans: []*prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
NegativeDeltas: []int64{1, 0},
|
||||
PositiveSpans: []prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
PositiveSpans: []*prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
PositiveDeltas: []int64{1, 0},
|
||||
Timestamp: 500,
|
||||
}
|
||||
|
@ -523,9 +523,9 @@ func TestExponentialToNativeHistogram(t *testing.T) {
|
|||
Schema: 8,
|
||||
ZeroThreshold: defaultZeroThreshold,
|
||||
ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: 1},
|
||||
PositiveSpans: []prompb.BucketSpan{{Offset: 2, Length: 3}},
|
||||
PositiveSpans: []*prompb.BucketSpan{{Offset: 2, Length: 3}},
|
||||
PositiveDeltas: []int64{1, 0, 0}, // 1, 1, 1
|
||||
NegativeSpans: []prompb.BucketSpan{{Offset: 3, Length: 3}},
|
||||
NegativeSpans: []*prompb.BucketSpan{{Offset: 3, Length: 3}},
|
||||
NegativeDeltas: []int64{1, 0, 0}, // 1, 1, 1
|
||||
Timestamp: 500,
|
||||
}
|
||||
|
@ -555,9 +555,9 @@ func TestExponentialToNativeHistogram(t *testing.T) {
|
|||
Schema: 8,
|
||||
ZeroThreshold: defaultZeroThreshold,
|
||||
ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: 1},
|
||||
PositiveSpans: []prompb.BucketSpan{{Offset: 1, Length: 2}},
|
||||
PositiveSpans: []*prompb.BucketSpan{{Offset: 1, Length: 2}},
|
||||
PositiveDeltas: []int64{1, 1}, // 0+1, 1+1 = 1, 2
|
||||
NegativeSpans: []prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
NegativeSpans: []*prompb.BucketSpan{{Offset: 2, Length: 2}},
|
||||
NegativeDeltas: []int64{2, -1}, // 1+1, 1+0 = 2, 1
|
||||
Timestamp: 500,
|
||||
}
|
||||
|
@ -575,8 +575,8 @@ func TestExponentialToNativeHistogram(t *testing.T) {
|
|||
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, annots)
|
||||
assert.Equal(t, tt.wantNativeHist(), got)
|
||||
validateNativeHistogramCount(t, got)
|
||||
assert.Equal(t, tt.wantNativeHist(), *got)
|
||||
validateNativeHistogramCount(t, *got)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -644,20 +644,20 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||
return metric
|
||||
},
|
||||
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
||||
labels := []prompb.Label{
|
||||
labels := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test_hist"},
|
||||
{Name: "attr", Value: "test_attr"},
|
||||
}
|
||||
return map[uint64]*prompb.TimeSeries{
|
||||
timeSeriesSignature(labels): {
|
||||
Labels: labels,
|
||||
Histograms: []prompb.Histogram{
|
||||
Histograms: []*prompb.Histogram{
|
||||
{
|
||||
Count: &prompb.Histogram_CountInt{CountInt: 7},
|
||||
Schema: 1,
|
||||
ZeroThreshold: defaultZeroThreshold,
|
||||
ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: 0},
|
||||
PositiveSpans: []prompb.BucketSpan{{Offset: 0, Length: 2}},
|
||||
PositiveSpans: []*prompb.BucketSpan{{Offset: 0, Length: 2}},
|
||||
PositiveDeltas: []int64{4, -2},
|
||||
},
|
||||
{
|
||||
|
@ -665,11 +665,11 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||
Schema: 1,
|
||||
ZeroThreshold: defaultZeroThreshold,
|
||||
ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: 0},
|
||||
PositiveSpans: []prompb.BucketSpan{{Offset: 0, Length: 3}},
|
||||
PositiveSpans: []*prompb.BucketSpan{{Offset: 0, Length: 3}},
|
||||
PositiveDeltas: []int64{4, -2, -1},
|
||||
},
|
||||
},
|
||||
Exemplars: []prompb.Exemplar{
|
||||
Exemplars: []*prompb.Exemplar{
|
||||
{Value: 1},
|
||||
{Value: 2},
|
||||
},
|
||||
|
@ -703,11 +703,11 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||
return metric
|
||||
},
|
||||
wantSeries: func() map[uint64]*prompb.TimeSeries {
|
||||
labels := []prompb.Label{
|
||||
labels := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test_hist"},
|
||||
{Name: "attr", Value: "test_attr"},
|
||||
}
|
||||
labelsAnother := []prompb.Label{
|
||||
labelsAnother := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test_hist"},
|
||||
{Name: "attr", Value: "test_attr_two"},
|
||||
}
|
||||
|
@ -715,33 +715,33 @@ func TestPrometheusConverter_addExponentialHistogramDataPoints(t *testing.T) {
|
|||
return map[uint64]*prompb.TimeSeries{
|
||||
timeSeriesSignature(labels): {
|
||||
Labels: labels,
|
||||
Histograms: []prompb.Histogram{
|
||||
Histograms: []*prompb.Histogram{
|
||||
{
|
||||
Count: &prompb.Histogram_CountInt{CountInt: 7},
|
||||
Schema: 1,
|
||||
ZeroThreshold: defaultZeroThreshold,
|
||||
ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: 0},
|
||||
PositiveSpans: []prompb.BucketSpan{{Offset: 0, Length: 2}},
|
||||
PositiveSpans: []*prompb.BucketSpan{{Offset: 0, Length: 2}},
|
||||
PositiveDeltas: []int64{4, -2},
|
||||
},
|
||||
},
|
||||
Exemplars: []prompb.Exemplar{
|
||||
Exemplars: []*prompb.Exemplar{
|
||||
{Value: 1},
|
||||
},
|
||||
},
|
||||
timeSeriesSignature(labelsAnother): {
|
||||
Labels: labelsAnother,
|
||||
Histograms: []prompb.Histogram{
|
||||
Histograms: []*prompb.Histogram{
|
||||
{
|
||||
Count: &prompb.Histogram_CountInt{CountInt: 4},
|
||||
Schema: 1,
|
||||
ZeroThreshold: defaultZeroThreshold,
|
||||
ZeroCount: &prompb.Histogram_ZeroCountInt{ZeroCountInt: 0},
|
||||
NegativeSpans: []prompb.BucketSpan{{Offset: 0, Length: 3}},
|
||||
NegativeSpans: []*prompb.BucketSpan{{Offset: 0, Length: 3}},
|
||||
NegativeDeltas: []int64{4, -2, -1},
|
||||
},
|
||||
},
|
||||
Exemplars: []prompb.Exemplar{
|
||||
Exemplars: []*prompb.Exemplar{
|
||||
{Value: 2},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -45,13 +45,13 @@ func TestPrometheusConverter_addGaugeNumberDataPoints(t *testing.T) {
|
|||
)
|
||||
},
|
||||
want: func() map[uint64]*prompb.TimeSeries {
|
||||
labels := []prompb.Label{
|
||||
labels := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test"},
|
||||
}
|
||||
return map[uint64]*prompb.TimeSeries{
|
||||
timeSeriesSignature(labels): {
|
||||
Labels: labels,
|
||||
Samples: []prompb.Sample{
|
||||
Samples: []*prompb.Sample{
|
||||
{
|
||||
Value: 1,
|
||||
Timestamp: convertTimeStamp(pcommon.Timestamp(ts)),
|
||||
|
@ -100,13 +100,13 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||
)
|
||||
},
|
||||
want: func() map[uint64]*prompb.TimeSeries {
|
||||
labels := []prompb.Label{
|
||||
labels := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test"},
|
||||
}
|
||||
return map[uint64]*prompb.TimeSeries{
|
||||
timeSeriesSignature(labels): {
|
||||
Labels: labels,
|
||||
Samples: []prompb.Sample{
|
||||
Samples: []*prompb.Sample{
|
||||
{
|
||||
Value: 1,
|
||||
Timestamp: convertTimeStamp(ts),
|
||||
|
@ -128,17 +128,17 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||
return m
|
||||
},
|
||||
want: func() map[uint64]*prompb.TimeSeries {
|
||||
labels := []prompb.Label{
|
||||
labels := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test"},
|
||||
}
|
||||
return map[uint64]*prompb.TimeSeries{
|
||||
timeSeriesSignature(labels): {
|
||||
Labels: labels,
|
||||
Samples: []prompb.Sample{{
|
||||
Samples: []*prompb.Sample{{
|
||||
Value: 1,
|
||||
Timestamp: convertTimeStamp(ts),
|
||||
}},
|
||||
Exemplars: []prompb.Exemplar{
|
||||
Exemplars: []*prompb.Exemplar{
|
||||
{Value: 2},
|
||||
},
|
||||
},
|
||||
|
@ -161,22 +161,22 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||
return metric
|
||||
},
|
||||
want: func() map[uint64]*prompb.TimeSeries {
|
||||
labels := []prompb.Label{
|
||||
labels := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test_sum"},
|
||||
}
|
||||
createdLabels := []prompb.Label{
|
||||
createdLabels := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test_sum" + createdSuffix},
|
||||
}
|
||||
return map[uint64]*prompb.TimeSeries{
|
||||
timeSeriesSignature(labels): {
|
||||
Labels: labels,
|
||||
Samples: []prompb.Sample{
|
||||
Samples: []*prompb.Sample{
|
||||
{Value: 1, Timestamp: convertTimeStamp(ts)},
|
||||
},
|
||||
},
|
||||
timeSeriesSignature(createdLabels): {
|
||||
Labels: createdLabels,
|
||||
Samples: []prompb.Sample{
|
||||
Samples: []*prompb.Sample{
|
||||
{Value: float64(convertTimeStamp(ts)), Timestamp: convertTimeStamp(ts)},
|
||||
},
|
||||
},
|
||||
|
@ -197,13 +197,13 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||
return metric
|
||||
},
|
||||
want: func() map[uint64]*prompb.TimeSeries {
|
||||
labels := []prompb.Label{
|
||||
labels := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test_sum"},
|
||||
}
|
||||
return map[uint64]*prompb.TimeSeries{
|
||||
timeSeriesSignature(labels): {
|
||||
Labels: labels,
|
||||
Samples: []prompb.Sample{
|
||||
Samples: []*prompb.Sample{
|
||||
{Value: 0, Timestamp: convertTimeStamp(ts)},
|
||||
},
|
||||
},
|
||||
|
@ -224,13 +224,13 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
|
|||
return metric
|
||||
},
|
||||
want: func() map[uint64]*prompb.TimeSeries {
|
||||
labels := []prompb.Label{
|
||||
labels := []*prompb.Label{
|
||||
{Name: model.MetricNameLabel, Value: "test_sum"},
|
||||
}
|
||||
return map[uint64]*prompb.TimeSeries{
|
||||
timeSeriesSignature(labels): {
|
||||
Labels: labels,
|
||||
Samples: []prompb.Sample{
|
||||
Samples: []*prompb.Sample{
|
||||
{Value: 0, Timestamp: convertTimeStamp(ts)},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue