From 0ff6021d3fcd38395ee6c7f6928720f4aceda7c3 Mon Sep 17 00:00:00 2001 From: jmacd Date: Tue, 23 Jun 2020 00:19:21 -0700 Subject: [PATCH] Rename SynchronizedCopy to SynchronizedMove and update comment --- exporters/metric/stdout/stdout_test.go | 16 ++++++++-------- exporters/metric/test/test.go | 4 ++-- exporters/otlp/internal/transform/metric_test.go | 10 +++++----- exporters/otlp/otlp_metric_test.go | 2 +- sdk/export/metric/metric.go | 11 ++++++----- sdk/metric/aggregator/array/array.go | 8 ++++---- sdk/metric/aggregator/array/array_test.go | 10 +++++----- sdk/metric/aggregator/ddsketch/ddsketch.go | 6 +++--- sdk/metric/aggregator/ddsketch/ddsketch_test.go | 6 +++--- sdk/metric/aggregator/histogram/histogram.go | 4 ++-- .../aggregator/histogram/histogram_test.go | 8 ++++---- sdk/metric/aggregator/lastvalue/lastvalue.go | 4 ++-- .../aggregator/lastvalue/lastvalue_test.go | 8 ++++---- sdk/metric/aggregator/minmaxsumcount/mmsc.go | 6 +++--- .../aggregator/minmaxsumcount/mmsc_test.go | 8 ++++---- sdk/metric/aggregator/sum/sum.go | 4 ++-- sdk/metric/aggregator/sum/sum_test.go | 8 ++++---- sdk/metric/histogram_stress_test.go | 2 +- sdk/metric/integrator/simple/simple.go | 4 ++-- sdk/metric/minmaxsumcount_stress_test.go | 2 +- sdk/metric/sdk.go | 2 +- 21 files changed, 67 insertions(+), 66 deletions(-) diff --git a/exporters/metric/stdout/stdout_test.go b/exporters/metric/stdout/stdout_test.go index 2208bee02b7..582b7dab0ba 100644 --- a/exporters/metric/stdout/stdout_test.go +++ b/exporters/metric/stdout/stdout_test.go @@ -104,7 +104,7 @@ func TestStdoutTimestamp(t *testing.T) { lvagg, ckpt := test.Unslice2(lastvalue.New(2)) aggtest.CheckedUpdate(t, lvagg, metric.NewInt64Number(321), &desc) - require.NoError(t, lvagg.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, lvagg.SynchronizedMove(ckpt, &desc)) checkpointSet.Add(&desc, ckpt) @@ -151,7 +151,7 @@ func TestStdoutCounterFormat(t *testing.T) { cagg, ckpt := test.Unslice2(sum.New(2)) aggtest.CheckedUpdate(fix.t, cagg, metric.NewInt64Number(123), &desc) - require.NoError(t, cagg.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, cagg.SynchronizedMove(ckpt, &desc)) checkpointSet.Add(&desc, ckpt, kv.String("A", "B"), kv.String("C", "D")) @@ -169,7 +169,7 @@ func TestStdoutLastValueFormat(t *testing.T) { lvagg, ckpt := test.Unslice2(lastvalue.New(2)) aggtest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc) - require.NoError(t, lvagg.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, lvagg.SynchronizedMove(ckpt, &desc)) checkpointSet.Add(&desc, ckpt, kv.String("A", "B"), kv.String("C", "D")) @@ -189,7 +189,7 @@ func TestStdoutMinMaxSumCount(t *testing.T) { aggtest.CheckedUpdate(fix.t, magg, metric.NewFloat64Number(123.456), &desc) aggtest.CheckedUpdate(fix.t, magg, metric.NewFloat64Number(876.543), &desc) - require.NoError(t, magg.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, magg.SynchronizedMove(ckpt, &desc)) checkpointSet.Add(&desc, ckpt, kv.String("A", "B"), kv.String("C", "D")) @@ -212,7 +212,7 @@ func TestStdoutValueRecorderFormat(t *testing.T) { aggtest.CheckedUpdate(fix.t, aagg, metric.NewFloat64Number(float64(i)+0.5), &desc) } - require.NoError(t, aagg.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, aagg.SynchronizedMove(ckpt, &desc)) checkpointSet.Add(&desc, ckpt, kv.String("A", "B"), kv.String("C", "D")) @@ -256,7 +256,7 @@ func TestStdoutNoData(t *testing.T) { checkpointSet := test.NewCheckpointSet(testResource) - require.NoError(t, agg.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, agg.SynchronizedMove(ckpt, &desc)) checkpointSet.Add(&desc, ckpt) @@ -278,7 +278,7 @@ func TestStdoutLastValueNotSet(t *testing.T) { desc := metric.NewDescriptor("test.name", metric.ValueObserverKind, metric.Float64NumberKind) lvagg, ckpt := test.Unslice2(lastvalue.New(2)) - require.NoError(t, lvagg.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, lvagg.SynchronizedMove(ckpt, &desc)) checkpointSet.Add(&desc, lvagg, kv.String("A", "B"), kv.String("C", "D")) @@ -330,7 +330,7 @@ func TestStdoutResource(t *testing.T) { lvagg, ckpt := test.Unslice2(lastvalue.New(2)) aggtest.CheckedUpdate(fix.t, lvagg, metric.NewFloat64Number(123.456), &desc) - require.NoError(t, lvagg.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, lvagg.SynchronizedMove(ckpt, &desc)) checkpointSet.Add(&desc, ckpt, tc.attrs...) diff --git a/exporters/metric/test/test.go b/exporters/metric/test/test.go index 2a4ea885569..c2a7f47c86d 100644 --- a/exporters/metric/test/test.go +++ b/exporters/metric/test/test.go @@ -52,8 +52,8 @@ func (NoopAggregator) Update(context.Context, metric.Number, *metric.Descriptor) return nil } -// SynchronizedCopy implements export.Aggregator. -func (NoopAggregator) SynchronizedCopy(export.Aggregator, *metric.Descriptor) error { +// SynchronizedMove implements export.Aggregator. +func (NoopAggregator) SynchronizedMove(export.Aggregator, *metric.Descriptor) error { return nil } diff --git a/exporters/otlp/internal/transform/metric_test.go b/exporters/otlp/internal/transform/metric_test.go index 06190e1624d..53912690c68 100644 --- a/exporters/otlp/internal/transform/metric_test.go +++ b/exporters/otlp/internal/transform/metric_test.go @@ -101,7 +101,7 @@ func TestMinMaxSumCountValue(t *testing.T) { assert.EqualError(t, err, aggregation.ErrNoData.Error()) // Checkpoint to set non-zero values - require.NoError(t, mmsc.SynchronizedCopy(ckpt, &metric.Descriptor{})) + require.NoError(t, mmsc.SynchronizedMove(ckpt, &metric.Descriptor{})) min, max, sum, count, err := minMaxSumCountValues(ckpt.(aggregation.MinMaxSumCount)) if assert.NoError(t, err) { assert.Equal(t, min, metric.NewInt64Number(1)) @@ -158,7 +158,7 @@ func TestMinMaxSumCountMetricDescriptor(t *testing.T) { if !assert.NoError(t, mmsc.Update(ctx, 1, &metric.Descriptor{})) { return } - require.NoError(t, mmsc.SynchronizedCopy(ckpt, &metric.Descriptor{})) + require.NoError(t, mmsc.SynchronizedMove(ckpt, &metric.Descriptor{})) for _, test := range tests { desc := metric.NewDescriptor(test.name, test.metricKind, test.numberKind, metric.WithDescription(test.description), @@ -179,7 +179,7 @@ func TestMinMaxSumCountDatapoints(t *testing.T) { assert.NoError(t, mmsc.Update(context.Background(), 1, &desc)) assert.NoError(t, mmsc.Update(context.Background(), 10, &desc)) - require.NoError(t, mmsc.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, mmsc.SynchronizedMove(ckpt, &desc)) expected := []*metricpb.SummaryDataPoint{ { Count: 2, @@ -280,7 +280,7 @@ func TestSumInt64DataPoints(t *testing.T) { labels := label.NewSet() s, ckpt := test.Unslice2(sumAgg.New(2)) assert.NoError(t, s.Update(context.Background(), metric.Number(1), &desc)) - require.NoError(t, s.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, s.SynchronizedMove(ckpt, &desc)) record := export.NewRecord(&desc, &labels, nil, ckpt.Aggregation(), intervalStart, intervalEnd) if m, err := sum(record, ckpt.(aggregation.Sum)); assert.NoError(t, err) { assert.Equal(t, []*metricpb.Int64DataPoint{{ @@ -299,7 +299,7 @@ func TestSumFloat64DataPoints(t *testing.T) { labels := label.NewSet() s, ckpt := test.Unslice2(sumAgg.New(2)) assert.NoError(t, s.Update(context.Background(), metric.NewFloat64Number(1), &desc)) - require.NoError(t, s.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, s.SynchronizedMove(ckpt, &desc)) record := export.NewRecord(&desc, &labels, nil, ckpt.Aggregation(), intervalStart, intervalEnd) if m, err := sum(record, ckpt.(aggregation.Sum)); assert.NoError(t, err) { assert.Equal(t, []*metricpb.Int64DataPoint(nil), m.Int64DataPoints) diff --git a/exporters/otlp/otlp_metric_test.go b/exporters/otlp/otlp_metric_test.go index f1d8d56c0d7..99d24a10baa 100644 --- a/exporters/otlp/otlp_metric_test.go +++ b/exporters/otlp/otlp_metric_test.go @@ -741,7 +741,7 @@ func runMetricExportTest(t *testing.T, exp *Exporter, rs []record, expected []me default: t.Fatalf("invalid number kind: %v", r.nKind) } - require.NoError(t, agg.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, agg.SynchronizedMove(ckpt, &desc)) equiv := r.resource.Equivalent() resources[equiv] = r.resource diff --git a/sdk/export/metric/metric.go b/sdk/export/metric/metric.go index 11b2b404115..408cb8a2ba3 100644 --- a/sdk/export/metric/metric.go +++ b/sdk/export/metric/metric.go @@ -127,11 +127,12 @@ type Aggregator interface { // inspected for a `correlation.Map` or `trace.SpanContext`. Update(context.Context, metric.Number, *metric.Descriptor) error - // SynchronizedCopy is called during collection to finish one + // SynchronizedMove is called during collection to finish one // period of aggregation by atomically saving the - // currently-updating state into the argument Aggregator. + // currently-updating state into the argument Aggregator AND + // resetting the current value to the zero state. // - // SynchronizedCopy() is called concurrently with Update(). These + // SynchronizedMove() is called concurrently with Update(). These // two methods must be synchronized with respect to each // other, for correctness. // @@ -145,11 +146,11 @@ type Aggregator interface { // // This call has no Context argument because it is expected to // perform only computation. - SynchronizedCopy(destination Aggregator, descriptor *metric.Descriptor) error + SynchronizedMove(destination Aggregator, descriptor *metric.Descriptor) error // Merge combines the checkpointed state from the argument // Aggregator into this Aggregator. Merge is not synchronized - // with respect to Update or SynchronizedCopy. + // with respect to Update or SynchronizedMove. // // The owner of an Aggregator being merged is responsible for // synchronization of both Aggregator states. diff --git a/sdk/metric/aggregator/array/array.go b/sdk/metric/aggregator/array/array.go index ab7cdeb0212..31451b81bbd 100644 --- a/sdk/metric/aggregator/array/array.go +++ b/sdk/metric/aggregator/array/array.go @@ -46,7 +46,7 @@ var _ aggregation.Points = &Aggregator{} // New returns a new array aggregator, which aggregates recorded // measurements by storing them in an array. This type uses a mutex -// for Update() and SynchronizedCopy() concurrency. +// for Update() and SynchronizedMove() concurrency. func New(cnt int) []Aggregator { return make([]Aggregator, cnt) } @@ -92,9 +92,9 @@ func (c *Aggregator) Points() ([]metric.Number, error) { return c.points, nil } -// SynchronizedCopy saves the current state to oa and resets the current state to +// SynchronizedMove saves the current state to oa and resets the current state to // the empty set, taking a lock to prevent concurrent Update() calls. -func (c *Aggregator) SynchronizedCopy(oa export.Aggregator, desc *metric.Descriptor) error { +func (c *Aggregator) SynchronizedMove(oa export.Aggregator, desc *metric.Descriptor) error { o, _ := oa.(*Aggregator) if o == nil { return aggregator.NewInconsistentAggregatorError(c, oa) @@ -114,7 +114,7 @@ func (c *Aggregator) SynchronizedCopy(oa export.Aggregator, desc *metric.Descrip } // Update adds the recorded measurement to the current data set. -// Update takes a lock to prevent concurrent Update() and SynchronizedCopy() +// Update takes a lock to prevent concurrent Update() and SynchronizedMove() // calls. func (c *Aggregator) Update(_ context.Context, number metric.Number, desc *metric.Descriptor) error { c.lock.Lock() diff --git a/sdk/metric/aggregator/array/array_test.go b/sdk/metric/aggregator/array/array_test.go index 234ea24f0e5..9f5eb81da1e 100644 --- a/sdk/metric/aggregator/array/array_test.go +++ b/sdk/metric/aggregator/array/array_test.go @@ -77,7 +77,7 @@ func (ut *updateTest) run(t *testing.T, profile test.Profile) { test.CheckedUpdate(t, agg, y, descriptor) } - err := agg.SynchronizedCopy(ckpt, descriptor) + err := agg.SynchronizedMove(ckpt, descriptor) require.NoError(t, err) checkZero(t, agg, descriptor) @@ -154,8 +154,8 @@ func (mt *mergeTest) run(t *testing.T, profile test.Profile) { } } - require.NoError(t, agg1.SynchronizedCopy(ckpt1, descriptor)) - require.NoError(t, agg2.SynchronizedCopy(ckpt2, descriptor)) + require.NoError(t, agg1.SynchronizedMove(ckpt1, descriptor)) + require.NoError(t, agg2.SynchronizedMove(ckpt2, descriptor)) checkZero(t, agg1, descriptor) checkZero(t, agg2, descriptor) @@ -232,7 +232,7 @@ func TestArrayErrors(t *testing.T) { if profile.NumberKind == metric.Float64NumberKind { test.CheckedUpdate(t, agg, metric.NewFloat64Number(math.NaN()), descriptor) } - require.NoError(t, agg.SynchronizedCopy(ckpt, descriptor)) + require.NoError(t, agg.SynchronizedMove(ckpt, descriptor)) count, err := ckpt.Count() require.Equal(t, int64(1), count, "NaN value was not counted") @@ -297,7 +297,7 @@ func TestArrayFloat64(t *testing.T) { test.CheckedUpdate(t, agg, metric.NewFloat64Number(f), descriptor) } - require.NoError(t, agg.SynchronizedCopy(ckpt, descriptor)) + require.NoError(t, agg.SynchronizedMove(ckpt, descriptor)) all.Sort() diff --git a/sdk/metric/aggregator/ddsketch/ddsketch.go b/sdk/metric/aggregator/ddsketch/ddsketch.go index c6d76e10f59..ae2ed4da724 100644 --- a/sdk/metric/aggregator/ddsketch/ddsketch.go +++ b/sdk/metric/aggregator/ddsketch/ddsketch.go @@ -112,9 +112,9 @@ func (c *Aggregator) toNumber(f float64) metric.Number { return metric.NewInt64Number(int64(f)) } -// SynchronizedCopy saves the current state into oa and resets the current state to +// SynchronizedMove saves the current state into oa and resets the current state to // a new sketch, taking a lock to prevent concurrent Update() calls. -func (c *Aggregator) SynchronizedCopy(oa export.Aggregator, _ *metric.Descriptor) error { +func (c *Aggregator) SynchronizedMove(oa export.Aggregator, _ *metric.Descriptor) error { o, _ := oa.(*Aggregator) if o == nil { return aggregator.NewInconsistentAggregatorError(c, oa) @@ -129,7 +129,7 @@ func (c *Aggregator) SynchronizedCopy(oa export.Aggregator, _ *metric.Descriptor } // Update adds the recorded measurement to the current data set. -// Update takes a lock to prevent concurrent Update() and SynchronizedCopy() +// Update takes a lock to prevent concurrent Update() and SynchronizedMove() // calls. func (c *Aggregator) Update(_ context.Context, number metric.Number, desc *metric.Descriptor) error { c.lock.Lock() diff --git a/sdk/metric/aggregator/ddsketch/ddsketch_test.go b/sdk/metric/aggregator/ddsketch/ddsketch_test.go index 1fdbde3679b..f5a09dc2d00 100644 --- a/sdk/metric/aggregator/ddsketch/ddsketch_test.go +++ b/sdk/metric/aggregator/ddsketch/ddsketch_test.go @@ -80,7 +80,7 @@ func (ut *updateTest) run(t *testing.T, profile test.Profile) { test.CheckedUpdate(t, agg, y, descriptor) } - err := agg.SynchronizedCopy(ckpt, descriptor) + err := agg.SynchronizedMove(ckpt, descriptor) require.NoError(t, err) checkZero(t, agg, descriptor) @@ -156,8 +156,8 @@ func (mt *mergeTest) run(t *testing.T, profile test.Profile) { } } - require.NoError(t, agg1.SynchronizedCopy(ckpt1, descriptor)) - require.NoError(t, agg2.SynchronizedCopy(ckpt2, descriptor)) + require.NoError(t, agg1.SynchronizedMove(ckpt1, descriptor)) + require.NoError(t, agg2.SynchronizedMove(ckpt2, descriptor)) checkZero(t, agg1, descriptor) checkZero(t, agg1, descriptor) diff --git a/sdk/metric/aggregator/histogram/histogram.go b/sdk/metric/aggregator/histogram/histogram.go index 6cace5f37e8..abad71aa1c1 100644 --- a/sdk/metric/aggregator/histogram/histogram.go +++ b/sdk/metric/aggregator/histogram/histogram.go @@ -111,11 +111,11 @@ func (c *Aggregator) Histogram() (aggregation.Buckets, error) { }, nil } -// SynchronizedCopy saves the current state into oa and resets the current state to +// SynchronizedMove saves the current state into oa and resets the current state to // the empty set. Since no locks are taken, there is a chance that // the independent Sum, Count and Bucket Count are not consistent with each // other. -func (c *Aggregator) SynchronizedCopy(oa export.Aggregator, desc *metric.Descriptor) error { +func (c *Aggregator) SynchronizedMove(oa export.Aggregator, desc *metric.Descriptor) error { o, _ := oa.(*Aggregator) if o == nil { return aggregator.NewInconsistentAggregatorError(c, oa) diff --git a/sdk/metric/aggregator/histogram/histogram_test.go b/sdk/metric/aggregator/histogram/histogram_test.go index b25c6421397..66e9c61fd67 100644 --- a/sdk/metric/aggregator/histogram/histogram_test.go +++ b/sdk/metric/aggregator/histogram/histogram_test.go @@ -121,7 +121,7 @@ func testHistogram(t *testing.T, profile test.Profile, policy policy) { test.CheckedUpdate(t, agg, x, descriptor) } - require.NoError(t, agg.SynchronizedCopy(ckpt, descriptor)) + require.NoError(t, agg.SynchronizedMove(ckpt, descriptor)) checkZero(t, agg, descriptor) @@ -184,8 +184,8 @@ func TestHistogramMerge(t *testing.T) { test.CheckedUpdate(t, agg2, x, descriptor) } - require.NoError(t, agg1.SynchronizedCopy(ckpt1, descriptor)) - require.NoError(t, agg2.SynchronizedCopy(ckpt2, descriptor)) + require.NoError(t, agg1.SynchronizedMove(ckpt1, descriptor)) + require.NoError(t, agg2.SynchronizedMove(ckpt2, descriptor)) test.CheckedMerge(t, ckpt1, ckpt2, descriptor) @@ -223,7 +223,7 @@ func TestHistogramNotSet(t *testing.T) { agg, ckpt := new2(descriptor) - err := agg.SynchronizedCopy(ckpt, descriptor) + err := agg.SynchronizedMove(ckpt, descriptor) require.NoError(t, err) checkZero(t, agg, descriptor) diff --git a/sdk/metric/aggregator/lastvalue/lastvalue.go b/sdk/metric/aggregator/lastvalue/lastvalue.go index 3ab03e19953..4aff9a64fd8 100644 --- a/sdk/metric/aggregator/lastvalue/lastvalue.go +++ b/sdk/metric/aggregator/lastvalue/lastvalue.go @@ -90,8 +90,8 @@ func (g *Aggregator) LastValue() (metric.Number, time.Time, error) { return gd.value.AsNumber(), gd.timestamp, nil } -// SynchronizedCopy atomically saves the current value. -func (g *Aggregator) SynchronizedCopy(oa export.Aggregator, _ *metric.Descriptor) error { +// SynchronizedMove atomically saves the current value. +func (g *Aggregator) SynchronizedMove(oa export.Aggregator, _ *metric.Descriptor) error { o, _ := oa.(*Aggregator) if o == nil { return aggregator.NewInconsistentAggregatorError(g, oa) diff --git a/sdk/metric/aggregator/lastvalue/lastvalue_test.go b/sdk/metric/aggregator/lastvalue/lastvalue_test.go index c9c12cf4f20..0c842ea9675 100644 --- a/sdk/metric/aggregator/lastvalue/lastvalue_test.go +++ b/sdk/metric/aggregator/lastvalue/lastvalue_test.go @@ -80,7 +80,7 @@ func TestLastValueUpdate(t *testing.T) { test.CheckedUpdate(t, agg, x, record) } - err := agg.SynchronizedCopy(ckpt, record) + err := agg.SynchronizedMove(ckpt, record) require.NoError(t, err) lv, _, err := ckpt.LastValue() @@ -102,8 +102,8 @@ func TestLastValueMerge(t *testing.T) { test.CheckedUpdate(t, agg1, first1, descriptor) test.CheckedUpdate(t, agg2, first2, descriptor) - require.NoError(t, agg1.SynchronizedCopy(ckpt1, descriptor)) - require.NoError(t, agg2.SynchronizedCopy(ckpt2, descriptor)) + require.NoError(t, agg1.SynchronizedMove(ckpt1, descriptor)) + require.NoError(t, agg2.SynchronizedMove(ckpt2, descriptor)) checkZero(t, agg1) checkZero(t, agg2) @@ -127,7 +127,7 @@ func TestLastValueNotSet(t *testing.T) { descriptor := test.NewAggregatorTest(metric.ValueObserverKind, metric.Int64NumberKind) g, ckpt := new2() - require.NoError(t, g.SynchronizedCopy(ckpt, descriptor)) + require.NoError(t, g.SynchronizedMove(ckpt, descriptor)) checkZero(t, g) } diff --git a/sdk/metric/aggregator/minmaxsumcount/mmsc.go b/sdk/metric/aggregator/minmaxsumcount/mmsc.go index 2ffac5a8958..a966d2a896a 100644 --- a/sdk/metric/aggregator/minmaxsumcount/mmsc.go +++ b/sdk/metric/aggregator/minmaxsumcount/mmsc.go @@ -48,7 +48,7 @@ var _ aggregation.MinMaxSumCount = &Aggregator{} // count. It does not compute quantile information other than Min and // Max. // -// This type uses a mutex for Update() and SynchronizedCopy() concurrency. +// This type uses a mutex for Update() and SynchronizedMove() concurrency. func New(cnt int, desc *metric.Descriptor) []Aggregator { kind := desc.NumberKind() aggs := make([]Aggregator, cnt) @@ -101,9 +101,9 @@ func (c *Aggregator) Max() (metric.Number, error) { return c.max, nil } -// SynchronizedCopy saves the current state into oa and resets the current state to +// SynchronizedMove saves the current state into oa and resets the current state to // the empty set. -func (c *Aggregator) SynchronizedCopy(oa export.Aggregator, desc *metric.Descriptor) error { +func (c *Aggregator) SynchronizedMove(oa export.Aggregator, desc *metric.Descriptor) error { o, _ := oa.(*Aggregator) if o == nil { return aggregator.NewInconsistentAggregatorError(c, oa) diff --git a/sdk/metric/aggregator/minmaxsumcount/mmsc_test.go b/sdk/metric/aggregator/minmaxsumcount/mmsc_test.go index 9e193ce43d9..915fabd5ad7 100644 --- a/sdk/metric/aggregator/minmaxsumcount/mmsc_test.go +++ b/sdk/metric/aggregator/minmaxsumcount/mmsc_test.go @@ -120,7 +120,7 @@ func minMaxSumCount(t *testing.T, profile test.Profile, policy policy) { test.CheckedUpdate(t, agg, x, descriptor) } - require.NoError(t, agg.SynchronizedCopy(ckpt, descriptor)) + require.NoError(t, agg.SynchronizedMove(ckpt, descriptor)) checkZero(t, agg, descriptor) @@ -173,8 +173,8 @@ func TestMinMaxSumCountMerge(t *testing.T) { test.CheckedUpdate(t, agg2, x, descriptor) } - require.NoError(t, agg1.SynchronizedCopy(ckpt1, descriptor)) - require.NoError(t, agg2.SynchronizedCopy(ckpt2, descriptor)) + require.NoError(t, agg1.SynchronizedMove(ckpt1, descriptor)) + require.NoError(t, agg2.SynchronizedMove(ckpt2, descriptor)) checkZero(t, agg1, descriptor) checkZero(t, agg2, descriptor) @@ -219,7 +219,7 @@ func TestMaxSumCountNotSet(t *testing.T) { alloc := New(2, descriptor) agg, ckpt := &alloc[0], &alloc[1] - require.NoError(t, agg.SynchronizedCopy(ckpt, descriptor)) + require.NoError(t, agg.SynchronizedMove(ckpt, descriptor)) asum, err := ckpt.Sum() require.Equal(t, metric.Number(0), asum, "Empty checkpoint sum = 0") diff --git a/sdk/metric/aggregator/sum/sum.go b/sdk/metric/aggregator/sum/sum.go index d61a0da9ae8..0b2b3f35864 100644 --- a/sdk/metric/aggregator/sum/sum.go +++ b/sdk/metric/aggregator/sum/sum.go @@ -57,9 +57,9 @@ func (c *Aggregator) Sum() (metric.Number, error) { return c.value, nil } -// SynchronizedCopy atomically saves the current value into oa and resets the +// SynchronizedMove atomically saves the current value into oa and resets the // current sum to zero. -func (c *Aggregator) SynchronizedCopy(oa export.Aggregator, _ *metric.Descriptor) error { +func (c *Aggregator) SynchronizedMove(oa export.Aggregator, _ *metric.Descriptor) error { o, _ := oa.(*Aggregator) if o == nil { return aggregator.NewInconsistentAggregatorError(c, oa) diff --git a/sdk/metric/aggregator/sum/sum_test.go b/sdk/metric/aggregator/sum/sum_test.go index eeb6755c20d..7372ea5655c 100644 --- a/sdk/metric/aggregator/sum/sum_test.go +++ b/sdk/metric/aggregator/sum/sum_test.go @@ -74,7 +74,7 @@ func TestCounterSum(t *testing.T) { test.CheckedUpdate(t, agg, x, descriptor) } - err := agg.SynchronizedCopy(ckpt, descriptor) + err := agg.SynchronizedMove(ckpt, descriptor) require.NoError(t, err) checkZero(t, agg, descriptor) @@ -102,7 +102,7 @@ func TestValueRecorderSum(t *testing.T) { sum.AddNumber(profile.NumberKind, r2) } - require.NoError(t, agg.SynchronizedCopy(ckpt, descriptor)) + require.NoError(t, agg.SynchronizedMove(ckpt, descriptor)) checkZero(t, agg, descriptor) asum, err := ckpt.Sum() @@ -125,8 +125,8 @@ func TestCounterMerge(t *testing.T) { test.CheckedUpdate(t, agg2, x, descriptor) } - require.NoError(t, agg1.SynchronizedCopy(ckpt1, descriptor)) - require.NoError(t, agg2.SynchronizedCopy(ckpt2, descriptor)) + require.NoError(t, agg1.SynchronizedMove(ckpt1, descriptor)) + require.NoError(t, agg2.SynchronizedMove(ckpt2, descriptor)) checkZero(t, agg1, descriptor) checkZero(t, agg2, descriptor) diff --git a/sdk/metric/histogram_stress_test.go b/sdk/metric/histogram_stress_test.go index 4f0bced3345..1356e37a34a 100644 --- a/sdk/metric/histogram_stress_test.go +++ b/sdk/metric/histogram_stress_test.go @@ -48,7 +48,7 @@ func TestStressInt64Histogram(t *testing.T) { startTime := time.Now() for time.Since(startTime) < time.Second { - require.NoError(t, h.SynchronizedCopy(ckpt, &desc)) + require.NoError(t, h.SynchronizedMove(ckpt, &desc)) b, _ := ckpt.Histogram() c, _ := ckpt.Count() diff --git a/sdk/metric/integrator/simple/simple.go b/sdk/metric/integrator/simple/simple.go index 52beff54db5..59393f15a12 100644 --- a/sdk/metric/integrator/simple/simple.go +++ b/sdk/metric/integrator/simple/simple.go @@ -220,7 +220,7 @@ func (b *Integrator) Process(accum export.Accumulation) error { // Accumulator's Aggregator into `value.delta` and sets // `value.current` appropriately to avoid this branch if // a third Accumulator is used. - err := value.current.SynchronizedCopy(value.delta, desc) + err := value.current.SynchronizedMove(value.delta, desc) if err != nil { return err } @@ -278,7 +278,7 @@ func (b *Integrator) FinishCollection() error { err = subt.Subtract(value.cumulative, value.delta, key.descriptor) if err == nil { - err = value.current.SynchronizedCopy(value.cumulative, key.descriptor) + err = value.current.SynchronizedMove(value.cumulative, key.descriptor) } } else { err = aggregation.ErrNoSubtraction diff --git a/sdk/metric/minmaxsumcount_stress_test.go b/sdk/metric/minmaxsumcount_stress_test.go index 50d8305059c..ee8bf614008 100644 --- a/sdk/metric/minmaxsumcount_stress_test.go +++ b/sdk/metric/minmaxsumcount_stress_test.go @@ -47,7 +47,7 @@ func TestStressInt64MinMaxSumCount(t *testing.T) { startTime := time.Now() for time.Since(startTime) < time.Second { - _ = mmsc.SynchronizedCopy(ckpt, &desc) + _ = mmsc.SynchronizedMove(ckpt, &desc) s, _ := ckpt.Sum() c, _ := ckpt.Count() diff --git a/sdk/metric/sdk.go b/sdk/metric/sdk.go index 0fde5099824..36c9758420c 100644 --- a/sdk/metric/sdk.go +++ b/sdk/metric/sdk.go @@ -438,7 +438,7 @@ func (m *Accumulator) checkpointRecord(r *record) int { if r.current == nil { return 0 } - err := r.current.SynchronizedCopy(r.checkpoint, &r.inst.descriptor) + err := r.current.SynchronizedMove(r.checkpoint, &r.inst.descriptor) if err != nil { global.Handle(err) return 0