1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-19 21:45:50 +02:00
Files
David Ashpole 6e3d3448fc Add WithUnsafeAttributes to support no-copy dynamic metric API calls (#8251)
Split from https://github.com/open-telemetry/opentelemetry-go/pull/8179

Part of https://github.com/open-telemetry/opentelemetry-go/issues/7743

This just defines the new WithUnsafeAttributes option, but converts it
to a set, and leaves the optimization of that path for a follow-up.

Benchmarks

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
                                                                              │   out.txt    │
                                                                              │    sec/op    │
EndToEndCounterAdd/NoFilter/Attributes/1/Precomputed/WithAttributeSet-24        65.18n ± 25%
EndToEndCounterAdd/NoFilter/Attributes/1/Precomputed/WithAttributes-24          61.96n ± 19%
EndToEndCounterAdd/NoFilter/Attributes/1/Precomputed/WithUnsafeAttributes-24    199.9n ± 22%
EndToEndCounterAdd/NoFilter/Attributes/1/Dynamic/WithAttributeSet-24            231.6n ±  9%
EndToEndCounterAdd/NoFilter/Attributes/1/Dynamic/WithAttributes-24              288.0n ± 14%
EndToEndCounterAdd/NoFilter/Attributes/1/Dynamic/WithUnsafeAttributes-24        271.9n ±  6%
EndToEndCounterAdd/NoFilter/Attributes/1/Naive/WithAttributes-24                352.7n ± 14%
EndToEndCounterAdd/NoFilter/Attributes/5/Precomputed/WithAttributeSet-24        68.73n ± 22%
EndToEndCounterAdd/NoFilter/Attributes/5/Precomputed/WithAttributes-24          61.04n ± 22%
EndToEndCounterAdd/NoFilter/Attributes/5/Precomputed/WithUnsafeAttributes-24    754.0n ± 25%
EndToEndCounterAdd/NoFilter/Attributes/5/Dynamic/WithAttributeSet-24            637.3n ± 21%
EndToEndCounterAdd/NoFilter/Attributes/5/Dynamic/WithAttributes-24              908.2n ± 28%
EndToEndCounterAdd/NoFilter/Attributes/5/Dynamic/WithUnsafeAttributes-24        901.7n ± 14%
EndToEndCounterAdd/NoFilter/Attributes/5/Naive/WithAttributes-24                1.062µ ± 15%
EndToEndCounterAdd/NoFilter/Attributes/10/Precomputed/WithAttributeSet-24       53.82n ± 28%
EndToEndCounterAdd/NoFilter/Attributes/10/Precomputed/WithAttributes-24         65.82n ±  5%
EndToEndCounterAdd/NoFilter/Attributes/10/Precomputed/WithUnsafeAttributes-24   1.717µ ± 14%
EndToEndCounterAdd/NoFilter/Attributes/10/Dynamic/WithAttributeSet-24           1.183µ ± 13%
EndToEndCounterAdd/NoFilter/Attributes/10/Dynamic/WithAttributes-24             1.803µ ± 20%
EndToEndCounterAdd/NoFilter/Attributes/10/Dynamic/WithUnsafeAttributes-24       2.050µ ± 15%
EndToEndCounterAdd/NoFilter/Attributes/10/Naive/WithAttributes-24               2.082µ ± 33%
EndToEndCounterAdd/Filtered/Attributes/1/Precomputed/WithAttributeSet-24        204.1n ± 14%
EndToEndCounterAdd/Filtered/Attributes/1/Precomputed/WithAttributes-24          214.5n ± 28%
EndToEndCounterAdd/Filtered/Attributes/1/Precomputed/WithUnsafeAttributes-24    433.9n ± 18%
EndToEndCounterAdd/Filtered/Attributes/1/Dynamic/WithAttributeSet-24            412.6n ± 10%
EndToEndCounterAdd/Filtered/Attributes/1/Dynamic/WithAttributes-24              464.1n ± 18%
EndToEndCounterAdd/Filtered/Attributes/1/Dynamic/WithUnsafeAttributes-24        471.4n ± 13%
EndToEndCounterAdd/Filtered/Attributes/1/Naive/WithAttributes-24                558.5n ± 19%
EndToEndCounterAdd/Filtered/Attributes/5/Precomputed/WithAttributeSet-24        772.4n ± 14%
EndToEndCounterAdd/Filtered/Attributes/5/Precomputed/WithAttributes-24          748.7n ±  9%
EndToEndCounterAdd/Filtered/Attributes/5/Precomputed/WithUnsafeAttributes-24    1.453µ ± 17%
EndToEndCounterAdd/Filtered/Attributes/5/Dynamic/WithAttributeSet-24            1.501µ ± 19%
EndToEndCounterAdd/Filtered/Attributes/5/Dynamic/WithAttributes-24              1.489µ ±  9%
EndToEndCounterAdd/Filtered/Attributes/5/Dynamic/WithUnsafeAttributes-24        1.608µ ± 24%
EndToEndCounterAdd/Filtered/Attributes/5/Naive/WithAttributes-24                1.671µ ± 14%
EndToEndCounterAdd/Filtered/Attributes/10/Precomputed/WithAttributeSet-24       1.324µ ± 18%
EndToEndCounterAdd/Filtered/Attributes/10/Precomputed/WithAttributes-24         1.463µ ± 17%
EndToEndCounterAdd/Filtered/Attributes/10/Precomputed/WithUnsafeAttributes-24   2.833µ ± 33%
EndToEndCounterAdd/Filtered/Attributes/10/Dynamic/WithAttributeSet-24           2.635µ ±  9%
EndToEndCounterAdd/Filtered/Attributes/10/Dynamic/WithAttributes-24             3.125µ ± 14%
EndToEndCounterAdd/Filtered/Attributes/10/Dynamic/WithUnsafeAttributes-24       2.685µ ± 24%
EndToEndCounterAdd/Filtered/Attributes/10/Naive/WithAttributes-24               3.404µ ±  8%
geomean                                                                         610.5n

                                                                              │    out.txt     │
                                                                              │      B/op      │
EndToEndCounterAdd/NoFilter/Attributes/1/Precomputed/WithAttributeSet-24          0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Precomputed/WithAttributes-24            0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Precomputed/WithUnsafeAttributes-24      128.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Dynamic/WithAttributeSet-24              88.00 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Dynamic/WithAttributes-24                152.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Dynamic/WithUnsafeAttributes-24          128.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Naive/WithAttributes-24                  232.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Precomputed/WithAttributeSet-24          0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Precomputed/WithAttributes-24            0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Precomputed/WithUnsafeAttributes-24      640.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Dynamic/WithAttributeSet-24              344.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Dynamic/WithAttributes-24                664.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Dynamic/WithUnsafeAttributes-24          640.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Naive/WithAttributes-24                 1000.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Precomputed/WithAttributeSet-24         0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Precomputed/WithAttributes-24           0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Precomputed/WithUnsafeAttributes-24   1.375Ki ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Dynamic/WithAttributeSet-24             729.0 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Dynamic/WithAttributes-24             1.399Ki ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Dynamic/WithUnsafeAttributes-24       1.376Ki ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Naive/WithAttributes-24               2.102Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Precomputed/WithAttributeSet-24          64.00 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Precomputed/WithAttributes-24            64.00 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Precomputed/WithUnsafeAttributes-24      192.0 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Dynamic/WithAttributeSet-24              152.0 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Dynamic/WithAttributes-24                216.0 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Dynamic/WithUnsafeAttributes-24          192.0 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Naive/WithAttributes-24                  296.0 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Precomputed/WithAttributeSet-24          576.0 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Precomputed/WithAttributes-24            576.0 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Precomputed/WithUnsafeAttributes-24    1.188Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Dynamic/WithAttributeSet-24              921.0 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Dynamic/WithAttributes-24              1.212Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Dynamic/WithUnsafeAttributes-24        1.188Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Naive/WithAttributes-24                1.539Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Precomputed/WithAttributeSet-24       1.312Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Precomputed/WithAttributes-24         1.312Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Precomputed/WithUnsafeAttributes-24   2.688Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Dynamic/WithAttributeSet-24           2.025Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Dynamic/WithAttributes-24             2.713Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Dynamic/WithUnsafeAttributes-24       2.689Ki ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Naive/WithAttributes-24               3.414Ki ± 0%
geomean                                                                                      ¹
¹ summaries must be >0 to compute geomean

                                                                              │   out.txt    │
                                                                              │  allocs/op   │
EndToEndCounterAdd/NoFilter/Attributes/1/Precomputed/WithAttributeSet-24        0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Precomputed/WithAttributes-24          0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Precomputed/WithUnsafeAttributes-24    2.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Dynamic/WithAttributeSet-24            2.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Dynamic/WithAttributes-24              3.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Dynamic/WithUnsafeAttributes-24        2.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/1/Naive/WithAttributes-24                5.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Precomputed/WithAttributeSet-24        0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Precomputed/WithAttributes-24          0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Precomputed/WithUnsafeAttributes-24    2.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Dynamic/WithAttributeSet-24            2.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Dynamic/WithAttributes-24              3.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Dynamic/WithUnsafeAttributes-24        2.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/5/Naive/WithAttributes-24                5.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Precomputed/WithAttributeSet-24       0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Precomputed/WithAttributes-24         0.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Precomputed/WithUnsafeAttributes-24   2.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Dynamic/WithAttributeSet-24           2.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Dynamic/WithAttributes-24             3.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Dynamic/WithUnsafeAttributes-24       2.000 ± 0%
EndToEndCounterAdd/NoFilter/Attributes/10/Naive/WithAttributes-24               5.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Precomputed/WithAttributeSet-24        1.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Precomputed/WithAttributes-24          1.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Precomputed/WithUnsafeAttributes-24    3.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Dynamic/WithAttributeSet-24            3.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Dynamic/WithAttributes-24              4.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Dynamic/WithUnsafeAttributes-24        3.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/1/Naive/WithAttributes-24                6.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Precomputed/WithAttributeSet-24        2.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Precomputed/WithAttributes-24          2.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Precomputed/WithUnsafeAttributes-24    4.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Dynamic/WithAttributeSet-24            4.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Dynamic/WithAttributes-24              5.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Dynamic/WithUnsafeAttributes-24        4.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/5/Naive/WithAttributes-24                7.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Precomputed/WithAttributeSet-24       2.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Precomputed/WithAttributes-24         2.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Precomputed/WithUnsafeAttributes-24   4.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Dynamic/WithAttributeSet-24           4.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Dynamic/WithAttributes-24             5.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Dynamic/WithUnsafeAttributes-24       4.000 ± 0%
EndToEndCounterAdd/Filtered/Attributes/10/Naive/WithAttributes-24               7.000 ± 0%
geomean                                                                                    ¹
¹ summaries must be >0 to compute geomean
```
2026-06-11 14:33:54 -04:00
..
2026-05-27 18:42:37 +02:00

Experimental Metric Options

This package contains experimental options for the OpenTelemetry metric package. These options are currently under development and not part of the stable API. They may be changed in backwards-incompatible ways, or removed entirely.