MetricPersistence.AppendSample signature changes.

``MetricPersistence.AppendSample(*model.Sample)`` -> ``MetricPersistence.AppendSample(model.Sample)``.
This commit is contained in:
Matt T. Proud 2013-02-13 13:46:28 -08:00
parent 7b2ee03e90
commit 4fbcea73f5
7 changed files with 22 additions and 21 deletions

View file

@ -79,11 +79,12 @@ func main() {
select {
case scrapeResult := <-scrapeResults:
if scrapeResult.Err == nil {
persistence.AppendSample(&scrapeResult.Sample)
persistence.AppendSample(scrapeResult.Sample)
}
case ruleResult := <-ruleResults:
for _, sample := range ruleResult.Samples {
persistence.AppendSample(sample)
// XXX: Wart
persistence.AppendSample(*sample)
}
}
}

View file

@ -54,7 +54,7 @@ func getTestVectorFromTestMatrix(matrix ast.Matrix) ast.Vector {
func storeMatrix(persistence metric.MetricPersistence, matrix ast.Matrix) error {
for _, sampleSet := range matrix {
for _, sample := range sampleSet.Values {
err := persistence.AppendSample(&model.Sample{
err := persistence.AppendSample(model.Sample{
Metric: sampleSet.Metric,
Value: sample.Value,
Timestamp: sample.Timestamp,

View file

@ -30,7 +30,7 @@ type MetricPersistence interface {
Close() error
// Record a new sample in the storage layer.
AppendSample(sample *model.Sample) error
AppendSample(sample model.Sample) error
// Get all of the metric fingerprints that are associated with the provided
// label set.

View file

@ -211,7 +211,7 @@ var testAppendSampleAsPureSparseAppend = func(t test.Tester) {
t := time.Unix(int64(x), int64(x))
l := model.Metric{model.LabelName(x): model.LabelValue(x)}
sample := &model.Sample{
sample := model.Sample{
Value: v,
Timestamp: t,
Metric: l,
@ -257,7 +257,7 @@ var testAppendSampleAsSparseAppendWithReads func(t test.Tester) = func(t test.Te
t := time.Unix(int64(x), int64(x))
l := model.Metric{model.LabelName(x): model.LabelValue(x)}
sample := &model.Sample{
sample := model.Sample{
Value: v,
Timestamp: t,
Metric: l,
@ -360,7 +360,7 @@ func TestAppendSampleAsPureSingleEntityAppend(t *testing.T) {
}()
appendSample := func(x int) bool {
sample := &model.Sample{
sample := model.Sample{
Value: model.SampleValue(float32(x)),
Timestamp: time.Unix(int64(x), 0),
Metric: model.Metric{"name": "my_metric"},
@ -407,7 +407,7 @@ func TestStochastic(t *testing.T) {
metricNewestSample := make(map[int]int64)
for metricIndex := 0; metricIndex < numberOfMetrics; metricIndex++ {
sample := &model.Sample{
sample := model.Sample{
Metric: model.Metric{},
}
@ -684,7 +684,7 @@ func TestGetFingerprintsForLabelSet(t *testing.T) {
persistence.Close()
}()
appendErr := persistence.AppendSample(&model.Sample{
appendErr := persistence.AppendSample(model.Sample{
Value: model.SampleValue(0),
Timestamp: time.Unix(0, 0),
Metric: model.Metric{
@ -697,7 +697,7 @@ func TestGetFingerprintsForLabelSet(t *testing.T) {
t.Error(appendErr)
}
appendErr = persistence.AppendSample(&model.Sample{
appendErr = persistence.AppendSample(model.Sample{
Value: model.SampleValue(0),
Timestamp: time.Unix(int64(0), 0),
Metric: model.Metric{
@ -762,7 +762,7 @@ func TestGetFingerprintsForLabelName(t *testing.T) {
persistence.Close()
}()
appendErr := persistence.AppendSample(&model.Sample{
appendErr := persistence.AppendSample(model.Sample{
Value: model.SampleValue(0),
Timestamp: time.Unix(0, 0),
Metric: model.Metric{
@ -776,7 +776,7 @@ func TestGetFingerprintsForLabelName(t *testing.T) {
t.Error(appendErr)
}
appendErr = persistence.AppendSample(&model.Sample{
appendErr = persistence.AppendSample(model.Sample{
Value: model.SampleValue(0),
Timestamp: time.Unix(int64(0), 0),
Metric: model.Metric{
@ -850,7 +850,7 @@ func TestGetMetricForFingerprint(t *testing.T) {
persistence.Close()
}()
appendErr := persistence.AppendSample(&model.Sample{
appendErr := persistence.AppendSample(model.Sample{
Value: model.SampleValue(0),
Timestamp: time.Unix(0, 0),
Metric: model.Metric{
@ -862,7 +862,7 @@ func TestGetMetricForFingerprint(t *testing.T) {
t.Error(appendErr)
}
appendErr = persistence.AppendSample(&model.Sample{
appendErr = persistence.AppendSample(model.Sample{
Value: model.SampleValue(0),
Timestamp: time.Unix(int64(0), 0),
Metric: model.Metric{

View file

@ -174,7 +174,7 @@ func (l *LevelDBMetricPersistence) appendFingerprints(sample model.Sample) (err
return
}
func (l *LevelDBMetricPersistence) AppendSample(sample *model.Sample) (err error) {
func (l *LevelDBMetricPersistence) AppendSample(sample model.Sample) (err error) {
begin := time.Now()
defer func() {
duration := time.Now().Sub(begin)
@ -182,7 +182,7 @@ func (l *LevelDBMetricPersistence) AppendSample(sample *model.Sample) (err error
recordOutcome(storageOperations, storageLatency, duration, err, map[string]string{operation: appendSample, result: success}, map[string]string{operation: appendSample, result: failure})
}()
metricDTO := model.SampleToMetricDTO(sample)
metricDTO := model.SampleToMetricDTO(&sample)
indexHas, err := l.hasIndexMetric(metricDTO)
if err != nil {
@ -197,7 +197,7 @@ func (l *LevelDBMetricPersistence) AppendSample(sample *model.Sample) (err error
return
}
err = l.appendFingerprints(*sample)
err = l.appendFingerprints(sample)
if err != nil {
return
}

View file

@ -49,7 +49,7 @@ func TestGetFingerprintsForLabelSetUsesAnd(t *testing.T) {
m[model.LabelName(k)] = model.LabelValue(v)
}
err := persistence.AppendSample(&model.Sample{
err := persistence.AppendSample(model.Sample{
Value: model.SampleValue(0.0),
Timestamp: time.Now(),
Metric: m,

View file

@ -574,7 +574,7 @@ var testGetValueAtTime = func(t test.Tester) {
}
for j, value := range context.values {
err := persistence.AppendSample(&model.Sample{
err := persistence.AppendSample(model.Sample{
Value: model.SampleValue(value.value),
Timestamp: time.Date(value.year, value.month, value.day, value.hour, 0, 0, 0, time.UTC),
Metric: m,
@ -1035,7 +1035,7 @@ var testGetBoundaryValues = func(t test.Tester) {
}
for j, value := range context.values {
err := persistence.AppendSample(&model.Sample{
err := persistence.AppendSample(model.Sample{
Value: model.SampleValue(value.value),
Timestamp: time.Date(value.year, value.month, value.day, value.hour, 0, 0, 0, time.UTC),
Metric: m,
@ -1629,7 +1629,7 @@ var testGetRangeValues = func(t test.Tester) {
}
for j, value := range context.values {
err := persistence.AppendSample(&model.Sample{
err := persistence.AppendSample(model.Sample{
Value: model.SampleValue(value.value),
Timestamp: time.Date(value.year, value.month, value.day, value.hour, 0, 0, 0, time.UTC),
Metric: m,