Tyler Yahn
9587c57d48
Optimize attribute slice conversion ( #8039 )
...
This PR refactors the internal slice conversion helpers in
`attribute/internal` to use generics and adds explicit short-length fast
paths for slice-backed attribute values.
The main changes are:
- replace the old type-specific internal helpers with generic
`SliceValue[T]` and `AsSlice[T]`
- preserve the comparable-array storage model used by `Value` and
`KeyValue`
- add fixed-size fast paths for lengths `0..3`
- add a matching short-length fast path in `IntSliceValue` before
falling back to `[]int64` conversion
- keep reflection as the fallback for larger slice lengths
- keep the existing `Value.As*Slice()` methods in `attribute` as thin
wrappers over the generic internal helpers
- add type-mismatch coverage for `AsSlice[T]`
- expand the benchmark suite so it measures both:
- short slices that hit the new fixed-size path
- longer slices that still use the reflective fallback
## Rationale
The package still needs reflection for arbitrary runtime lengths because
slice values are stored as comparable arrays behind `any`, and Go cannot
construct a runtime-sized array type without `reflect.ArrayOf`.
The fast path is intentionally small. The cutoff of `0..3` is based on a
combination of:
- benchmark gains for short slices
- semantic convention examples where `1..3` values are common
- downstream source analysis, which found that most external call sites
pass variables rather than inline literals, so static source scanning
does not justify a larger cutoff
## External Usage Validation
Downstream scan:
- sampled repos cloned and scanned: `285`
- most external call sites pass dynamic slice variables, not inline
literals
- final literal counts recovered statically:
- `StringSlice`: total `131`, dynamic `121`, literal len `0`: `1`, len
`1`: `8`, len `2`: `1`
- `IntSlice`: total `5`, all dynamic
- `Int64Slice`: total `6`, all dynamic
- `BoolSlice`: total `3`, all dynamic
- `Float64Slice`: total `3`, all dynamic
Semantic conventions reviewed locally in `semantic-conventions` include
several slice-valued attributes where short lists are normal, for
example:
- `browser.brands`
- `gen_ai.request.stop_sequences`
- `gen_ai.request.encoding_formats`
- `gen_ai.response.finish_reasons`
- `user.roles`
- `file.attributes`
There are also clearly unbounded cases like headers, metadata, command
args, and some cloud/provider arrays. That combination supports a small
fast path, but not an assumption that all real-world slices are tiny.
## Benchmarks
Changes to the benchmarks:
- internal microbenchmarks now run both `Len2` and `Len8`
- public `attribute` benchmarks now run both `Len2` and `Len8`
- repeated benchmark runs were compared with `benchstat`
`Len2` exercises the new fixed-size path. `Len8` exercises the
reflective fallback path.
Headline result:
- short slices improve substantially
- large slices stay close to baseline because they still use reflection
- `IntSlice` now gets the same short-slice win as the other slice types,
but larger `[]int` values still pay the `[]int` to `[]int64` conversion
cost
### Internal Helpers
```text
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/attribute/internal
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
│ /tmp/bench-internal-base-v2.txt │ /tmp/bench-internal-current-v2.txt │
│ sec/op │ sec/op vs base │
BoolSliceValue/Len2-8 124.00n ± 4% 19.36n ± 12% -84.39% (p=0.000 n=12)
BoolSliceValue/Len8-8 129.9n ± 2% 136.8n ± 3% +5.31% (p=0.000 n=12)
Int64SliceValue/Len2-8 146.00n ± 26% 26.13n ± 3% -82.10% (p=0.000 n=12)
Int64SliceValue/Len8-8 172.1n ± 4% 174.9n ± 5% ~ (p=0.443 n=12)
Float64SliceValue/Len2-8 151.70n ± 2% 26.25n ± 2% -82.70% (p=0.000 n=12)
Float64SliceValue/Len8-8 173.6n ± 2% 169.7n ± 4% ~ (p=0.155 n=12)
StringSliceValue/Len2-8 177.15n ± 2% 42.03n ± 3% -76.27% (p=0.000 n=12)
StringSliceValue/Len8-8 217.2n ± 6% 219.1n ± 6% ~ (p=0.504 n=12)
AsFloat64Slice/Len2-8 96.77n ± 3% 63.05n ± 27% -34.84% (p=0.000 n=12)
AsFloat64Slice/Len8-8 123.8n ± 18% 117.1n ± 4% ~ (p=1.000 n=12)
geomean 147.6n 71.85n -51.33%
│ /tmp/bench-internal-base-v2.txt │ /tmp/bench-internal-current-v2.txt │
│ B/op │ B/op vs base │
BoolSliceValue/Len2-8 4.000 ± 0% 2.000 ± 0% -50.00% (p=0.000 n=12)
BoolSliceValue/Len8-8 16.00 ± 0% 16.00 ± 0% ~ (p=1.000 n=12) ¹
Int64SliceValue/Len2-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=12)
Int64SliceValue/Len8-8 128.0 ± 0% 128.0 ± 0% ~ (p=1.000 n=12) ¹
Float64SliceValue/Len2-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=12)
Float64SliceValue/Len8-8 128.0 ± 0% 128.0 ± 0% ~ (p=1.000 n=12) ¹
StringSliceValue/Len2-8 64.00 ± 0% 32.00 ± 0% -50.00% (p=0.000 n=12)
StringSliceValue/Len8-8 256.0 ± 0% 256.0 ± 0% ~ (p=1.000 n=12) ¹
AsFloat64Slice/Len2-8 40.00 ± 0% 40.00 ± 0% ~ (p=1.000 n=12) ¹
AsFloat64Slice/Len8-8 88.00 ± 0% 88.00 ± 0% ~ (p=1.000 n=12) ¹
geomean 47.77 36.21 -24.21%
¹ all samples are equal
│ /tmp/bench-internal-base-v2.txt │ /tmp/bench-internal-current-v2.txt │
│ allocs/op │ allocs/op vs base │
BoolSliceValue/Len2-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
BoolSliceValue/Len8-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
Int64SliceValue/Len2-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
Int64SliceValue/Len8-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
Float64SliceValue/Len2-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
Float64SliceValue/Len8-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
StringSliceValue/Len2-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
StringSliceValue/Len8-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
AsFloat64Slice/Len2-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
AsFloat64Slice/Len8-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
geomean 2.000 1.516 -24.21%
¹ all samples are equal
```
### Public `attribute` API
```text
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/attribute
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
│ /tmp/bench-attr-base-v2.txt │ /tmp/bench-attr-current-v3.txt │
│ sec/op │ sec/op vs base │
BoolSlice/Len2/Value-8 130.65n ± 3% 16.90n ± 3% -87.06% (p=0.000 n=12)
BoolSlice/Len2/KeyValue-8 135.85n ± 14% 23.49n ± 2% -82.71% (p=0.000 n=12)
BoolSlice/Len2/AsBoolSlice-8 50.22n ± 1% 19.12n ± 15% -61.92% (p=0.000 n=12)
BoolSlice/Len2/Emit-8 343.9n ± 1% 293.4n ± 1% -14.68% (p=0.000 n=12)
BoolSlice/Len8/Value-8 134.7n ± 2% 136.4n ± 2% +1.22% (p=0.011 n=12)
BoolSlice/Len8/KeyValue-8 137.7n ± 2% 140.6n ± 2% +2.11% (p=0.046 n=12)
BoolSlice/Len8/AsBoolSlice-8 53.59n ± 22% 61.15n ± 22% +14.11% (p=0.020 n=12)
BoolSlice/Len8/Emit-8 773.5n ± 1% 788.5n ± 2% +1.93% (p=0.028 n=12)
IntSlice/Len2/Value-8 140.85n ± 2% 36.20n ± 3% -74.30% (p=0.000 n=12)
IntSlice/Len2/KeyValue-8 149.65n ± 2% 42.84n ± 3% -71.37% (p=0.000 n=12)
IntSlice/Len2/Emit-8 318.2n ± 3% 279.6n ± 15% -12.15% (p=0.012 n=12)
IntSlice/Len8/Value-8 217.9n ± 1% 228.8n ± 2% +5.00% (p=0.001 n=12)
IntSlice/Len8/KeyValue-8 225.6n ± 29% 232.3n ± 3% ~ (p=0.767 n=12)
IntSlice/Len8/Emit-8 480.0n ± 1% 478.6n ± 2% ~ (p=0.899 n=12)
Int64Slice/Len2/Value-8 150.90n ± 1% 27.43n ± 3% -81.82% (p=0.000 n=12)
Int64Slice/Len2/KeyValue-8 152.05n ± 1% 34.34n ± 3% -77.42% (p=0.000 n=12)
Int64Slice/Len2/AsInt64Slice-8 58.69n ± 4% 28.58n ± 3% -51.30% (p=0.000 n=12)
Int64Slice/Len2/Emit-8 318.4n ± 3% 273.9n ± 1% -13.99% (p=0.000 n=12)
Int64Slice/Len8/Value-8 173.0n ± 8% 177.8n ± 2% ~ (p=0.173 n=12)
Int64Slice/Len8/KeyValue-8 184.0n ± 24% 184.3n ± 2% ~ (p=0.701 n=12)
Int64Slice/Len8/AsInt64Slice-8 72.04n ± 2% 83.05n ± 2% +15.30% (p=0.000 n=12)
Int64Slice/Len8/Emit-8 474.9n ± 19% 501.9n ± 18% +5.67% (p=0.020 n=12)
Float64Slice/Len2/Value-8 150.95n ± 3% 26.92n ± 3% -82.17% (p=0.000 n=12)
Float64Slice/Len2/KeyValue-8 153.95n ± 3% 33.08n ± 2% -78.52% (p=0.000 n=12)
Float64Slice/Len2/AsFloat64Slice-8 60.31n ± 24% 27.02n ± 1% -55.19% (p=0.000 n=12)
Float64Slice/Len2/Emit-8 434.2n ± 2% 380.4n ± 1% -12.40% (p=0.000 n=12)
Float64Slice/Len8/Value-8 173.7n ± 2% 175.2n ± 25% ~ (p=0.248 n=12)
Float64Slice/Len8/KeyValue-8 174.0n ± 4% 175.2n ± 2% ~ (p=0.702 n=12)
Float64Slice/Len8/AsFloat64Slice-8 71.17n ± 8% 78.00n ± 4% +9.58% (p=0.007 n=12)
Float64Slice/Len8/Emit-8 920.6n ± 20% 909.9n ± 8% ~ (p=0.378 n=12)
StringSlice/Len2/Value-8 174.00n ± 5% 41.97n ± 20% -75.88% (p=0.000 n=12)
StringSlice/Len2/KeyValue-8 179.85n ± 2% 46.76n ± 2% -74.00% (p=0.000 n=12)
StringSlice/Len2/AsStringSlice-8 76.03n ± 5% 39.83n ± 3% -47.61% (p=0.000 n=12)
StringSlice/Len2/Emit-8 386.0n ± 2% 332.3n ± 3% -13.91% (p=0.000 n=12)
StringSlice/Len8/Value-8 225.4n ± 4% 226.2n ± 4% ~ (p=0.311 n=12)
StringSlice/Len8/KeyValue-8 228.1n ± 7% 234.2n ± 4% ~ (p=0.386 n=12)
StringSlice/Len8/AsStringSlice-8 110.8n ± 25% 117.8n ± 4% ~ (p=0.173 n=12)
StringSlice/Len8/Emit-8 658.7n ± 3% 647.9n ± 5% ~ (p=0.319 n=12)
geomean 181.7n 110.7n -39.08%
│ /tmp/bench-attr-base-v2.txt │ /tmp/bench-attr-current-v3.txt │
│ B/op │ B/op vs base │
BoolSlice/Len2/Value-8 4.000 ± 0% 2.000 ± 0% -50.00% (p=0.000 n=12)
BoolSlice/Len2/KeyValue-8 4.000 ± 0% 2.000 ± 0% -50.00% (p=0.000 n=12)
BoolSlice/Len2/AsBoolSlice-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len2/Emit-8 40.00 ± 0% 40.00 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len8/Value-8 16.00 ± 0% 16.00 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len8/KeyValue-8 16.00 ± 0% 16.00 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len8/AsBoolSlice-8 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len8/Emit-8 88.00 ± 0% 88.00 ± 0% ~ (p=1.000 n=12) ¹
IntSlice/Len2/Value-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=12)
IntSlice/Len2/KeyValue-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=12)
IntSlice/Len2/Emit-8 56.00 ± 0% 56.00 ± 0% ~ (p=1.000 n=12) ¹
IntSlice/Len8/Value-8 128.0 ± 0% 192.0 ± 0% +50.00% (p=0.000 n=12)
IntSlice/Len8/KeyValue-8 128.0 ± 0% 192.0 ± 0% +50.00% (p=0.000 n=12)
IntSlice/Len8/Emit-8 136.0 ± 0% 136.0 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len2/Value-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=12)
Int64Slice/Len2/KeyValue-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=12)
Int64Slice/Len2/AsInt64Slice-8 16.00 ± 0% 16.00 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len2/Emit-8 56.00 ± 0% 56.00 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len8/Value-8 128.0 ± 0% 128.0 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len8/KeyValue-8 128.0 ± 0% 128.0 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len8/AsInt64Slice-8 64.00 ± 0% 64.00 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len8/Emit-8 136.0 ± 0% 136.0 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len2/Value-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=12)
Float64Slice/Len2/KeyValue-8 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=12)
Float64Slice/Len2/AsFloat64Slice-8 16.00 ± 0% 16.00 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len2/Emit-8 56.00 ± 0% 56.00 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len8/Value-8 128.0 ± 0% 128.0 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len8/KeyValue-8 128.0 ± 0% 128.0 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len8/AsFloat64Slice-8 64.00 ± 0% 64.00 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len8/Emit-8 136.0 ± 0% 136.0 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len2/Value-8 64.00 ± 0% 32.00 ± 0% -50.00% (p=0.000 n=12)
StringSlice/Len2/KeyValue-8 64.00 ± 0% 32.00 ± 0% -50.00% (p=0.000 n=12)
StringSlice/Len2/AsStringSlice-8 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len2/Emit-8 120.0 ± 0% 120.0 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len8/Value-8 256.0 ± 0% 256.0 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len8/KeyValue-8 256.0 ± 0% 256.0 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len8/AsStringSlice-8 128.0 ± 0% 128.0 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len8/Emit-8 344.0 ± 0% 344.0 ± 0% ~ (p=1.000 n=12) ¹
geomean 49.39 42.05 -14.88%
¹ all samples are equal
│ /tmp/bench-attr-base-v2.txt │ /tmp/bench-attr-current-v3.txt │
│ allocs/op │ allocs/op vs base │
BoolSlice/Len2/Value-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
BoolSlice/Len2/KeyValue-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
BoolSlice/Len2/AsBoolSlice-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len2/Emit-8 5.000 ± 0% 5.000 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len8/Value-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len8/KeyValue-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len8/AsBoolSlice-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=12) ¹
BoolSlice/Len8/Emit-8 11.00 ± 0% 11.00 ± 0% ~ (p=1.000 n=12) ¹
IntSlice/Len2/Value-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
IntSlice/Len2/KeyValue-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
IntSlice/Len2/Emit-8 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=12) ¹
IntSlice/Len8/Value-8 2.000 ± 0% 3.000 ± 0% +50.00% (p=0.000 n=12)
IntSlice/Len8/KeyValue-8 2.000 ± 0% 3.000 ± 0% +50.00% (p=0.000 n=12)
IntSlice/Len8/Emit-8 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len2/Value-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
Int64Slice/Len2/KeyValue-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
Int64Slice/Len2/AsInt64Slice-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len2/Emit-8 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len8/Value-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len8/KeyValue-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len8/AsInt64Slice-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=12) ¹
Int64Slice/Len8/Emit-8 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len2/Value-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
Float64Slice/Len2/KeyValue-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
Float64Slice/Len2/AsFloat64Slice-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len2/Emit-8 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len8/Value-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len8/KeyValue-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len8/AsFloat64Slice-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=12) ¹
Float64Slice/Len8/Emit-8 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len2/Value-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
StringSlice/Len2/KeyValue-8 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=12)
StringSlice/Len2/AsStringSlice-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len2/Emit-8 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len8/Value-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len8/KeyValue-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len8/AsStringSlice-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=12) ¹
StringSlice/Len8/Emit-8 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=12) ¹
geomean 2.143 1.824 -14.88%
¹ all samples are equal
```
## Notes
- `Len2` is where the wins show up because those calls avoid
`reflect.ArrayOf` and one allocation.
- `Len8` stays much closer to baseline because it still uses the
reflective path.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com >
Co-authored-by: David Ashpole <dashpole@google.com >
2026-03-12 09:33:23 -07:00
renovate[bot]
6d79ac3936
fix(deps): update golang.org/x ( #8045 )
...
This PR contains the following updates:
| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/ ) |
[Confidence](https://docs.renovatebot.com/merge-confidence/ ) | Type |
Update |
|---|---|---|---|---|---|
| [golang.org/x/crypto](https://pkg.go.dev/golang.org/x/crypto ) |
[`v0.48.0` →
`v0.49.0`](https://cs.opensource.google/go/x/crypto/+/refs/tags/v0.48.0...refs/tags/v0.49.0 )
|

|

| indirect | minor |
| [golang.org/x/mod](https://pkg.go.dev/golang.org/x/mod ) | [`v0.33.0` →
`v0.34.0`](https://cs.opensource.google/go/x/mod/+/refs/tags/v0.33.0...refs/tags/v0.34.0 )
|

|

| indirect | minor |
| [golang.org/x/net](https://pkg.go.dev/golang.org/x/net ) | [`v0.51.0` →
`v0.52.0`](https://cs.opensource.google/go/x/net/+/refs/tags/v0.51.0...refs/tags/v0.52.0 )
|

|

| indirect | minor |
| [golang.org/x/telemetry](https://pkg.go.dev/golang.org/x/telemetry ) |
`e526e8a` → `579e4da` |

|

| indirect | digest |
| [golang.org/x/text](https://pkg.go.dev/golang.org/x/text ) | [`v0.34.0`
→
`v0.35.0`](https://cs.opensource.google/go/x/text/+/refs/tags/v0.34.0...refs/tags/v0.35.0 )
|

|

| indirect | minor |
| [golang.org/x/tools](https://pkg.go.dev/golang.org/x/tools ) |
[`v0.42.0` →
`v0.43.0`](https://cs.opensource.google/go/x/tools/+/refs/tags/v0.42.0...refs/tags/v0.43.0 )
|

|

| require | minor |
---
> [!WARNING]
> Some dependencies could not be looked up. Check the [Dependency
Dashboard](../issues/5322) for more information.
---
### Configuration
📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.
♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.
👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config
help](https://redirect.github.com/renovatebot/renovate/discussions ) if
that's undesired.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box
---
This PR was generated by [Mend Renovate](https://mend.io/renovate/ ).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-go ).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My41OS4wIiwidXBkYXRlZEluVmVyIjoiNDMuNTkuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: dmathieu <damien.mathieu@elastic.co >
2026-03-12 15:40:07 +01:00
Robert Pająk
f4da59e651
attribute: change INVALID Type to EMPTY and mark INVALID as deprecated ( #8038 )
...
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7932
Noticeable comment from previous PR:
https://github.com/open-telemetry/opentelemetry-go/pull/7942#discussion_r2913179215
Print the empty value as empty string per
https://opentelemetry.io/docs/specs/otel/common/#empty-values
2026-03-12 09:43:04 +01:00
Robert Pająk
4ba8200946
attribute: add TestNotEquivalence and equality operator tests ( #7979 )
...
Related to
https://github.com/open-telemetry/opentelemetry-go/issues/7970
Add missing unit tests.
2026-03-03 14:36:44 +01:00
Oleksandr Redko
3264bf171b
refactor: modernize code ( #7850 )
...
Enable the
[`modernize`](https://golangci-lint.run/docs/linters/configuration/#modernize )
linter in the golangci-lint configuration and fix the reported issues by
running `golangci-lint run --enable-only modernize --fix`. The
`modernize` linter is internally the same as [gopls
modernize](https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/modernize ).
Similar to #7089 .
2026-01-30 18:15:17 +01:00
Saharsh Tibrewala
3dc4cccef7
Add test cases to TestEmit in attribute ( #7751 )
...
Add test cases for `Key.Emit()` values:
- `BoolSliceValue`
- `IntValue`
- `IntSliceValue`
---------
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2026-01-05 08:32:29 -08:00
Preeti Dewani
49292857b7
Replace fnv with xxhash ( #7497 )
...
**Objective**:
- Performance comparison between fnv and xxhash in terms of ops/sec,
allocations and collisions
- Implement xxhash according to first objective
**Changes**:
- fnv is replaced by xxhash.
Perform stats:
- **Collision**: No collision upto 100M
- **Allocations**: Same in both cases
- **Ops/sec**: xxhash performed better in cases with medium to large
strings
**Benchmarks**:
```
benchstat old.txt new.txt
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/attribute
cpu: Apple M2
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
NewSet-8 205.5n ± 1% 229.4n ± 1% +11.61% (p=0.002 n=6)
NewSetSmallStrings-8 160.5n ± 1% 169.0n ± 5% +5.26% (p=0.002 n=6)
NewSetMediumStrings-8 263.8n ± 6% 185.0n ± 1% -29.89% (p=0.002 n=6)
NewSetLargeStrings-8 426.4n ± 9% 210.2n ± 1% -50.72% (p=0.002 n=6)
NewSetVeryLargeStrings-8 1012.5n ± 7% 238.7n ± 2% -76.43% (p=0.002 n=6)
NewSetHugeStrings-8 3622.0n ± 8% 397.1n ± 1% -89.04% (p=0.002 n=6)
geomean 488.6n 228.6n -53.21%
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
NewSet-8 448.0 ± 0% 448.0 ± 0% ~ (p=1.000 n=6) ¹
NewSetSmallStrings-8 320.0 ± 0% 320.0 ± 0% ~ (p=1.000 n=6) ¹
NewSetMediumStrings-8 320.0 ± 0% 320.0 ± 0% ~ (p=1.000 n=6) ¹
NewSetLargeStrings-8 320.0 ± 0% 320.0 ± 0% ~ (p=1.000 n=6) ¹
NewSetVeryLargeStrings-8 320.0 ± 0% 320.0 ± 0% ~ (p=1.000 n=6) ¹
NewSetHugeStrings-8 320.0 ± 0% 320.0 ± 0% ~ (p=1.000 n=6) ¹
geomean 338.5 338.5 +0.00%
¹ all samples are equal
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
NewSet-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=6) ¹
NewSetSmallStrings-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=6) ¹
NewSetMediumStrings-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=6) ¹
NewSetLargeStrings-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=6) ¹
NewSetVeryLargeStrings-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=6) ¹
NewSetHugeStrings-8 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=6) ¹
geomean 1.000 1.000 +0.00%
¹ all samples are equal
```
Previous implementation for reference:
https://github.com/open-telemetry/opentelemetry-go/blame/d0483a7c89d936dcced557fb523465daeac16967/CHANGELOG.md#L16
---------
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2025-11-19 11:06:20 +01:00
renovate[bot]
56138d1060
fix(deps): update golang.org/x ( #7482 )
...
This PR contains the following updates:
| Package | Type | Update | Change | Age | Confidence |
|---|---|---|---|---|---|
| golang.org/x/exp | require | digest | `27f1f14` -> `90e834f` |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| golang.org/x/exp/typeparams | indirect | digest | `27f1f14` ->
`90e834f` |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| golang.org/x/net | indirect | minor | `v0.45.0` -> `v0.46.0` |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| golang.org/x/telemetry | indirect | digest | `ca0c2a9` -> `24f779f` |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
| golang.org/x/tools | require | minor | `v0.37.0` -> `v0.38.0` |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
---
> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.
---
### Configuration
📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.
♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.
👻 **Immortal**: This PR will be recreated if closed unmerged. Get
[config
help](https://redirect.github.com/renovatebot/renovate/discussions ) if
that's undesired.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box
---
This PR was generated by [Mend Renovate](https://mend.io/renovate/ ).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-go ).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMzEuOSIsInVwZGF0ZWRJblZlciI6IjQxLjE0My4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJTa2lwIENoYW5nZWxvZyIsImRlcGVuZGVuY2llcyJdfQ==-->
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com >
2025-10-20 09:09:34 -07:00
Sebastien Dionne
1935e6012b
Fix typos and linguistic errors in documentation / hacktoberfest ( #7494 )
...
Fix typos and linguistic errors in documentation. It's not much, but I'm
happy to help
---------
Signed-off-by: Sebastien Dionne <survivant00@gmail.com >
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2025-10-13 15:57:14 -07:00
David Ashpole
9d52bde6d6
Use Set hash in Distinct (2nd attempt) ( #7175 )
...
Re-opening https://github.com/open-telemetry/opentelemetry-go/pull/5028
with new benchmarks. For cases with 10 attributes, this reduces the
overhead of metric measurements by ~80-90% (depending on lock
contention). It introduces a small probability of collision for
attribute sets in the metrics SDK. For an instrument with 1 million
different attribute sets, the probability of a collision is
approximately 2 * 10^-8. For a more "normal" cardinality of 1000 on an
instrument, it is approximately 2 * 10^-17.
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/attribute
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
│ main.txt │ hash.txt │
│ sec/op │ sec/op vs base │
EquivalentMapAccess/Empty-24 32.01n ± 2% 10.12n ± 4% -68.37% (p=0.002 n=6)
EquivalentMapAccess/1_string_attribute-24 106.25n ± 2% 10.01n ± 5% -90.58% (p=0.002 n=6)
EquivalentMapAccess/10_string_attributes-24 826.250n ± 1% 9.982n ± 11% -98.79% (p=0.002 n=6)
EquivalentMapAccess/1_int_attribute-24 106.65n ± 2% 10.13n ± 3% -90.50% (p=0.002 n=6)
EquivalentMapAccess/10_int_attributes-24 833.25n ± 2% 10.04n ± 5% -98.80% (p=0.002 n=6)
geomean 190.3n 10.06n -94.72%
```
Parallel benchmarks:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
│ main24.txt │ new24.txt │
│ sec/op │ sec/op vs base │
SyncMeasure/NoView/Int64Counter/Attributes/0-24 288.4n ± 13% 267.0n ± 16% ~ (p=0.180 n=6)
SyncMeasure/NoView/Int64Counter/Attributes/1-24 372.7n ± 24% 303.3n ± 6% -18.61% (p=0.002 n=6)
SyncMeasure/NoView/Int64Counter/Attributes/10-24 1862.5n ± 11% 302.2n ± 6% -83.77% (p=0.002 n=6)
SyncMeasure/NoView/Float64Counter/Attributes/0-24 288.2n ± 5% 291.8n ± 14% ~ (p=0.589 n=6)
SyncMeasure/NoView/Float64Counter/Attributes/1-24 374.8n ± 22% 326.2n ± 15% -12.98% (p=0.002 n=6)
SyncMeasure/NoView/Float64Counter/Attributes/10-24 1984.0n ± 10% 277.9n ± 15% -85.99% (p=0.002 n=6)
SyncMeasure/NoView/Int64UpDownCounter/Attributes/0-24 286.8n ± 13% 279.4n ± 14% ~ (p=0.818 n=6)
SyncMeasure/NoView/Int64UpDownCounter/Attributes/1-24 415.4n ± 14% 309.5n ± 11% -25.47% (p=0.002 n=6)
SyncMeasure/NoView/Int64UpDownCounter/Attributes/10-24 1923.0n ± 19% 294.1n ± 17% -84.71% (p=0.002 n=6)
SyncMeasure/NoView/Float64UpDownCounter/Attributes/0-24 284.9n ± 5% 271.6n ± 11% ~ (p=0.240 n=6)
SyncMeasure/NoView/Float64UpDownCounter/Attributes/1-24 382.9n ± 23% 295.7n ± 13% -22.78% (p=0.002 n=6)
SyncMeasure/NoView/Float64UpDownCounter/Attributes/10-24 1787.0n ± 28% 289.2n ± 12% -83.81% (p=0.002 n=6)
SyncMeasure/NoView/Int64Histogram/Attributes/0-24 283.4n ± 8% 269.9n ± 9% ~ (p=0.589 n=6)
SyncMeasure/NoView/Int64Histogram/Attributes/1-24 300.7n ± 8% 270.1n ± 15% -10.16% (p=0.026 n=6)
SyncMeasure/NoView/Int64Histogram/Attributes/10-24 1046.8n ± 24% 299.2n ± 16% -71.42% (p=0.002 n=6)
SyncMeasure/NoView/Float64Histogram/Attributes/0-24 264.3n ± 12% 295.9n ± 5% +11.93% (p=0.026 n=6)
SyncMeasure/NoView/Float64Histogram/Attributes/1-24 321.0n ± 8% 269.4n ± 11% -16.09% (p=0.002 n=6)
SyncMeasure/NoView/Float64Histogram/Attributes/10-24 1052.2n ± 10% 274.6n ± 5% -73.90% (p=0.002 n=6)
geomean 540.0n 287.7n -46.72%
```
Single-threaded benchmarks:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
│ main1.txt │ new1.txt │
│ sec/op │ sec/op vs base │
SyncMeasure/NoView/Int64Counter/Attributes/0 130.95n ± 1% 97.99n ± 21% -25.17% (p=0.002 n=6)
SyncMeasure/NoView/Int64Counter/Attributes/1 300.8n ± 7% 104.6n ± 3% -65.21% (p=0.002 n=6)
SyncMeasure/NoView/Int64Counter/Attributes/10 1646.0n ± 2% 105.8n ± 2% -93.58% (p=0.002 n=6)
SyncMeasure/NoView/Float64Counter/Attributes/0 132.65n ± 1% 99.28n ± 4% -25.16% (p=0.002 n=6)
SyncMeasure/NoView/Float64Counter/Attributes/1 295.4n ± 3% 107.7n ± 3% -63.54% (p=0.002 n=6)
SyncMeasure/NoView/Float64Counter/Attributes/10 1620.0n ± 1% 109.6n ± 4% -93.23% (p=0.002 n=6)
SyncMeasure/NoView/Int64UpDownCounter/Attributes/0 132.85n ± 80% 99.34n ± 1% -25.22% (p=0.002 n=6)
SyncMeasure/NoView/Int64UpDownCounter/Attributes/1 300.4n ± 1% 106.0n ± 1% -64.71% (p=0.002 n=6)
SyncMeasure/NoView/Int64UpDownCounter/Attributes/10 1622.0n ± 1% 105.8n ± 1% -93.48% (p=0.002 n=6)
SyncMeasure/NoView/Float64UpDownCounter/Attributes/0 134.90n ± 51% 99.16n ± 4% -26.49% (p=0.002 n=6)
SyncMeasure/NoView/Float64UpDownCounter/Attributes/1 312.4n ± 34% 107.8n ± 2% -65.51% (p=0.002 n=6)
SyncMeasure/NoView/Float64UpDownCounter/Attributes/10 1613.0n ± 23% 106.1n ± 1% -93.43% (p=0.002 n=6)
SyncMeasure/NoView/Int64Histogram/Attributes/0 103.50n ± 17% 88.53n ± 1% -14.46% (p=0.002 n=6)
SyncMeasure/NoView/Int64Histogram/Attributes/1 199.50n ± 16% 95.44n ± 2% -52.16% (p=0.002 n=6)
SyncMeasure/NoView/Int64Histogram/Attributes/10 878.70n ± 2% 95.78n ± 2% -89.10% (p=0.002 n=6)
SyncMeasure/NoView/Float64Histogram/Attributes/0 108.55n ± 54% 88.45n ± 1% -18.51% (p=0.002 n=6)
SyncMeasure/NoView/Float64Histogram/Attributes/1 257.30n ± 14% 95.05n ± 2% -63.06% (p=0.002 n=6)
SyncMeasure/NoView/Float64Histogram/Attributes/10 882.70n ± 18% 96.28n ± 1% -89.09% (p=0.002 n=6)
geomean 355.2n 100.3n -71.77%
```
---------
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2025-09-16 16:04:50 -04:00
Tyler Yahn
59563f7ae4
Do not use the user-defined empty set when comparing sets. ( #7357 )
...
Fix #7356
2025-09-15 09:28:12 -07:00
renovate[bot]
83c041a6cd
chore(deps): update module mvdan.cc/gofumpt to v0.9.0 ( #7292 )
...
This PR contains the following updates:
| Package | Change | Age | Confidence |
|---|---|---|---|
| [mvdan.cc/gofumpt](https://redirect.github.com/mvdan/gofumpt ) |
`v0.8.0` -> `v0.9.0` |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
---
> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.
---
### Release Notes
<details>
<summary>mvdan/gofumpt (mvdan.cc/gofumpt)</summary>
###
[`v0.9.0`](https://redirect.github.com/mvdan/gofumpt/blob/HEAD/CHANGELOG.md#v090---2025-09-02 )
[Compare
Source](https://redirect.github.com/mvdan/gofumpt/compare/v0.8.0...v0.9.0 )
This release is based on Go 1.25's gofmt, and requires Go 1.24 or later.
A new rule is introduced to "clothe" naked returns for the sake of
clarity.
While there is nothing wrong with naming results in function signatures,
using lone `return` statements can be confusing to the reader.
Go 1.25's `ignore` directives in `go.mod` files are now obeyed;
any directories within the module matching any of the patterns
are now omitted when walking directories, such as with `gofumpt -w .`.
Module information is now loaded via Go's [`x/mod/modfile`
package](https://pkg.go.dev/golang.org/x/mod/modfile )
rather than executing `go mod edit -json`, which is way faster.
This should result in moderate speed-ups when formatting many
directories.
</details>
---
### Configuration
📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).
🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.
♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.
🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.
---
- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box
---
This PR was generated by [Mend Renovate](https://mend.io/renovate/ ).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-go ).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS45MS4xIiwidXBkYXRlZEluVmVyIjoiNDEuOTEuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: dmathieu <damien.mathieu@elastic.co >
2025-09-03 10:18:12 +02:00
David Ashpole
18424a46ed
Add tests for attribute JSON marshalling ( #7268 )
...
Forked from
https://github.com/open-telemetry/opentelemetry-go/pull/7175#discussion_r2277148762
This adds a test for JSON marshaling of attribute sets.
---------
Co-authored-by: Flc゛ <four_leaf_clover@foxmail.com >
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2025-08-29 12:02:56 -04:00
David Ashpole
0724539e71
Add benchmark for set equality ( #7262 )
...
Forked from https://github.com/open-telemetry/opentelemetry-go/pull/7175
```
$ go test -timeout 60s -run=xxxxxMatchNothingxxxxx -test.benchtime=10ms -count 6 -cpu 1 -bench=BenchmarkEquals ./...
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/attribute
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkEquals/Empty 1314884 9.008 ns/op
BenchmarkEquals/Empty 1875915 8.461 ns/op
BenchmarkEquals/Empty 1461613 7.749 ns/op
BenchmarkEquals/Empty 1636912 9.359 ns/op
BenchmarkEquals/Empty 1863039 6.355 ns/op
BenchmarkEquals/Empty 1789053 6.336 ns/op
BenchmarkEquals/1_string_attribute 674168 16.92 ns/op
BenchmarkEquals/1_string_attribute 701983 16.42 ns/op
BenchmarkEquals/1_string_attribute 692001 16.52 ns/op
BenchmarkEquals/1_string_attribute 687970 16.29 ns/op
BenchmarkEquals/1_string_attribute 751766 16.58 ns/op
BenchmarkEquals/1_string_attribute 703534 16.88 ns/op
BenchmarkEquals/10_string_attributes 85400 137.1 ns/op
BenchmarkEquals/10_string_attributes 91045 136.1 ns/op
BenchmarkEquals/10_string_attributes 90973 150.7 ns/op
BenchmarkEquals/10_string_attributes 62877 177.5 ns/op
BenchmarkEquals/10_string_attributes 90780 194.2 ns/op
BenchmarkEquals/10_string_attributes 91058 144.6 ns/op
BenchmarkEquals/1_int_attribute 624625 18.72 ns/op
BenchmarkEquals/1_int_attribute 689478 16.03 ns/op
BenchmarkEquals/1_int_attribute 719173 15.68 ns/op
BenchmarkEquals/1_int_attribute 707005 16.18 ns/op
BenchmarkEquals/1_int_attribute 752048 15.94 ns/op
BenchmarkEquals/1_int_attribute 752034 16.23 ns/op
BenchmarkEquals/10_int_attributes 90302 132.5 ns/op
BenchmarkEquals/10_int_attributes 89929 131.9 ns/op
BenchmarkEquals/10_int_attributes 86578 135.2 ns/op
BenchmarkEquals/10_int_attributes 90482 133.1 ns/op
BenchmarkEquals/10_int_attributes 90255 132.0 ns/op
BenchmarkEquals/10_int_attributes 87615 134.6 ns/op
PASS
ok go.opentelemetry.io/otel/attribute 0.578s
PASS
ok go.opentelemetry.io/otel/attribute/internal 0.017s
```
---------
Co-authored-by: Flc゛ <four_leaf_clover@foxmail.com >
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2025-08-28 14:13:55 -04:00
Tyler Yahn
4623d0a989
Fix minor grammatical error in Distinct docs ( #7203 )
2025-08-18 12:24:26 +02:00
David Ashpole
eb4f1dc4a1
Add benchmark for map access using attribute Equivalent ( #7123 )
...
I am looking into I am looking into
https://promlabs.com/blog/2025/07/17/why-i-recommend-native-prometheus-instrumentation-over-opentelemetry/#comparing-counter-increment-performance ,
and was trying to figure out why incrementing a counter with 10
attributes was so much slower than incrementing a counter with no
attributes, or 1 attribute:
```
$ go test -run=xxxxxMatchNothingxxxxx -cpu=1 -test.benchtime=1s -bench=BenchmarkSyncMeasure/NoView/Int64Counter/Attributes
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkSyncMeasure/NoView/Int64Counter/Attributes/0 9905773 121.3 ns/op
BenchmarkSyncMeasure/NoView/Int64Counter/Attributes/1 4079145 296.5 ns/op
BenchmarkSyncMeasure/NoView/Int64Counter/Attributes/10 781627 1531 ns/op
```
Looking at the profile, most of the time is spent in
"runtime.mapKeyError2" within "runtime.mapaccess2". My best guess is
that whatever we are using for Equivalent() is not very performant when
used as a map key. This seems like a good opportunity to greatly improve
the performance of our metrics (and probably other signals) API + SDK.
To start, i'm adding a simple benchmark within the attribute package to
isolate the issue. Results:
```
$ go test -run '^$' -bench '^BenchmarkEquivalentMapAccess' -benchtime .1s -cpu 1 -benchmem
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/attribute
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkEquivalentMapAccess/Empty 2220508 53.58 ns/op 0 B/op 0 allocs/op
BenchmarkEquivalentMapAccess/1_string_attribute 622770 196.7 ns/op 0 B/op 0 allocs/op
BenchmarkEquivalentMapAccess/10_string_attributes 77462 1558 ns/op 0 B/op 0 allocs/op
BenchmarkEquivalentMapAccess/1_int_attribute 602163 197.7 ns/op 0 B/op 0 allocs/op
BenchmarkEquivalentMapAccess/10_int_attributes 76603 1569 ns/op 0 B/op 0 allocs/op
```
This shows that it is the map lookup and storage itself that is making
the metrics API+SDK perform much worse with more attributes.
Some optimization ideas include:
* Most attribute sets are likely to be just numbers and strings. Can we
make a fast path for sets that don't include complex attributes?
* We encourage improving performance of the metrics API by re-using
attribute sets where possible. If we can lazily compute+cache a "faster"
map key, that will have a big performance improvement when attribute
sets are re-used.
* compute a uint64 hash using something like
https://github.com/gohugoio/hashstructure , or something similar to what
prometheus/client_golang does:
https://github.com/prometheus/common/blob/c79a891c6c28ce135a2ac082b721c2dacc2269a8/model/signature.go#L31
---------
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
Co-authored-by: Flc゛ <four_leaf_clover@foxmail.com >
2025-08-06 14:45:22 -04:00
Matthieu MOREL
d464abf1f3
chore: enable unused-parameter rule from revive ( #7122 )
...
#### Description
Enable and fixes
[unused-parameter](https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-parameter )
rule from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com >
2025-08-04 12:48:04 -07:00
Matthieu MOREL
982391315f
chore: enable gocritic linter ( #7095 )
...
#### Description
Enable and fixes several rules from
[gocritic](https://golangci-lint.run/usage/linters/#gocritic ) linter
---------
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com >
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2025-07-29 09:20:32 -07:00
Mikhail Mazurskiy
5e1c62a2d5
Modernize ( #7089 )
...
Use
https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
to update code to new style.
---------
Co-authored-by: Flc゛ <four_leaf_clover@foxmail.com >
Co-authored-by: Damien Mathieu <42@dmathieu.com >
2025-07-29 10:19:11 +02:00
Robert Pająk
1737ab8666
docs: unify doc comments for functions returning bool ( #7064 )
...
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7063
If also fixes Go Doc comment for `SpanID.IsEmpty`.
The pattern is based on the way the Go standard library documents
functions returning a boolean.
2025-07-23 07:58:50 +02:00
igrucci
cc43e01c27
chore: move functionality from internal/rawhelpers.go to attribute ( #6578 )
...
Resolve #6524
---------
Signed-off-by: igrucci <babichevigor12@gmail.com >
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
Co-authored-by: Tyler Yahn <codingalias@gmail.com >
2025-04-10 09:04:50 -07:00
Rabel Mervin
5bf8691520
Functionality moved from internal/attribute to attribute ( #6580 )
...
Resolve #6525
## Description
This pull request addresses the issue of moving internal functionality
from the `internal/attribute` package to the `attribute `package within
the open-telemetry/opentelemetry-go repository. The goal is to ensure
that none of this functionality is added to the public API of the
attribute or any other public package while improving the naming,
layout, and following Go idioms.
## Changes made
1. Moved Functions to `attribute/internal`
- Created a new internal package within the `attribute` package:
`attribute/internal`.
- Moved `attribute.go` and `attribute_test.go` into the
`attribute/internal`
- Moved the following functions from `internal/attribute` to
`attribute/internal`
2 . Changes in .golangci.yml
- Removed line 67 and 68 from .golangci.yml
---------
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2025-04-03 14:12:30 +01:00
Tyler Yahn
7512a2be2e
Add the golines golangci-lint formatter ( #6513 )
...
Ensure consistent line wrapping (<= 120 characters) within the project.
2025-03-30 03:46:44 -07:00
ian
8dc08e26b4
attribute: preallocate map in NewAllowKeysFilter and NewDenyKeysFilter ( #6455 )
...
preallocate map in `NewAllowKeysFilter` and `NewDenyKeysFilter` to avoid
necessary allocations
2025-03-18 08:38:17 -07:00
Damien Mathieu
2c15a77942
Fix lint issues for golangci-lint 1.62.0 ( #5967 )
...
This fixes the new lint issues brough by the golangci-lint upgrade in
https://github.com/open-telemetry/opentelemetry-go/pull/5966
2024-11-13 08:58:59 +01:00
Lijingfeng
a7e83aace9
simplify conversions from slice to array ( #5818 )
...
Go 1.17 introduced an expression for convertion from slice to array, so
codes can be simplified.
Ref:
https://tip.golang.org/ref/spec#Conversions_from_slice_to_array_or_array_pointer
> Converting a slice to an array yields an array containing the elements
of the underlying array of the slice.
2024-09-16 09:17:59 +02:00
Damien Mathieu
a3c512aa95
Fix gosec overflow alerts ( #5799 )
...
To allow the golangci-lint upgrade in #5796 .
---------
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2024-09-13 09:11:50 +02:00
Damien Mathieu
f8b9fe3dbe
Emit attributes slices as their json representation ( #5159 )
...
* emit slices as their json representation
* add changelog
* fix resource tests
* indicate invalid slice if we couldn't turn them into json
* move changelog entry to the unreleased section
---------
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2024-05-07 07:42:07 -07:00
Damien Mathieu
edb788bf49
Add READMEs to every package ( #5103 )
2024-03-26 20:13:54 +01:00
Mikhail Mazurskiy
1fe2f03854
Deprecate Sortable ( #4734 )
...
* Deprecate Sortable
* Remove redundant checks
* Move code to a non-deprecated func
* Apply suggestions from code review
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
* Mention individual deprecated function
* Update attribute/set.go
Co-authored-by: Robert Pająk <pellared@hotmail.com >
* Add BenchmarkNewSet
---------
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2024-03-11 08:31:19 -07:00
Tyler Yahn
fe9bab54b7
Use Distinct instead of Set for map keys ( #5027 )
2024-03-06 11:11:16 +01:00
Robert Pająk
7dea232a46
[chore] Simplify the license header ( #4987 )
2024-02-29 07:05:28 +01:00
Alex Boten
8778c38832
docs: minor update to docstring ( #4833 )
...
Signed-off-by: Alex Boten <aboten@lightstep.com >
2024-01-19 15:18:16 +01:00
Tyler Yahn
deddec38ac
Optimize (attribute.Set).Filter for no filtered case ( #4774 )
...
* Optimize Set.Filter for no filtered case
When all elements of the Set are kept during a call to Filter, do not
allocate a new Set and the dropped attributes slice. Instead, return the
immutable Set and nil.
To achieve this the functionality of filterSet is broken down into a
more generic filteredToFront function.
* Apply suggestions from code review
Co-authored-by: Robert Pająk <pellared@hotmail.com >
* Rename run to benchFn based on review feedback
---------
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2024-01-08 07:49:45 -08:00
Tyler Yahn
5dff273a1e
Use gofumpt instead of gofmt ( #4623 )
...
* Use gofumpt instead of gofmt in golangci-lint conf
* Run gofumpt fixes
* Format generated templates
---------
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com >
2023-10-16 10:02:21 -07:00
Tyler Yahn
69611bd01a
Switch Stream back to having an AttributeFilter field and add New*Filter functions ( #4444 )
...
* Add allow/deny attr filters
* Revert "Replace `Stream.AttributeFilter` with `AllowAttributeKeys` (#4288 )"
This reverts commit 1633c74aea .
* Rename new attr filter funcs
Do not include the term "Attribute" in a creation function of the
"attribute" pkg.
* Update the AttributeFilter field documentation
* Add tests for filter creation funcs
* Add change to changelog
* Apply feedback
* Use NewDenyKeysFilter for allow-all and deny-list filters
* Remove links from field docs
These links do not render.
---------
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com >
2023-08-25 07:39:43 -07:00
Tyler Yahn
a25f4fe7ef
Guard zero value Set methods ( #3957 )
...
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com >
2023-04-04 08:06:10 -07:00
Tyler Yahn
b62eb2ca88
Pool sortables used to create attribute sets ( #3832 )
...
* Pool sortables used to create attribute sets
* Move sync pool to attribute pkg
* Add change to changelog
* Fix comment
* Apply suggestions from code review
Co-authored-by: Peter Liu <lpfvip2008@gmail.com >
* Update sdk/metric/instrument.go
Co-authored-by: Robert Pająk <pellared@hotmail.com >
* Update comment based on feedback
* Apply feedback
---------
Co-authored-by: Peter Liu <lpfvip2008@gmail.com >
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2023-03-13 11:19:28 -07:00
Peter Liu
d68b05fbee
Refactor package internal/attribute to not use generics. ( #3725 )
...
* remove generics
Signed-off-by: Peter Liu <lpfvip2008@gmail.com >
* Update internal/attribute/attribute.go
Co-authored-by: Damien Mathieu <42@dmathieu.com >
* Update internal/attribute/attribute.go
Co-authored-by: Damien Mathieu <42@dmathieu.com >
* Update internal/attribute/attribute.go
Co-authored-by: Damien Mathieu <42@dmathieu.com >
* Update internal/attribute/attribute.go
Co-authored-by: Damien Mathieu <42@dmathieu.com >
* Update internal/attribute/attribute.go
Co-authored-by: Damien Mathieu <42@dmathieu.com >
* Update internal/attribute/attribute.go
Co-authored-by: Damien Mathieu <42@dmathieu.com >
* Update internal/attribute/attribute.go
Co-authored-by: Damien Mathieu <42@dmathieu.com >
* Update internal/attribute/attribute.go
Co-authored-by: Damien Mathieu <42@dmathieu.com >
* refactor unit test
Signed-off-by: Peter Liu <lpfvip2008@gmail.com >
* add changelog
Signed-off-by: Peter Liu <lpfvip2008@gmail.com >
* update changelog
Signed-off-by: Peter Liu <lpfvip2008@gmail.com >
* Update internal/attribute/attribute.go
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
* replace interface{} with any
Signed-off-by: Peter Liu <lpfvip2008@gmail.com >
---------
Signed-off-by: Peter Liu <lpfvip2008@gmail.com >
Co-authored-by: Damien Mathieu <42@dmathieu.com >
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2023-02-15 10:37:07 -08:00
Aaron Clawson
d7b31155b5
Make the AsType functions not panic ( #3489 )
...
* Make the AsType functions not panic
* Adds changelog
Signed-off-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com >
Signed-off-by: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com >
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com >
2022-11-25 15:27:47 -08:00
Ziqi Zhao
a8b9ddc7f6
attribute: fix slice related function bug ( #3252 )
...
* attribute: fix slice related function bug
Signed-off-by: Ziqi Zhao <zhaoziqi9146@gmail.com >
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com >
2022-10-13 09:34:02 -05:00
Aaron Clawson
8423364f5a
Update golangci-lint to v1.48.0 ( #3105 )
...
* Update golangci-lint to v1.48.0
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com >
2022-08-24 21:42:28 -05:00
Tyler Yahn
1f5b159161
Use already enabled revive linter and add depguard ( #2883 )
...
* Refactor golangci-lint conf
Order settings alphabetically.
* Add revive settings to golangci conf
* Check blank imports
* Check bool-literal-in-expr
* Check constant-logical-expr
* Check context-as-argument
* Check context-key-type
* Check deep-exit
* Check defer
* Check dot-imports
* Check duplicated-imports
* Check early-return
* Check empty-block
* Check empty-lines
* Check error-naming
* Check error-return
* Check error-strings
* Check errorf
* Stop ignoring context first arg in tests
* Check exported comments
* Check flag-parameter
* Check identical branches
* Check if-return
* Check increment-decrement
* Check indent-error-flow
* Check deny list of go imports
* Check import shadowing
* Check package comments
* Check range
* Check range val in closure
* Check range val address
* Check redefines builtin id
* Check string-format
* Check struct tag
* Check superfluous else
* Check time equal
* Check var naming
* Check var declaration
* Check unconditional recursion
* Check unexported return
* Check unhandled errors
* Check unnecessary stmt
* Check unnecessary break
* Check waitgroup by value
* Exclude deep-exit check in example*_test.go files
2022-05-19 15:15:07 -05:00
Tyler Yahn
a8ea3dbb46
Replace use of old term label with attribute ( #2790 )
...
* Replace use of old term label with attribute
The specification has unified on the term attribute to describe
key-value pairs. There exist still many hold-overs of the use of the
term label. This updates those uses or deprecates exported types and
functions in favor of renamed forms.
* fix infinite recursion
* Remove backticks from attribute set docs
* Remove LabelFilterSelector entirely
* Remove Metadata.Labels instead of deprecate
* Update changelog with public changes
* Revert OC err msg
2022-04-18 07:31:31 -07:00
yellow chicks
b01dc21f6c
refactor: use Key's Defined method ( #2593 )
...
* optimize(attribute): use Key's Defined method
* Update kv.go
2022-02-10 19:41:34 -05:00
Aaron Clawson
f24f52aa06
Debug Logging for sdk/trace ( #2500 )
...
* Debug Logging for sdk/trace
* Fixes spelling, adds marshaling to attribute sets
Co-authored-by: Aaron Clawson <MadVikingGod@users.noreply.github.com >
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com >
2022-01-10 19:58:01 -05:00
Chester Cheung
7aba6f796f
update wrong doc comment with attribute value ( #2476 )
2021-12-20 08:10:34 -08:00
dependabot[bot]
e9db0473aa
Bump github.com/jcchavezs/porto from 0.2.1 to 0.3.0 in /internal/tools ( #2288 )
...
* Bump github.com/jcchavezs/porto from 0.2.1 to 0.3.0 in /internal/tools
Bumps [github.com/jcchavezs/porto](https://github.com/jcchavezs/porto ) from 0.2.1 to 0.3.0.
- [Release notes](https://github.com/jcchavezs/porto/releases )
- [Commits](https://github.com/jcchavezs/porto/compare/v0.2.1...v0.3.0 )
---
updated-dependencies:
- dependency-name: github.com/jcchavezs/porto
dependency-type: direct:production
update-type: version-update:semver-minor
...
Signed-off-by: dependabot[bot] <support@github.com >
* Auto-fix go.sum changes in dependent modules
* make precommit
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: MrAlias <MrAlias@users.noreply.github.com >
Co-authored-by: Tyler Yahn <codingalias@gmail.com >
2021-10-15 11:36:56 -07:00
José Carlos Chávez
099df58e4e
chore: adds vanity import check. ( #2255 )
...
* chore: adds vanity import check.
* chore: runs vanity import check on ci.
* fix: set right target on CI.
* fix: fixes install for porto.
* fix: install right proto bin.
* chore: list all files insides the tools directory.
* fix: fixes vanity import target
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
* chore(vanity-imports): adds vanity import support.
* fix: fixes internal generation.
* chore: runs go mod tidy in tools.
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
Co-authored-by: Anthony Mirabella <a9@aneurysm9.com >
2021-09-27 22:37:26 -04:00
Tyler Yahn
92551d3933
Prerelease v1.0.0 ( #2250 )
...
* Update versions file for 1.0.0 release
* Prepare stable-v1 for version v1.0.0
* Update trace signal status in documentation
* Update changelog
* Update CHANGELOG.md
Co-authored-by: Robert Pająk <pellared@hotmail.com >
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2021-09-20 13:02:46 -07:00