1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00

attribute: add SLICE type support (#8166)

Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7934

```
$ go test -run=^$ -bench=BenchmarkSlice
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/attribute
cpu: 13th Gen Intel(R) Core(TM) i7-13800H
BenchmarkSlice/Len3/Value-20                    25297926                52.56 ns/op          144 B/op          1 allocs/op
BenchmarkSlice/Len3/KeyValue-20                 21315132                55.97 ns/op          144 B/op          1 allocs/op
BenchmarkSlice/Len3/AsSlice-20                  24214248                50.03 ns/op          144 B/op          1 allocs/op
BenchmarkSlice/Len3/String-20                   14148270                86.48 ns/op           48 B/op          1 allocs/op
BenchmarkSlice/Len3/Emit-20                     13605388                85.18 ns/op           48 B/op          1 allocs/op
BenchmarkSlice/Len5Nested/Value-20              16086171                71.30 ns/op          240 B/op          1 allocs/op
BenchmarkSlice/Len5Nested/KeyValue-20           15547844                75.81 ns/op          240 B/op          1 allocs/op
BenchmarkSlice/Len5Nested/AsSlice-20            17806996                66.16 ns/op          240 B/op          1 allocs/op
BenchmarkSlice/Len5Nested/String-20              7409064               165.2 ns/op            64 B/op          1 allocs/op
BenchmarkSlice/Len5Nested/Emit-20                7666302               161.0 ns/op            64 B/op          1 allocs/op
PASS
ok      go.opentelemetry.io/otel/attribute      12.980s
```

```
$ go test -run=^$ -bench=BenchmarkHashKVs
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/attribute
cpu: 13th Gen Intel(R) Core(TM) i7-13800H
BenchmarkHashKVs-20      1268742               940.5 ns/op             0 B/op          0 allocs/op
PASS
ok      go.opentelemetry.io/otel/attribute      1.198s
```
This commit is contained in:
Robert Pająk
2026-04-16 12:38:32 +02:00
committed by GitHub
parent bb6804e300
commit d13f8ecb2d
16 changed files with 962 additions and 127 deletions
+3 -2
View File
@@ -18,11 +18,12 @@ func _() {
_ = x[FLOAT64SLICE-7]
_ = x[STRINGSLICE-8]
_ = x[BYTESLICE-9]
_ = x[SLICE-10]
}
const _Type_name = "EMPTYBOOLINT64FLOAT64STRINGBOOLSLICEINT64SLICEFLOAT64SLICESTRINGSLICEBYTESLICE"
const _Type_name = "EMPTYBOOLINT64FLOAT64STRINGBOOLSLICEINT64SLICEFLOAT64SLICESTRINGSLICEBYTESLICESLICE"
var _Type_index = [...]uint8{0, 5, 9, 14, 21, 27, 36, 46, 58, 69, 78}
var _Type_index = [...]uint8{0, 5, 9, 14, 21, 27, 36, 46, 58, 69, 78, 83}
func (i Type) String() string {
idx := int(i) - 0