Skip to content

Commit

Permalink
Change exemplars to slice of values instead of ptrs (open-telemetry#2402
Browse files Browse the repository at this point in the history
)

Benchmarks before:
```
goos: darwin
goarch: amd64
pkg: go.opentelemetry.io/collector/consumer/pdata
BenchmarkMetricsFromOtlp
BenchmarkMetricsFromOtlp-16    	     322	   3809358 ns/op	 2271080 B/op	   51507 allocs/op
PASS
```

Benchmarks after
```
goos: darwin
goarch: amd64
pkg: go.opentelemetry.io/collector/consumer/pdata
BenchmarkMetricsFromOtlp
BenchmarkMetricsFromOtlp-16    	     331	   3594315 ns/op	 3212271 B/op	   34700 allocs/op
PASS
```

Significant improvement in the number of allocations. Increase in the number of total bytes allocated.

Signed-off-by: Bogdan Drutu <[email protected]>
  • Loading branch information
bogdandrutu authored Feb 3, 2021
1 parent b44b92d commit 52decc7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func generateOtlpDoubleHistogramMetric() *otlpmetrics.Metric {
Sum: 15,
BucketCounts: []uint64{0, 1},
ExplicitBounds: []float64{1},
Exemplars: []*otlpmetrics.DoubleExemplar{
Exemplars: []otlpmetrics.DoubleExemplar{
{
FilteredLabels: generateOtlpMetricAttachment(),
TimeUnixNano: uint64(TestMetricExemplarTimestamp),
Expand Down Expand Up @@ -500,7 +500,7 @@ func generateOtlpIntHistogramMetric() *otlpmetrics.Metric {
Sum: 15,
BucketCounts: []uint64{0, 1},
ExplicitBounds: []float64{1},
Exemplars: []*otlpmetrics.IntExemplar{
Exemplars: []otlpmetrics.IntExemplar{
{
FilteredLabels: generateOtlpMetricAttachment(),
TimeUnixNano: uint64(TestMetricExemplarTimestamp),
Expand Down

0 comments on commit 52decc7

Please sign in to comment.