Skip to content

Commit

Permalink
[chore] [translator/prometheusremotewrite] Optimize FromMetrics. (#29686
Browse files Browse the repository at this point in the history
)

**Description:** <Describe what has changed.>
Optimize `prometheusremotewrite.FromMetrics` by defining metric name per
metric, instead of per sample (the name doesn't change per sample). Also
optimize by preallocating some slices.

**Link to tracking Issue:**

**Testing:** <Describe what testing was performed and which tests were
added.>
I've run `make test`. The Grafana Mimir team is also testing these
changes in a development deployment, and have found performance
improvements through benchmarking.

`BenchmarkFromMetrics` statistics:

<details>

```console
goos: darwin
goarch: arm64
pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheusremotewrite
                                                                                                                                           │   main.txt   │              opt.txt               │
                                                                                                                                           │    sec/op    │   sec/op     vs base               │
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12         1.857m ±  0%   1.858m ± 0%        ~ (p=1.000 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12         3.566m ±  1%   3.230m ± 3%   -9.43% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12        4.765m ±  1%   4.268m ± 5%  -10.42% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12        11.35m ±  0%   11.10m ± 0%   -2.19% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12        13.02m ±  0%   12.51m ± 1%   -3.86% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12       14.24m ±  1%   13.49m ± 2%   -5.26% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12         5.712m ±  1%   5.651m ± 1%        ~ (p=0.132 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12         8.817m ±  1%   8.349m ± 2%   -5.31% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12        10.90m ±  0%   10.28m ± 2%   -5.67% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12        18.81m ±  1%   18.39m ± 1%   -2.28% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12        22.17m ±  1%   21.28m ± 1%   -4.00% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12       24.51m ±  8%   23.62m ± 1%   -3.62% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12      7.008m ±  2%   6.993m ± 2%        ~ (p=0.699 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12      11.51m ±  1%   10.74m ± 2%   -6.69% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12     14.59m ±  1%   13.62m ± 3%   -6.69% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12     29.35m ±  1%   29.01m ± 2%        ~ (p=0.093 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12     34.39m ±  1%   33.35m ± 1%   -3.01% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12    37.90m ±  1%   36.66m ± 0%   -3.26% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12            1.190µ ±  3%   1.165µ ± 0%   -2.06% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12            1.188µ ±  1%   1.165µ ± 0%   -1.89% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12           1.189µ ±  1%   1.164µ ± 1%   -2.10% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12           1.183µ ±  1%   1.163µ ± 1%   -1.73% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12           1.182µ ±  0%   1.177µ ± 1%        ~ (p=0.097 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12          1.182µ ±  0%   1.173µ ± 0%   -0.76% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12         1.899m ±  0%   1.870m ± 1%   -1.49% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12         3.604m ±  0%   3.217m ± 1%  -10.75% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12        4.784m ±  1%   4.329m ± 4%   -9.52% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12        11.37m ±  1%   11.34m ± 0%        ~ (p=0.485 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12        13.01m ±  1%   12.78m ± 1%   -1.71% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12       14.14m ±  0%   13.95m ± 1%   -1.32% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12         5.688m ±  1%   5.683m ± 4%        ~ (p=1.000 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12         8.804m ±  1%   8.299m ± 3%   -5.74% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12        10.89m ±  1%   10.11m ± 1%   -7.10% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12        18.77m ±  1%   18.92m ± 2%        ~ (p=0.065 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12        22.37m ±  1%   21.95m ± 1%   -1.87% (p=0.009 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12       24.68m ±  0%   24.26m ± 3%        ~ (p=0.065 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12      7.099m ±  1%   7.169m ± 1%        ~ (p=0.240 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12      11.57m ±  0%   11.08m ± 2%   -4.21% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12     14.82m ±  0%   13.92m ± 3%   -6.08% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12     29.28m ±  0%   29.51m ± 3%   +0.80% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12     34.16m ±  1%   34.03m ± 3%        ~ (p=0.699 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12    37.67m ±  1%   37.45m ± 2%        ~ (p=1.000 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12           13.01µ ±  0%   13.10µ ± 1%        ~ (p=0.093 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12           13.18µ ±  1%   13.06µ ± 2%        ~ (p=0.310 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12          13.20µ ±  1%   13.08µ ± 1%   -0.91% (p=0.026 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12          13.15µ ±  0%   13.00µ ± 0%   -1.10% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12          13.15µ ±  1%   13.03µ ± 1%        ~ (p=0.065 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12         13.13µ ±  1%   12.99µ ± 0%   -1.06% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12        2.027m ±  0%   2.002m ± 1%   -1.23% (p=0.015 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12        3.682m ±  2%   3.427m ± 4%   -6.92% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12       4.906m ±  2%   4.481m ± 3%   -8.67% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12       11.45m ±  0%   11.51m ± 1%   +0.53% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12       13.09m ±  1%   13.11m ± 2%        ~ (p=1.000 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12      14.25m ±  0%   14.22m ± 2%        ~ (p=0.093 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12        5.774m ±  1%   5.853m ± 2%   +1.37% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12        8.789m ±  1%   8.596m ± 1%   -2.20% (p=0.004 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12       10.85m ±  1%   10.49m ± 1%   -3.25% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12       18.77m ±  1%   18.80m ± 1%        ~ (p=0.589 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12       22.08m ±  5%   21.78m ± 2%   -1.35% (p=0.026 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12      24.65m ±  1%   24.24m ± 1%   -1.66% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12     7.234m ± 11%   7.312m ± 0%        ~ (p=0.394 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12     11.77m ±  3%   11.13m ± 2%   -5.44% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12    15.15m ±  1%   14.03m ± 2%   -7.38% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12    29.58m ±  1%   29.57m ± 1%        ~ (p=0.699 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12    34.62m ±  3%   33.82m ± 1%   -2.33% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12   38.47m ±  1%   37.18m ± 1%   -3.36% (p=0.002 n=6)
geomean                                                                                                                                      2.748m         2.673m        -2.75%

                                                                                                                                           │   main.txt    │                opt.txt                │
                                                                                                                                           │     B/op      │     B/op      vs base                 │
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12          1.578Mi ± 0%   1.578Mi ± 0%        ~ (p=0.310 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12          4.363Mi ± 0%   3.690Mi ± 0%  -15.41% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12         7.213Mi ± 0%   5.807Mi ± 0%  -19.49% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12         10.14Mi ± 0%   10.14Mi ± 0%   -0.01% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12         12.95Mi ± 0%   12.28Mi ± 0%   -5.20% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12        15.83Mi ± 0%   14.41Mi ± 0%   -8.92% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12          6.560Mi ± 0%   6.583Mi ± 0%   +0.34% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12         10.041Mi ± 0%   9.369Mi ± 0%   -6.69% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12         13.63Mi ± 0%   12.22Mi ± 0%  -10.32% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12         23.96Mi ± 0%   23.98Mi ± 0%   +0.09% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12         27.46Mi ± 0%   26.79Mi ± 0%   -2.46% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12        31.07Mi ± 0%   29.66Mi ± 0%   -4.53% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12       7.923Mi ± 0%   7.946Mi ± 0%   +0.29% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12       14.21Mi ± 0%   12.86Mi ± 0%   -9.47% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12      20.67Mi ± 0%   17.86Mi ± 0%  -13.62% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12      34.02Mi ± 0%   34.03Mi ± 0%   +0.05% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12      40.40Mi ± 0%   39.05Mi ± 0%   -3.34% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12     46.95Mi ± 0%   44.14Mi ± 0%   -6.00% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12             1.613Ki ± 0%   1.613Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12             1.613Ki ± 0%   1.613Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12            1.613Ki ± 0%   1.613Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12            1.613Ki ± 0%   1.613Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12            1.613Ki ± 0%   1.613Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12           1.613Ki ± 0%   1.613Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12          1.579Mi ± 0%   1.579Mi ± 0%        ~ (p=0.180 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12          4.364Mi ± 0%   3.692Mi ± 0%  -15.40% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12         7.215Mi ± 0%   5.809Mi ± 0%  -19.48% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12         10.14Mi ± 0%   10.14Mi ± 0%        ~ (p=0.818 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12         12.95Mi ± 0%   12.28Mi ± 0%   -5.20% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12        15.83Mi ± 0%   14.42Mi ± 0%   -8.89% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12          6.561Mi ± 0%   6.584Mi ± 0%   +0.35% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12         10.043Mi ± 0%   9.370Mi ± 0%   -6.69% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12         13.63Mi ± 0%   12.22Mi ± 0%  -10.34% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12         23.96Mi ± 0%   23.98Mi ± 0%   +0.10% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12         27.47Mi ± 0%   26.79Mi ± 0%   -2.46% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12        31.07Mi ± 0%   29.66Mi ± 0%   -4.53% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12       7.924Mi ± 0%   7.948Mi ± 0%   +0.29% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12       14.21Mi ± 0%   12.86Mi ± 0%   -9.47% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12      20.67Mi ± 0%   17.86Mi ± 0%  -13.61% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12      34.02Mi ± 0%   34.04Mi ± 0%   +0.07% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12      40.41Mi ± 0%   39.07Mi ± 0%   -3.32% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12     46.95Mi ± 0%   44.15Mi ± 0%   -5.98% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12            16.07Ki ± 0%   16.07Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12            16.07Ki ± 0%   16.07Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12           16.07Ki ± 0%   16.07Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12           16.07Ki ± 0%   16.07Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12           16.07Ki ± 0%   16.07Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12          16.07Ki ± 0%   16.07Ki ± 0%        ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12         1.593Mi ± 0%   1.593Mi ± 0%        ~ (p=0.240 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12         4.379Mi ± 0%   3.706Mi ± 0%  -15.35% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12        7.229Mi ± 0%   5.823Mi ± 0%  -19.45% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12        10.16Mi ± 0%   10.16Mi ± 0%        ~ (p=0.818 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12        12.97Mi ± 0%   12.29Mi ± 0%   -5.18% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12       15.84Mi ± 0%   14.43Mi ± 0%   -8.88% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12         6.576Mi ± 0%   6.599Mi ± 0%   +0.35% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12        10.057Mi ± 0%   9.385Mi ± 0%   -6.68% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12        13.64Mi ± 0%   12.24Mi ± 0%  -10.27% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12        23.98Mi ± 0%   24.00Mi ± 0%   +0.10% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12        27.48Mi ± 0%   26.80Mi ± 0%   -2.45% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12       31.08Mi ± 0%   29.67Mi ± 0%   -4.52% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12      7.939Mi ± 0%   7.962Mi ± 0%   +0.29% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12      14.23Mi ± 0%   12.88Mi ± 0%   -9.46% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12     20.69Mi ± 0%   17.88Mi ± 0%  -13.61% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12     34.03Mi ± 0%   34.06Mi ± 0%   +0.07% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12     40.43Mi ± 0%   39.07Mi ± 0%   -3.35% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12    46.99Mi ± 0%   44.16Mi ± 0%   -6.01% (p=0.002 n=6)
geomean                                                                                                                                       3.244Mi        3.084Mi        -4.93%
¹ all samples are equal

                                                                                                                                           │  main.txt   │               opt.txt               │
                                                                                                                                           │  allocs/op  │  allocs/op   vs base                │
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12         22.10k ± 0%   22.10k ± 0%       ~ (p=0.632 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12         57.21k ± 0%   54.19k ± 0%  -5.27% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12        88.31k ± 0%   84.29k ± 0%  -4.55% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12        62.30k ± 0%   62.27k ± 0%  -0.05% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12        97.76k ± 0%   94.69k ± 0%  -3.14% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12       129.2k ± 0%   125.0k ± 0%  -3.22% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12         73.27k ± 0%   74.27k ± 0%  +1.36% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12         112.4k ± 0%   109.4k ± 0%  -2.68% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12        144.5k ± 0%   140.5k ± 0%  -2.78% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12        93.86k ± 0%   94.83k ± 0%  +1.04% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12        133.3k ± 0%   130.2k ± 0%  -2.33% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12       165.6k ± 0%   161.6k ± 0%  -2.47% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12      95.54k ± 0%   96.53k ± 0%  +1.04% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12      170.0k ± 0%   164.0k ± 0%  -3.55% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12     233.5k ± 0%   225.4k ± 0%  -3.47% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12     160.1k ± 0%   160.9k ± 0%  +0.51% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12     236.1k ± 0%   229.9k ± 0%  -2.60% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_0/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12    300.4k ± 0%   292.2k ± 0%  -2.72% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12             17.00 ± 0%    17.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12             17.00 ± 0%    17.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12            17.00 ± 0%    17.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12            17.00 ± 0%    17.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12            17.00 ± 0%    17.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12           17.00 ± 0%    17.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12         22.12k ± 0%   22.12k ± 0%       ~ (p=0.152 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12         57.22k ± 0%   54.21k ± 0%  -5.26% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12        88.33k ± 0%   84.31k ± 0%  -4.55% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12        62.33k ± 0%   62.32k ± 0%       ~ (p=0.193 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12        97.80k ± 0%   94.75k ± 0%  -3.12% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12       129.2k ± 0%   125.1k ± 0%  -3.16% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12         73.28k ± 0%   74.28k ± 0%  +1.36% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12         112.4k ± 0%   109.4k ± 0%  -2.68% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12        144.6k ± 0%   140.5k ± 0%  -2.82% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12        93.87k ± 0%   94.88k ± 0%  +1.08% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12        133.4k ± 0%   130.3k ± 0%  -2.31% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12       165.7k ± 0%   161.6k ± 0%  -2.44% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12      95.55k ± 0%   96.55k ± 0%  +1.05% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12      170.0k ± 0%   164.0k ± 0%  -3.55% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12     233.5k ± 0%   225.4k ± 0%  -3.46% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12     160.1k ± 0%   161.1k ± 0%  +0.63% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12     236.2k ± 0%   230.2k ± 0%  -2.54% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_5/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12    300.4k ± 0%   292.4k ± 0%  -2.66% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12            64.00 ± 0%    64.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12            64.00 ± 0%    64.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12           64.00 ± 0%    64.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12           64.00 ± 0%    64.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12           64.00 ± 0%    64.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12          64.00 ± 0%    64.00 ± 0%       ~ (p=1.000 n=6) ¹
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12        22.17k ± 0%   22.17k ± 0%       ~ (p=0.232 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12        57.28k ± 0%   54.26k ± 0%  -5.26% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12       88.38k ± 0%   84.35k ± 0%  -4.55% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12       62.38k ± 0%   62.39k ± 0%       ~ (p=1.000 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12       97.85k ± 0%   94.85k ± 0%  -3.07% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_0/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12      129.2k ± 0%   125.2k ± 0%  -3.14% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_0-12        73.33k ± 0%   74.33k ± 0%  +1.37% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_5-12        112.4k ± 0%   109.4k ± 0%  -2.67% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_2/exemplars_per_series:_10-12       144.6k ± 0%   140.6k ± 0%  -2.74% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_0-12       93.92k ± 0%   94.94k ± 0%  +1.09% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_5-12       133.3k ± 0%   130.3k ± 0%  -2.25% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_0/labels_per_metric:_20/exemplars_per_series:_10-12      165.7k ± 0%   161.7k ± 0%  -2.44% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_0-12     95.61k ± 0%   96.61k ± 0%  +1.05% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_5-12     170.1k ± 0%   164.0k ± 0%  -3.55% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_2/exemplars_per_series:_10-12    233.5k ± 0%   225.5k ± 0%  -3.46% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_0-12    160.2k ± 0%   161.2k ± 0%  +0.62% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_5-12    236.3k ± 0%   230.0k ± 0%  -2.66% (p=0.002 n=6)
FromMetrics/resource_attribute_count:_50/histogram_count:_1000/non-histogram_count:_1000/labels_per_metric:_20/exemplars_per_series:_10-12   300.8k ± 0%   292.5k ± 0%  -2.78% (p=0.002 n=6)
geomean                                                                                                                                      25.77k        25.36k       -1.59%
¹ all samples are equal
```
</details>

**Documentation:** <Describe the documentation added.>

---------

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
  • Loading branch information
aknuds1 committed Jan 25, 2024
1 parent 4ed9e85 commit 082c427
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
18 changes: 8 additions & 10 deletions pkg/translator/prometheusremotewrite/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,8 @@ func isValidAggregationTemporality(metric pmetric.Metric) bool {

// addSingleHistogramDataPoint converts pt to 2 + min(len(ExplicitBounds), len(BucketCount)) + 1 samples. It
// ignore extra buckets if len(ExplicitBounds) > len(BucketCounts)
func addSingleHistogramDataPoint(pt pmetric.HistogramDataPoint, resource pcommon.Resource, metric pmetric.Metric, settings Settings, tsMap map[string]*prompb.TimeSeries) {
func addSingleHistogramDataPoint(pt pmetric.HistogramDataPoint, resource pcommon.Resource, metric pmetric.Metric, settings Settings, tsMap map[string]*prompb.TimeSeries, baseName string) {
timestamp := convertTimeStamp(pt.Timestamp())
// sum, count, and buckets of the histogram should append suffix to baseName
baseName := prometheustranslator.BuildCompliantName(metric, settings.Namespace, settings.AddMetricSuffixes)
baseLabels := createAttributes(resource, pt.Attributes(), settings.ExternalLabels)

createLabels := func(nameSuffix string, extras ...string) []prompb.Label {
Expand All @@ -270,6 +268,7 @@ func addSingleHistogramDataPoint(pt pmetric.HistogramDataPoint, resource pcommon
labels = append(labels, prompb.Label{Name: extras[extrasIdx], Value: extras[extrasIdx+1]})
}

// sum, count, and buckets of the histogram should append suffix to baseName
labels = append(labels, prompb.Label{Name: nameStr, Value: baseName + nameSuffix})

return labels
Expand Down Expand Up @@ -357,8 +356,7 @@ type exemplarType interface {
}

func getPromExemplars[T exemplarType](pt T) []prompb.Exemplar {
var promExemplars []prompb.Exemplar

promExemplars := make([]prompb.Exemplar, 0, pt.Exemplars().Len())
for i := 0; i < pt.Exemplars().Len(); i++ {
exemplar := pt.Exemplars().At(i)
exemplarRunes := 0
Expand All @@ -385,9 +383,10 @@ func getPromExemplars[T exemplarType](pt T) []prompb.Exemplar {
}
promExemplar.Labels = append(promExemplar.Labels, promLabel)
}
var labelsFromAttributes []prompb.Label

exemplar.FilteredAttributes().Range(func(key string, value pcommon.Value) bool {
attrs := exemplar.FilteredAttributes()
labelsFromAttributes := make([]prompb.Label, 0, attrs.Len())
attrs.Range(func(key string, value pcommon.Value) bool {
val := value.AsString()
exemplarRunes += utf8.RuneCountInString(key) + utf8.RuneCountInString(val)
promLabel := prompb.Label{
Expand Down Expand Up @@ -455,10 +454,8 @@ func maxTimestamp(a, b pcommon.Timestamp) pcommon.Timestamp {

// addSingleSummaryDataPoint converts pt to len(QuantileValues) + 2 samples.
func addSingleSummaryDataPoint(pt pmetric.SummaryDataPoint, resource pcommon.Resource, metric pmetric.Metric, settings Settings,
tsMap map[string]*prompb.TimeSeries) {
tsMap map[string]*prompb.TimeSeries, baseName string) {
timestamp := convertTimeStamp(pt.Timestamp())
// sum and count of the summary should append suffix to baseName
baseName := prometheustranslator.BuildCompliantName(metric, settings.Namespace, settings.AddMetricSuffixes)
baseLabels := createAttributes(resource, pt.Attributes(), settings.ExternalLabels)

createLabels := func(name string, extras ...string) []prompb.Label {
Expand All @@ -483,6 +480,7 @@ func addSingleSummaryDataPoint(pt pmetric.SummaryDataPoint, resource pcommon.Res
if pt.Flags().NoRecordedValue() {
sum.Value = math.Float64frombits(value.StaleNaN)
}
// sum and count of the summary should append suffix to baseName
sumlabels := createLabels(baseName + sumStr)
addSample(tsMap, sum, sumlabels, metric.Type().String())

Expand Down
4 changes: 3 additions & 1 deletion pkg/translator/prometheusremotewrite/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func Test_getPromExemplars(t *testing.T) {
{
"without_exemplar",
pmetric.NewHistogramDataPoint(),
nil,
[]prompb.Exemplar{},
},
}
// run tests
Expand Down Expand Up @@ -762,6 +762,7 @@ func TestAddSingleSummaryDataPoint(t *testing.T) {
ExportCreatedMetric: true,
},
got,
metric.Name(),
)
}
assert.Equal(t, tt.want(), got)
Expand Down Expand Up @@ -873,6 +874,7 @@ func TestAddSingleHistogramDataPoint(t *testing.T) {
ExportCreatedMetric: true,
},
got,
metric.Name(),
)
}
assert.Equal(t, tt.want(), got)
Expand Down
13 changes: 7 additions & 6 deletions pkg/translator/prometheusremotewrite/metrics_to_prw.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ func FromMetrics(md pmetric.Metrics, settings Settings) (tsMap map[string]*promp
continue
}

promName := prometheustranslator.BuildCompliantName(metric, settings.Namespace, settings.AddMetricSuffixes)

// handle individual metric based on type
//exhaustive:enforce
switch metric.Type() {
Expand All @@ -59,35 +61,34 @@ func FromMetrics(md pmetric.Metrics, settings Settings) (tsMap map[string]*promp
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name()))
}
for x := 0; x < dataPoints.Len(); x++ {
addSingleGaugeNumberDataPoint(dataPoints.At(x), resource, metric, settings, tsMap)
addSingleGaugeNumberDataPoint(dataPoints.At(x), resource, metric, settings, tsMap, promName)
}
case pmetric.MetricTypeSum:
dataPoints := metric.Sum().DataPoints()
if dataPoints.Len() == 0 {
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name()))
}
for x := 0; x < dataPoints.Len(); x++ {
addSingleSumNumberDataPoint(dataPoints.At(x), resource, metric, settings, tsMap)
addSingleSumNumberDataPoint(dataPoints.At(x), resource, metric, settings, tsMap, promName)
}
case pmetric.MetricTypeHistogram:
dataPoints := metric.Histogram().DataPoints()
if dataPoints.Len() == 0 {
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name()))
}
for x := 0; x < dataPoints.Len(); x++ {
addSingleHistogramDataPoint(dataPoints.At(x), resource, metric, settings, tsMap)
addSingleHistogramDataPoint(dataPoints.At(x), resource, metric, settings, tsMap, promName)
}
case pmetric.MetricTypeExponentialHistogram:
dataPoints := metric.ExponentialHistogram().DataPoints()
if dataPoints.Len() == 0 {
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name()))
}
name := prometheustranslator.BuildCompliantName(metric, settings.Namespace, settings.AddMetricSuffixes)
for x := 0; x < dataPoints.Len(); x++ {
errs = multierr.Append(
errs,
addSingleExponentialHistogramDataPoint(
name,
promName,
dataPoints.At(x),
resource,
settings,
Expand All @@ -101,7 +102,7 @@ func FromMetrics(md pmetric.Metrics, settings Settings) (tsMap map[string]*promp
errs = multierr.Append(errs, fmt.Errorf("empty data points. %s is dropped", metric.Name()))
}
for x := 0; x < dataPoints.Len(); x++ {
addSingleSummaryDataPoint(dataPoints.At(x), resource, metric, settings, tsMap)
addSingleSummaryDataPoint(dataPoints.At(x), resource, metric, settings, tsMap, promName)
}
default:
errs = multierr.Append(errs, errors.New("unsupported metric type"))
Expand Down
21 changes: 10 additions & 11 deletions pkg/translator/prometheusremotewrite/number_data_points.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
"github.com/prometheus/prometheus/prompb"
"go.opentelemetry.io/collector/pdata/pcommon"
"go.opentelemetry.io/collector/pdata/pmetric"

prometheustranslator "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus"
)

// addSingleSumNumberDataPoint converts the Gauge metric data point to a
Expand All @@ -24,8 +22,8 @@ func addSingleGaugeNumberDataPoint(
metric pmetric.Metric,
settings Settings,
series map[string]*prompb.TimeSeries,
name string,
) {
name := prometheustranslator.BuildCompliantName(metric, settings.Namespace, settings.AddMetricSuffixes)
labels := createAttributes(
resource,
pt.Attributes(),
Expand Down Expand Up @@ -57,8 +55,8 @@ func addSingleSumNumberDataPoint(
metric pmetric.Metric,
settings Settings,
series map[string]*prompb.TimeSeries,
name string,
) {
name := prometheustranslator.BuildCompliantName(metric, settings.Namespace, settings.AddMetricSuffixes)
labels := createAttributes(
resource,
pt.Attributes(),
Expand Down Expand Up @@ -89,13 +87,14 @@ func addSingleSumNumberDataPoint(
if settings.ExportCreatedMetric && metric.Sum().IsMonotonic() {
startTimestamp := pt.StartTimestamp()
if startTimestamp != 0 {
createdLabels := createAttributes(
resource,
pt.Attributes(),
settings.ExternalLabels,
nameStr,
name+createdSuffix,
)
createdLabels := make([]prompb.Label, len(labels))
copy(createdLabels, labels)
for i, l := range createdLabels {
if l.Name == model.MetricNameLabel {
createdLabels[i].Value = name + createdSuffix
break
}
}
addCreatedTimeSeriesIfNeeded(series, createdLabels, startTimestamp, pt.Timestamp(), metric.Type().String())
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func TestAddSingleGaugeNumberDataPoint(t *testing.T) {
metric,
Settings{},
gotSeries,
metric.Name(),
)
}
assert.Equal(t, tt.want(), gotSeries)
Expand Down Expand Up @@ -236,6 +237,7 @@ func TestAddSingleSumNumberDataPoint(t *testing.T) {
metric,
Settings{ExportCreatedMetric: true},
got,
metric.Name(),
)
}
assert.Equal(t, tt.want(), got)
Expand Down

0 comments on commit 082c427

Please sign in to comment.