Remove base labels.
This commit is contained in:
parent
65a55bbf4e
commit
89432f861e
|
@ -81,9 +81,6 @@ func extractCounter(out Ingester, o *ProcessOptions, f *dto.MetricFamily) error
|
||||||
sample.Metric = model.Metric{}
|
sample.Metric = model.Metric{}
|
||||||
metric := sample.Metric
|
metric := sample.Metric
|
||||||
|
|
||||||
for l, v := range o.BaseLabels {
|
|
||||||
metric[l] = v
|
|
||||||
}
|
|
||||||
for _, p := range m.Label {
|
for _, p := range m.Label {
|
||||||
metric[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
|
metric[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
|
||||||
}
|
}
|
||||||
|
@ -111,9 +108,6 @@ func extractGauge(out Ingester, o *ProcessOptions, f *dto.MetricFamily) error {
|
||||||
sample.Metric = model.Metric{}
|
sample.Metric = model.Metric{}
|
||||||
metric := sample.Metric
|
metric := sample.Metric
|
||||||
|
|
||||||
for l, v := range o.BaseLabels {
|
|
||||||
metric[l] = v
|
|
||||||
}
|
|
||||||
for _, p := range m.Label {
|
for _, p := range m.Label {
|
||||||
metric[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
|
metric[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
|
||||||
}
|
}
|
||||||
|
@ -143,9 +137,6 @@ func extractSummary(out Ingester, o *ProcessOptions, f *dto.MetricFamily) error
|
||||||
sample.Metric = model.Metric{}
|
sample.Metric = model.Metric{}
|
||||||
metric := sample.Metric
|
metric := sample.Metric
|
||||||
|
|
||||||
for l, v := range o.BaseLabels {
|
|
||||||
metric[l] = v
|
|
||||||
}
|
|
||||||
for _, p := range m.Label {
|
for _, p := range m.Label {
|
||||||
metric[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
|
metric[model.LabelName(p.GetName())] = model.LabelValue(p.GetValue())
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,6 @@ func (s *metricFamilyProcessorScenario) test(t *testing.T, set int) {
|
||||||
|
|
||||||
o := &ProcessOptions{
|
o := &ProcessOptions{
|
||||||
Timestamp: testTime,
|
Timestamp: testTime,
|
||||||
BaseLabels: model.LabelSet{"base": "label"},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err := MetricFamilyProcessor.ProcessSingle(i, s, o)
|
err := MetricFamilyProcessor.ProcessSingle(i, s, o)
|
||||||
|
@ -72,12 +71,12 @@ func TestMetricFamilyProcessor(t *testing.T) {
|
||||||
{
|
{
|
||||||
Samples: model.Samples{
|
Samples: model.Samples{
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"base": "label", "name": "request_count", "some_label_name": "some_label_value"},
|
Metric: model.Metric{"name": "request_count", "some_label_name": "some_label_value"},
|
||||||
Value: -42,
|
Value: -42,
|
||||||
Timestamp: testTime,
|
Timestamp: testTime,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"base": "label", "name": "request_count", "another_label_name": "another_label_value"},
|
Metric: model.Metric{"name": "request_count", "another_label_name": "another_label_value"},
|
||||||
Value: 84,
|
Value: 84,
|
||||||
Timestamp: testTime,
|
Timestamp: testTime,
|
||||||
},
|
},
|
||||||
|
@ -91,17 +90,17 @@ func TestMetricFamilyProcessor(t *testing.T) {
|
||||||
{
|
{
|
||||||
Samples: model.Samples{
|
Samples: model.Samples{
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"base": "label", "name": "request_count", "some_label_name": "some_label_value", "quantile": "0.99"},
|
Metric: model.Metric{"name": "request_count", "some_label_name": "some_label_value", "quantile": "0.99"},
|
||||||
Value: -42,
|
Value: -42,
|
||||||
Timestamp: testTime,
|
Timestamp: testTime,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"base": "label", "name": "request_count", "some_label_name": "some_label_value", "quantile": "0.999"},
|
Metric: model.Metric{"name": "request_count", "some_label_name": "some_label_value", "quantile": "0.999"},
|
||||||
Value: -84,
|
Value: -84,
|
||||||
Timestamp: testTime,
|
Timestamp: testTime,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"base": "label", "name": "request_count", "another_label_name": "another_label_value", "quantile": "0.5"},
|
Metric: model.Metric{"name": "request_count", "another_label_name": "another_label_value", "quantile": "0.5"},
|
||||||
Value: 10,
|
Value: 10,
|
||||||
Timestamp: testTime,
|
Timestamp: testTime,
|
||||||
},
|
},
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
package extraction
|
package extraction
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -25,9 +26,6 @@ import (
|
||||||
type ProcessOptions struct {
|
type ProcessOptions struct {
|
||||||
// Timestamp is added to each value interpreted from the stream.
|
// Timestamp is added to each value interpreted from the stream.
|
||||||
Timestamp time.Time
|
Timestamp time.Time
|
||||||
|
|
||||||
// BaseLabels are labels that are accumulated onto each sample, if any.
|
|
||||||
BaseLabels model.LabelSet
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ingester consumes result streams in whatever way is desired by the user.
|
// Ingester consumes result streams in whatever way is desired by the user.
|
||||||
|
@ -58,31 +56,6 @@ func labelSet(labels map[string]string) model.LabelSet {
|
||||||
return labelset
|
return labelset
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to merge a target's base labels ontop of the labels of an
|
|
||||||
// exported sample. If a label is already defined in the exported sample, we
|
|
||||||
// assume that we are scraping an intermediate exporter and attach
|
|
||||||
// "exporter_"-prefixes to Prometheus' own base labels.
|
|
||||||
func mergeTargetLabels(entityLabels, targetLabels model.LabelSet) model.LabelSet {
|
|
||||||
if targetLabels == nil {
|
|
||||||
targetLabels = model.LabelSet{}
|
|
||||||
}
|
|
||||||
|
|
||||||
result := model.LabelSet{}
|
|
||||||
|
|
||||||
for label, value := range entityLabels {
|
|
||||||
result[label] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
for label, labelValue := range targetLabels {
|
|
||||||
if _, exists := result[label]; exists {
|
|
||||||
result[model.ExporterLabelPrefix+label] = labelValue
|
|
||||||
} else {
|
|
||||||
result[label] = labelValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
// Result encapsulates the outcome from processing samples from a source.
|
// Result encapsulates the outcome from processing samples from a source.
|
||||||
type Result struct {
|
type Result struct {
|
||||||
Err error
|
Err error
|
||||||
|
@ -96,15 +69,18 @@ func (r *Result) equal(o *Result) bool {
|
||||||
|
|
||||||
if r.Err != o.Err {
|
if r.Err != o.Err {
|
||||||
if r.Err == nil || o.Err == nil {
|
if r.Err == nil || o.Err == nil {
|
||||||
|
fmt.Println("err nil")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.Err.Error() != o.Err.Error() {
|
if r.Err.Error() != o.Err.Error() {
|
||||||
|
fmt.Println("err str")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(r.Samples) != len(o.Samples) {
|
if len(r.Samples) != len(o.Samples) {
|
||||||
|
fmt.Println("samples len")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,6 +88,7 @@ func (r *Result) equal(o *Result) bool {
|
||||||
other := o.Samples[i]
|
other := o.Samples[i]
|
||||||
|
|
||||||
if !mine.Equal(other) {
|
if !mine.Equal(other) {
|
||||||
|
fmt.Println("samples", mine, other)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,7 @@ func (p *processor001) ProcessSingle(in io.Reader, out Ingester, o *ProcessOptio
|
||||||
pendingSamples := model.Samples{}
|
pendingSamples := model.Samples{}
|
||||||
for _, entity := range entities {
|
for _, entity := range entities {
|
||||||
for _, value := range entity.Metric.Value {
|
for _, value := range entity.Metric.Value {
|
||||||
entityLabels := labelSet(entity.BaseLabels).Merge(labelSet(value.Labels))
|
labels := labelSet(entity.BaseLabels).Merge(labelSet(value.Labels))
|
||||||
labels := mergeTargetLabels(entityLabels, o.BaseLabels)
|
|
||||||
|
|
||||||
switch entity.Metric.MetricType {
|
switch entity.Metric.MetricType {
|
||||||
case gauge001, counter001:
|
case gauge001, counter001:
|
||||||
|
|
|
@ -29,7 +29,6 @@ var test001Time = time.Now()
|
||||||
|
|
||||||
type testProcessor001ProcessScenario struct {
|
type testProcessor001ProcessScenario struct {
|
||||||
in string
|
in string
|
||||||
baseLabels model.LabelSet
|
|
||||||
expected, actual []*Result
|
expected, actual []*Result
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
@ -47,7 +46,6 @@ func (s *testProcessor001ProcessScenario) test(t test.Tester, set int) {
|
||||||
|
|
||||||
options := &ProcessOptions{
|
options := &ProcessOptions{
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
BaseLabels: s.baseLabels,
|
|
||||||
}
|
}
|
||||||
if err := Processor001.ProcessSingle(reader, s, options); !test.ErrorEqual(s.err, err) {
|
if err := Processor001.ProcessSingle(reader, s, options); !test.ErrorEqual(s.err, err) {
|
||||||
t.Fatalf("%d. expected err of %s, got %s", set, s.err, err)
|
t.Fatalf("%d. expected err of %s, got %s", set, s.err, err)
|
||||||
|
@ -75,101 +73,98 @@ func testProcessor001Process(t test.Tester) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
in: "test0_0_1-0_0_2.json",
|
in: "test0_0_1-0_0_2.json",
|
||||||
baseLabels: model.LabelSet{
|
|
||||||
model.JobLabel: "batch_exporter",
|
|
||||||
},
|
|
||||||
expected: []*Result{
|
expected: []*Result{
|
||||||
{
|
{
|
||||||
Samples: model.Samples{
|
Samples: model.Samples{
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"service": "zed", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job", "exporter_job": "batch_exporter"},
|
Metric: model.Metric{"service": "zed", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job"},
|
||||||
Value: 25,
|
Value: 25,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"service": "bar", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job", "exporter_job": "batch_exporter"},
|
Metric: model.Metric{"service": "bar", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job"},
|
||||||
Value: 25,
|
Value: 25,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"service": "foo", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job", "exporter_job": "batch_exporter"},
|
Metric: model.Metric{"service": "foo", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job"},
|
||||||
Value: 25,
|
Value: 25,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
Value: 0.0459814091918713,
|
Value: 0.0459814091918713,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
Value: 78.48563317257356,
|
Value: 78.48563317257356,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
Value: 15.890724674774395,
|
Value: 15.890724674774395,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
|
|
||||||
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
Value: 0.0459814091918713,
|
Value: 0.0459814091918713,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
Value: 78.48563317257356,
|
Value: 78.48563317257356,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
Value: 15.890724674774395,
|
Value: 15.890724674774395,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
Value: 0.6120456642749681,
|
Value: 0.6120456642749681,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
|
|
||||||
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
Value: 97.31798360385088,
|
Value: 97.31798360385088,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
Value: 84.63044031436561,
|
Value: 84.63044031436561,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
Value: 1.355915069887731,
|
Value: 1.355915069887731,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
Value: 109.89202084295582,
|
Value: 109.89202084295582,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
Value: 160.21100853053224,
|
Value: 160.21100853053224,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
Value: 1.772733213161236,
|
Value: 1.772733213161236,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
Value: 109.99626121011262,
|
Value: 109.99626121011262,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
Value: 172.49828748957728,
|
Value: 172.49828748957728,
|
||||||
Timestamp: test001Time,
|
Timestamp: test001Time,
|
||||||
},
|
},
|
||||||
|
|
|
@ -68,8 +68,7 @@ func (p *processor002) ProcessSingle(in io.Reader, out Ingester, o *ProcessOptio
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, counter := range values {
|
for _, counter := range values {
|
||||||
entityLabels := labelSet(entity.BaseLabels).Merge(labelSet(counter.Labels))
|
labels := labelSet(entity.BaseLabels).Merge(labelSet(counter.Labels))
|
||||||
labels := mergeTargetLabels(entityLabels, o.BaseLabels)
|
|
||||||
|
|
||||||
pendingSamples = append(pendingSamples, &model.Sample{
|
pendingSamples = append(pendingSamples, &model.Sample{
|
||||||
Metric: model.Metric(labels),
|
Metric: model.Metric(labels),
|
||||||
|
@ -91,9 +90,8 @@ func (p *processor002) ProcessSingle(in io.Reader, out Ingester, o *ProcessOptio
|
||||||
|
|
||||||
for _, histogram := range values {
|
for _, histogram := range values {
|
||||||
for percentile, value := range histogram.Values {
|
for percentile, value := range histogram.Values {
|
||||||
entityLabels := labelSet(entity.BaseLabels).Merge(labelSet(histogram.Labels))
|
labels := labelSet(entity.BaseLabels).Merge(labelSet(histogram.Labels))
|
||||||
entityLabels[model.LabelName("percentile")] = model.LabelValue(percentile)
|
labels[model.LabelName("percentile")] = model.LabelValue(percentile)
|
||||||
labels := mergeTargetLabels(entityLabels, o.BaseLabels)
|
|
||||||
|
|
||||||
pendingSamples = append(pendingSamples, &model.Sample{
|
pendingSamples = append(pendingSamples, &model.Sample{
|
||||||
Metric: model.Metric(labels),
|
Metric: model.Metric(labels),
|
||||||
|
|
|
@ -30,7 +30,6 @@ var test002Time = time.Now()
|
||||||
|
|
||||||
type testProcessor002ProcessScenario struct {
|
type testProcessor002ProcessScenario struct {
|
||||||
in string
|
in string
|
||||||
baseLabels model.LabelSet
|
|
||||||
expected, actual []*Result
|
expected, actual []*Result
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
@ -48,7 +47,6 @@ func (s *testProcessor002ProcessScenario) test(t test.Tester, set int) {
|
||||||
|
|
||||||
options := &ProcessOptions{
|
options := &ProcessOptions{
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
BaseLabels: s.baseLabels,
|
|
||||||
}
|
}
|
||||||
if err := Processor002.ProcessSingle(reader, s, options); !test.ErrorEqual(s.err, err) {
|
if err := Processor002.ProcessSingle(reader, s, options); !test.ErrorEqual(s.err, err) {
|
||||||
t.Fatalf("%d. expected err of %s, got %s", set, s.err, err)
|
t.Fatalf("%d. expected err of %s, got %s", set, s.err, err)
|
||||||
|
@ -76,100 +74,98 @@ func testProcessor002Process(t test.Tester) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
in: "test0_0_1-0_0_2.json",
|
in: "test0_0_1-0_0_2.json",
|
||||||
baseLabels: model.LabelSet{
|
|
||||||
model.JobLabel: "batch_exporter",
|
|
||||||
},
|
|
||||||
expected: []*Result{
|
expected: []*Result{
|
||||||
{
|
{
|
||||||
Samples: model.Samples{
|
Samples: model.Samples{
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"service": "zed", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job", "exporter_job": "batch_exporter"},
|
Metric: model.Metric{"service": "zed", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job"},
|
||||||
Value: 25,
|
Value: 25,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"service": "bar", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job", "exporter_job": "batch_exporter"},
|
Metric: model.Metric{"service": "bar", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job"},
|
||||||
Value: 25,
|
Value: 25,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"service": "foo", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job", "exporter_job": "batch_exporter"},
|
Metric: model.Metric{"service": "foo", model.MetricNameLabel: "rpc_calls_total", "job": "batch_job"},
|
||||||
Value: 25,
|
Value: 25,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
Value: 0.0459814091918713,
|
Value: 0.0459814091918713,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
Value: 78.48563317257356,
|
Value: 78.48563317257356,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.010000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
Value: 15.890724674774395,
|
Value: 15.890724674774395,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
|
||||||
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
|
||||||
Value: 0.0459814091918713,
|
|
||||||
Timestamp: test002Time,
|
|
||||||
},
|
|
||||||
&model.Sample{
|
|
||||||
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
|
||||||
Value: 78.48563317257356,
|
|
||||||
Timestamp: test002Time,
|
|
||||||
},
|
|
||||||
&model.Sample{
|
|
||||||
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
|
||||||
Value: 15.890724674774395,
|
|
||||||
Timestamp: test002Time,
|
|
||||||
},
|
|
||||||
&model.Sample{
|
|
||||||
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
|
||||||
Value: 0.6120456642749681,
|
|
||||||
Timestamp: test002Time,
|
|
||||||
},
|
|
||||||
&model.Sample{
|
|
||||||
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
|
||||||
Value: 97.31798360385088,
|
|
||||||
Timestamp: test002Time,
|
|
||||||
},
|
|
||||||
&model.Sample{
|
|
||||||
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
|
||||||
Value: 84.63044031436561,
|
|
||||||
Timestamp: test002Time,
|
|
||||||
},
|
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
|
|
||||||
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
|
Value: 0.0459814091918713,
|
||||||
|
Timestamp: test002Time,
|
||||||
|
},
|
||||||
|
&model.Sample{
|
||||||
|
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
|
Value: 78.48563317257356,
|
||||||
|
Timestamp: test002Time,
|
||||||
|
},
|
||||||
|
&model.Sample{
|
||||||
|
Metric: model.Metric{"percentile": "0.050000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
|
Value: 15.890724674774395,
|
||||||
|
Timestamp: test002Time,
|
||||||
|
},
|
||||||
|
&model.Sample{
|
||||||
|
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
|
Value: 0.6120456642749681,
|
||||||
|
Timestamp: test002Time,
|
||||||
|
},
|
||||||
|
&model.Sample{
|
||||||
|
|
||||||
|
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
|
Value: 97.31798360385088,
|
||||||
|
Timestamp: test002Time,
|
||||||
|
},
|
||||||
|
&model.Sample{
|
||||||
|
Metric: model.Metric{"percentile": "0.500000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
|
Value: 84.63044031436561,
|
||||||
|
Timestamp: test002Time,
|
||||||
|
},
|
||||||
|
&model.Sample{
|
||||||
|
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
Value: 1.355915069887731,
|
Value: 1.355915069887731,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
Value: 109.89202084295582,
|
Value: 109.89202084295582,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.900000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
Value: 160.21100853053224,
|
Value: 160.21100853053224,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "zed"},
|
||||||
Value: 1.772733213161236,
|
Value: 1.772733213161236,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "bar"},
|
||||||
Value: 109.99626121011262,
|
Value: 109.99626121011262,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
&model.Sample{
|
&model.Sample{
|
||||||
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo", "job": "batch_exporter"},
|
Metric: model.Metric{"percentile": "0.990000", model.MetricNameLabel: "rpc_latency_microseconds", "service": "foo"},
|
||||||
Value: 172.49828748957728,
|
Value: 172.49828748957728,
|
||||||
Timestamp: test002Time,
|
Timestamp: test002Time,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue