1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2025-11-23 22:34:47 +02:00
Commit Graph

1156 Commits

Author SHA1 Message Date
Damien Mathieu
e308db8adf chore: handle Float64Histogram in log/observe errMeter (#7555)
Calling other metrics from this meter provider should be a noop, not a
panic.
This fixes the test suite in
https://github.com/open-telemetry/opentelemetry-go/pull/7524
2025-10-31 13:55:01 -07:00
ian
b15942f345 Added the internal/observ package to log (#7532)
-  part of #7016

```txt
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/sdk/log/internal/observ
cpu: Apple M3
                            │ bench_res.txt │
                            │    sec/op     │
SLP/LogProcessed-8             0.8900n ± 2%
SLP/LogProcessedWithError-8     119.2n ± 5%
geomean                         10.30n

                            │ bench_res.txt │
                            │     B/op      │
SLP/LogProcessed-8             0.000 ± 0%
SLP/LogProcessedWithError-8    232.0 ± 0%
geomean                                   ¹
¹ summaries must be >0 to compute geomean

                            │ bench_res.txt │
                            │   allocs/op   │
SLP/LogProcessed-8             0.000 ± 0%
SLP/LogProcessedWithError-8    3.000 ± 0%
geomean                                   ¹
¹ summaries must be >0 to compute geomean
```

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-10-24 10:06:48 +02: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` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fexp/v0.0.0-20251017212417-90e834f514db?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fexp/v0.0.0-20251002181428-27f1f14c8bb9/v0.0.0-20251017212417-90e834f514db?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/exp/typeparams | indirect | digest | `27f1f14` ->
`90e834f` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fexp%2ftypeparams/v0.0.0-20251017212417-90e834f514db?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fexp%2ftypeparams/v0.0.0-20251002181428-27f1f14c8bb9/v0.0.0-20251017212417-90e834f514db?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/net | indirect | minor | `v0.45.0` -> `v0.46.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fnet/v0.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fnet/v0.45.0/v0.46.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/telemetry | indirect | digest | `ca0c2a9` -> `24f779f` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2ftelemetry/v0.0.0-20251014153721-24f779f6aaef?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2ftelemetry/v0.0.0-20251008162818-ca0c2a905e73/v0.0.0-20251014153721-24f779f6aaef?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/tools | require | minor | `v0.37.0` -> `v0.38.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2ftools/v0.38.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2ftools/v0.37.0/v0.38.0?slim=true)](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
Robert Wu
eb7ec3eb96 Simulate failures for histogram creation paths without risking a nil-interface panic (#7518)
Manual reader need to add Observability metric: #7009 .

If the code under test calls meter.Float64Histogram(...), the call will
be dispatched to the embedded mapi.Meter interface field, which is nil →
runtime panic (nil interface method call).

```
go test -timeout 60s -race ./sdk/...
ok  	go.opentelemetry.io/otel/sdk	(cached)
?   	go.opentelemetry.io/otel/sdk/instrumentation	[no test files]
ok  	go.opentelemetry.io/otel/sdk/internal/x	(cached)
ok  	go.opentelemetry.io/otel/sdk/resource	(cached)
ok  	go.opentelemetry.io/otel/sdk/trace	1.995s
?   	go.opentelemetry.io/otel/sdk/trace/internal	[no test files]
ok  	go.opentelemetry.io/otel/sdk/trace/internal/env	(cached)
2025/10/14 23:56:39 internal_logging.go:50: "msg"="Setting meter provider to its current value. No delegate will be configured" "error"="no delegate configured in meter provider"
--- FAIL: TestBSPCallback (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
[signal SIGSEGV: segmentation violation code=0x2 addr=0x28 pc=0x1044c8c24]
```

**Resolution**:
Add `Float64Histogram` to `errMeter`

**Context**:


https://github.com/open-telemetry/opentelemetry-go/pull/7500#discussion_r2431050902
2025-10-20 07:50:56 -07:00
Mahendra Bishnoi
f7d2882606 feat: sdk/trace: span processed metric for simple span processor (#7374)
Fixes #7004 

This PR adds support for experimental otel.sdk.processor.span.processed
metric in simple span processor.
Definition of metric at:
https://github.com/open-telemetry/semantic-conventions/blob/v1.36.0/docs/otel/sdk-metrics.md

Experimental metrics are behind a feature flag:
`OTEL_GO_X_OBSERVABILITY`

<details>
<summary>Observability Implementation Checklist</summary>

## Observability Implementation Checklist
Based on the [project Observability
guidelines](e4ab314112/CONTRIBUTING.md (observability)),
ensure the following are completed:

### Environment Variable Activation
* [x] Observability features are disabled by default
* [x] Features are activated through the `OTEL_GO_X_OBSERVABILITY`
environment variable
* [x] Use consistent pattern with `x.Observability.Enabled()` check [^1]
* [x] Follow established experimental feature pattern [^2][^3]

[^1]:
e4ab314112/exporters/stdout/stdouttrace/internal/observ/instrumentation.go (L101-L103)
[^2]:
e4ab314112/exporters/stdout/stdouttrace/internal/x/x.go
[^3]:
e4ab314112/sdk/internal/x/x.go

### Encapsulation
* [x] Instrumentation is encapsulated within a dedicated `struct` (e.g.,
[`Instrumentation`](e4ab314112/exporters/stdout/stdouttrace/internal/observ/instrumentation.go (L86-L94)))
* [x] Instrumentation is not mixed into the instrumented component
* [x] Instrumentation code is in its own file or package if
complex/reused
* [x] Instrumentation setup doesn't bloat the main component code

### Initialization
* [x] Initialization is only done when observability is enabled
* [x] Setup is explicit and side-effect free
* [x] Return errors from initialization when appropriate
* [x] Use the global Meter provider (e.g., `otel.GetMeterProvider()`)
* [x] Include proper meter configuration with:
  * [x] Instrumentation package name is used for the Meter
* [x] Instrumentation version (e.g.
[`Version`](e4ab314112/exporters/stdout/stdouttrace/internal/observ/instrumentation.go (L40-L43)))
* [x] Schema URL (e.g.
[`SchemaURL`](e4ab314112/exporters/stdout/stdouttrace/internal/observ/instrumentation.go (L36-L38)))

### Performance
* [x] Little to no overhead when observability is disabled
* [x] Expensive operations are only executed when observability is
enabled
* [x] When enabled, instrumentation code paths are optimized to reduce
allocation/computation overhead

#### Attribute and Option Allocation Management
* [x] Use `sync.Pool` for attribute slices and options with dynamic
attributes
* [x] Pool objects are properly reset before returning to pool
* [x] Pools are scoped for maximum efficiency while ensuring correctness

#### Caching
* [x] Static attribute sets known at compile time are pre-computed and
cached
* [x] Common attribute combinations use lookup tables/maps

#### Benchmarking
* [x] Benchmarks provided for all instrumentation code
* [ ] Benchmark scenarios include both enabled and disabled
observability
* [x] Benchmark results show impact on allocs/op, B/op, and ns/op (use
`b.ReportAllocs()` in benchmarks)

### Error Handling and Robustness
* [x] Errors are reported back to caller when possible
* [x] Partial failures are handled gracefully
* [x] Use partially initialized components when available
* [x] Return errors to caller instead of only using `otel.Handle()`
* [x] Use `otel.Handle()` only when component cannot report error to
user

### Context Propagation
* [x] Observability measurements receive the context from the function
being measured (don't break context propagation by using
`context.Background()`)

### Semantic Conventions Compliance
* [x] All metrics follow [OpenTelemetry Semantic
Conventions](5ee549b1ce/docs/otel/sdk-metrics.md)
* [x] Use the
[`otelconv`](https://pkg.go.dev/go.opentelemetry.io/otel@v1.38.0/semconv/v1.37.0/otelconv)
convenience package for metric semantic conventions
* [x] Component names follow semantic conventions
* [x] Use package path scope type as stable identifier for non-standard
components
* [x] Component names are stable unique identifiers
* [x] Use global counter for uniqueness if necessary
* [x] Component ID counter is resettable for deterministic testing

### Testing
* [x] Use deterministic testing with isolated state
* [x] Restore previous state after tests (`t.Cleanup()`)
* [x] Isolate meter provider for testing
* [x] Use `t.Setenv()` for environment variable testing
* [x] Reset component ID counter for deterministic component names
* [x] Test order doesn't affect results
</details>

### Benchmarks

```console
> benchstat bmark.result
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/sdk/trace/internal/observ
cpu: Apple M1 Pro
                             │ bmark.result │
                             │    sec/op    │
SSP/SpanProcessed-8            146.7n ± 15%
SSP/SpanProcessedWithError-8   205.1n ±  3%
geomean                        173.5n

                             │ bmark.result │
                             │     B/op     │
SSP/SpanProcessed-8              280.0 ± 0%
SSP/SpanProcessedWithError-8     408.0 ± 0%
geomean                          338.0

                             │ bmark.result │
                             │  allocs/op   │
SSP/SpanProcessed-8              3.000 ± 0%
SSP/SpanProcessedWithError-8     3.000 ± 0%
geomean                          3.000
```

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2025-10-17 15:57:35 -07:00
Robert Pająk
b5b6989c7a sdk/log: Fix AddAttributes, SetAttributes, SetBody on Record to not mutate input (#7403)
Fixes #7364

The allocations happen only when necessary.
This is when deduplication happens or data is truncated because of the
limits.

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/log
cpu: 13th Gen Intel(R) Core(TM) i7-13800H
                                              │    old.txt    │                new.txt                 │
                                              │    sec/op     │    sec/op      vs base                 │
AddAttributes/Single/NoLimits-20                 57.91n ± 19%    29.12n ±  5%   -49.71% (p=0.000 n=10)
AddAttributes/Single/AllowDuplicates-20          24.21n ±  2%    24.46n ± 17%    +1.05% (p=0.011 n=10)
AddAttributes/Unique/NoLimits-20                 174.6n ±  8%    184.2n ±  7%    +5.47% (p=0.027 n=10)
AddAttributes/Unique/AllowDuplicates-20          69.79n ± 22%    67.83n ±  9%    -2.81% (p=0.019 n=10)
AddAttributes/Deduplication/Enabled-20           144.5n ±  4%    165.8n ±  4%   +14.71% (p=0.000 n=10)
AddAttributes/NestedDeduplication/Enabled-20     439.2n ±  2%    792.4n ± 11%   +80.41% (p=0.000 n=10)
AddAttributes/NestedDeduplication/Disabled-20   162.60n ±  1%    86.84n ±  5%   -46.59% (p=0.000 n=10)
AddAttributes/Deduplication/Disabled-20          68.15n ±  8%    67.59n ±  8%         ~ (p=0.190 n=10)
AddAttributes/CountLimit/Hit-20                  629.1n ±  4%    621.0n ±  7%         ~ (p=0.325 n=10)
AddAttributes/CountLimit/NotHit-20               914.6n ±  7%    944.2n ± 13%         ~ (p=0.393 n=10)
AddAttributes/ValueLimit/Hit-20                  133.5n ±  2%    162.1n ±  2%   +21.43% (p=0.000 n=10)
AddAttributes/ValueLimit/NotHit-20               115.8n ±  9%    131.2n ±  8%   +13.26% (p=0.000 n=10)
SetAttributes/Single/NoLimits-20                 59.38n ±  2%    28.89n ± 22%   -51.36% (p=0.000 n=10)
SetAttributes/Single/AllowDuplicates-20          24.19n ±  1%    24.30n ±  2%         ~ (p=0.867 n=10)
SetAttributes/Unique/NoLimits-20                 179.8n ±  2%    200.7n ±  6%   +11.66% (p=0.000 n=10)
SetAttributes/Unique/AllowDuplicates-20          72.65n ±  6%    71.91n ±  6%         ~ (p=0.218 n=10)
SetAttributes/Deduplication/Enabled-20           143.9n ±  6%    188.5n ± 12%   +30.96% (p=0.000 n=10)
SetAttributes/Deduplication/Disabled-20          77.68n ± 12%    69.20n ±  8%   -10.92% (p=0.008 n=10)
SetAttributes/NestedDeduplication/Enabled-20     443.7n ± 11%    770.8n ±  7%   +73.75% (p=0.000 n=10)
SetAttributes/NestedDeduplication/Disabled-20   172.60n ±  4%    91.73n ± 11%   -46.85% (p=0.000 n=10)
SetAttributes/CountLimit/Hit-20                  629.1n ±  2%    631.3n ±  7%         ~ (p=0.971 n=10)
SetAttributes/CountLimit/NotHit-20               909.2n ±  8%    866.4n ±  7%         ~ (p=0.143 n=10)
SetAttributes/ValueLimit/Hit-20                  135.5n ±  2%    150.2n ±  5%   +10.85% (p=0.000 n=10)
SetAttributes/ValueLimit/NotHit-20               121.7n ±  7%    137.2n ±  6%   +12.65% (p=0.001 n=10)
SetAttributes/Overwrite/Existing-20              176.0n ±  5%    184.1n ±  2%    +4.60% (p=0.005 n=10)
SetBody/Simple/NoLimits-20                       13.54n ±  1%    13.34n ±  2%    -1.48% (p=0.027 n=10)
SetBody/Simple/WithLimits-20                     13.46n ± 11%    13.91n ±  9%         ~ (p=0.541 n=10)
SetBody/UniqueMap/NoLimits-20                    216.2n ±  8%    183.8n ±  3%   -14.94% (p=0.000 n=10)
SetBody/UniqueMap/AllowDuplicates-20             12.89n ±  1%    12.75n ±  1%    -1.05% (p=0.001 n=10)
SetBody/Deduplication/Enabled-20                 113.5n ±  2%    164.4n ±  4%   +44.85% (p=0.000 n=10)
SetBody/Deduplication/Disabled-20                12.93n ± 41%    12.74n ±  1%    -1.51% (p=0.000 n=10)
SetBody/NestedDeduplication/Enabled-20           206.4n ±  2%    493.4n ±  2%  +139.05% (p=0.000 n=10)
SetBody/NestedDeduplication/Disabled-20          12.93n ±  1%    12.98n ± 11%         ~ (p=0.515 n=10)
SetBody/ValueLimit/Hit-20                        86.22n ±  1%   110.25n ±  3%   +27.87% (p=0.000 n=10)
SetBody/ValueLimit/NoHit-20                      85.52n ±  8%   104.25n ±  1%   +21.91% (p=0.000 n=10)
geomean                                          104.2n          107.1n          +2.84%

                                              │   old.txt    │            new.txt             │
                                              │     B/op     │    B/op     vs base            │
AddAttributes/Single/NoLimits-20                0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Single/AllowDuplicates-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Unique/NoLimits-20                0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Unique/AllowDuplicates-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Deduplication/Enabled-20            0.0 ± 0%     128.0 ± 0%  ? (p=0.000 n=10)
AddAttributes/NestedDeduplication/Enabled-20      0.0 ± 0%     312.0 ± 0%  ? (p=0.000 n=10)
AddAttributes/NestedDeduplication/Disabled-20   0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Deduplication/Disabled-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/CountLimit/Hit-20                 208.0 ± 0%     208.0 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/CountLimit/NotHit-20              640.0 ± 0%     640.0 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/ValueLimit/Hit-20                 0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/ValueLimit/NotHit-20              0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Single/NoLimits-20                0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Single/AllowDuplicates-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Unique/NoLimits-20                0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Unique/AllowDuplicates-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Deduplication/Enabled-20            0.0 ± 0%     128.0 ± 0%  ? (p=0.000 n=10)
SetAttributes/Deduplication/Disabled-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/NestedDeduplication/Enabled-20      0.0 ± 0%     312.0 ± 0%  ? (p=0.000 n=10)
SetAttributes/NestedDeduplication/Disabled-20   0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/CountLimit/Hit-20                 208.0 ± 0%     208.0 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/CountLimit/NotHit-20              640.0 ± 0%     640.0 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/ValueLimit/Hit-20                 0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/ValueLimit/NotHit-20              0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Overwrite/Existing-20             0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/Simple/NoLimits-20                      0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/Simple/WithLimits-20                    0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/UniqueMap/NoLimits-20                   0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/UniqueMap/AllowDuplicates-20            0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/Deduplication/Enabled-20                  0.0 ± 0%     128.0 ± 0%  ? (p=0.000 n=10)
SetBody/Deduplication/Disabled-20               0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/NestedDeduplication/Enabled-20            0.0 ± 0%     280.0 ± 0%  ? (p=0.000 n=10)
SetBody/NestedDeduplication/Disabled-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/ValueLimit/Hit-20                       0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/ValueLimit/NoHit-20                     0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
geomean                                                    ²               ?                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                              │   old.txt    │            new.txt             │
                                              │  allocs/op   │ allocs/op   vs base            │
AddAttributes/Single/NoLimits-20                0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Single/AllowDuplicates-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Unique/NoLimits-20                0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Unique/AllowDuplicates-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Deduplication/Enabled-20          0.000 ± 0%     1.000 ± 0%  ? (p=0.000 n=10)
AddAttributes/NestedDeduplication/Enabled-20    0.000 ± 0%     5.000 ± 0%  ? (p=0.000 n=10)
AddAttributes/NestedDeduplication/Disabled-20   0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/Deduplication/Disabled-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/CountLimit/Hit-20                 1.000 ± 0%     1.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/CountLimit/NotHit-20              1.000 ± 0%     1.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/ValueLimit/Hit-20                 0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
AddAttributes/ValueLimit/NotHit-20              0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Single/NoLimits-20                0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Single/AllowDuplicates-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Unique/NoLimits-20                0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Unique/AllowDuplicates-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Deduplication/Enabled-20          0.000 ± 0%     1.000 ± 0%  ? (p=0.000 n=10)
SetAttributes/Deduplication/Disabled-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/NestedDeduplication/Enabled-20    0.000 ± 0%     5.000 ± 0%  ? (p=0.000 n=10)
SetAttributes/NestedDeduplication/Disabled-20   0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/CountLimit/Hit-20                 1.000 ± 0%     1.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/CountLimit/NotHit-20              1.000 ± 0%     1.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/ValueLimit/Hit-20                 0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/ValueLimit/NotHit-20              0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetAttributes/Overwrite/Existing-20             0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/Simple/NoLimits-20                      0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/Simple/WithLimits-20                    0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/UniqueMap/NoLimits-20                   0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/UniqueMap/AllowDuplicates-20            0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/Deduplication/Enabled-20                0.000 ± 0%     1.000 ± 0%  ? (p=0.000 n=10)
SetBody/Deduplication/Disabled-20               0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/NestedDeduplication/Enabled-20          0.000 ± 0%     4.000 ± 0%  ? (p=0.000 n=10)
SetBody/NestedDeduplication/Disabled-20         0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/ValueLimit/Hit-20                       0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
SetBody/ValueLimit/NoHit-20                     0.000 ± 0%     0.000 ± 0%  ~ (p=1.000 n=10) ¹
geomean                                                    ²               ?                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```
2025-10-16 21:07:08 +02:00
Nikhil Mantri
f346decaf6 chore: sdk/internal/x - generate x package from shared template (#7495)
Closes #7384 

- Add sdk/internal/gen.go with gotmpl directives to generate x/x.go and
x/x_test.go
- Refactor sdk/internal/x/x.go to generic Feature[T] with multi-key
support and Keys()
- Move Resource feature into sdk/internal/x/features.go
(case-insensitive true enables)
- Add tests: generic feature tests in x_test.go and Resource tests in
features_test.go
- Aligns with sdk/log/internal/x pattern introduced in PR #7389

Internal note: replaces Key() with Keys() for internal Feature API.
Build and lints pass

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-10-16 09:23:17 +02:00
renovate[bot]
9dea78c87f chore(deps): update module github.com/go-critic/go-critic to v0.14.0 (#7509)
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
|
[github.com/go-critic/go-critic](https://redirect.github.com/go-critic/go-critic)
| `v0.13.0` -> `v0.14.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fgo-critic%2fgo-critic/v0.14.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fgo-critic%2fgo-critic/v0.13.0/v0.14.0?slim=true)](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>go-critic/go-critic (github.com/go-critic/go-critic)</summary>

###
[`v0.14.0`](https://redirect.github.com/go-critic/go-critic/releases/tag/v0.14.0)

[Compare
Source](https://redirect.github.com/go-critic/go-critic/compare/v0.13.0...v0.14.0)

#### What's Changed

- checkers/exitAfterDefer: handle optional `defer` properly by
[@&#8203;Afterous](https://redirect.github.com/Afterous) in
[#&#8203;1437](https://redirect.github.com/go-critic/go-critic/pull/1437)
- checkers/deprecatedComment: check that deprecated convention appears
in a separate paragraph by
[@&#8203;mx-psi](https://redirect.github.com/mx-psi) in
[#&#8203;1470](https://redirect.github.com/go-critic/go-critic/pull/1470)
- dev: enable goprintffuncname linter by
[@&#8203;alexandear](https://redirect.github.com/alexandear) in
[#&#8203;1478](https://redirect.github.com/go-critic/go-critic/pull/1478)
- checkers: add dupOption by
[@&#8203;alingse](https://redirect.github.com/alingse) in
[#&#8203;1471](https://redirect.github.com/go-critic/go-critic/pull/1471)
- all: rename gocritic to go-critic by
[@&#8203;cristaloleg](https://redirect.github.com/cristaloleg) in
[#&#8203;1482](https://redirect.github.com/go-critic/go-critic/pull/1482)
- deps: bump golang.org/x/tools from 0.31.0 to 0.32.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot)\[bot] in
[#&#8203;1484](https://redirect.github.com/go-critic/go-critic/pull/1484)
- checker/badCond: rhs should be also check for safe expr by
[@&#8203;codeimmortal](https://redirect.github.com/codeimmortal) in
[#&#8203;1486](https://redirect.github.com/go-critic/go-critic/pull/1486)
- deps: bump golang.org/x/tools from 0.32.0 to 0.33.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot)\[bot] in
[#&#8203;1489](https://redirect.github.com/go-critic/go-critic/pull/1489)
- checker: add `zeroByteRepeat` for avoiding `bytes.Repeat([]byte{0},
x)` by [@&#8203;codeimmortal](https://redirect.github.com/codeimmortal)
in
[#&#8203;1488](https://redirect.github.com/go-critic/go-critic/pull/1488)
- docs/readme: add Homebrew install instructions by
[@&#8203;krehel](https://redirect.github.com/krehel) in
[#&#8203;1491](https://redirect.github.com/go-critic/go-critic/pull/1491)
- deps: bump golang.org/x/tools from 0.33.0 to 0.34.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot)\[bot] in
[#&#8203;1492](https://redirect.github.com/go-critic/go-critic/pull/1492)
- deps: bump golang.org/x/tools from 0.34.0 to 0.35.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot)\[bot] in
[#&#8203;1498](https://redirect.github.com/go-critic/go-critic/pull/1498)
- ci: bump actions/checkout from 4 to 5 by
[@&#8203;dependabot](https://redirect.github.com/dependabot)\[bot] in
[#&#8203;1501](https://redirect.github.com/go-critic/go-critic/pull/1501)
- ci: bump actions/setup-go from 5 to 6 by
[@&#8203;dependabot](https://redirect.github.com/dependabot)\[bot] in
[#&#8203;1503](https://redirect.github.com/go-critic/go-critic/pull/1503)
- deps: bump golang.org/x/tools from 0.35.0 to 0.36.0 by
[@&#8203;dependabot](https://redirect.github.com/dependabot)\[bot] in
[#&#8203;1500](https://redirect.github.com/go-critic/go-critic/pull/1500)

#### New Contributors

- [@&#8203;mx-psi](https://redirect.github.com/mx-psi) made their first
contribution in
[#&#8203;1470](https://redirect.github.com/go-critic/go-critic/pull/1470)
- [@&#8203;codeimmortal](https://redirect.github.com/codeimmortal) made
their first contribution in
[#&#8203;1486](https://redirect.github.com/go-critic/go-critic/pull/1486)
- [@&#8203;krehel](https://redirect.github.com/krehel) made their first
contribution in
[#&#8203;1491](https://redirect.github.com/go-critic/go-critic/pull/1491)

**Full Changelog**:
<https://github.com/go-critic/go-critic/compare/v0.13.0...v0.14.0>

</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:eyJjcmVhdGVkSW5WZXIiOiI0MS4xNDMuMSIsInVwZGF0ZWRJblZlciI6IjQxLjE0My4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJTa2lwIENoYW5nZWxvZyIsImRlcGVuZGVuY2llcyJdfQ==-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: dmathieu <damien.mathieu@elastic.co>
2025-10-15 11:26:48 +02:00
Damien Mathieu
691638a817 Move sdk/internal/env to sdk/trace/internal/env (#7437)
The `sdk/internal/env` package is only used by tracing, and having that
internal package at the `sdk/` level means traces have a dependency on a
specific version of the SDK, causing issues such as
https://github.com/open-telemetry/opentelemetry-go/issues/6981

This moves the package to `sdk/trace/internal/env` to remove that
dependency.
2025-10-10 08:57:44 +02:00
renovate[bot]
0c97dfd6bd fix(deps): update golang.org/x (#7475)
This PR contains the following updates:

| Package | Change | Age | Confidence | Type | Update |
|---|---|---|---|---|---|
| golang.org/x/sys | `v0.36.0` -> `v0.37.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fsys/v0.37.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fsys/v0.36.0/v0.37.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| indirect | minor |
| golang.org/x/sys | `v0.36.0` -> `v0.37.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fsys/v0.37.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fsys/v0.36.0/v0.37.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| require | minor |
| golang.org/x/telemetry | `4eae98a` -> `badf71c` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2ftelemetry/v0.0.0-20251008142558-badf71c62812?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2ftelemetry/v0.0.0-20251001141935-4eae98a72453/v0.0.0-20251008142558-badf71c62812?slim=true)](https://docs.renovatebot.com/merge-confidence/)
| indirect | digest |

---

> [!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:eyJjcmVhdGVkSW5WZXIiOiI0MS4xMzEuOSIsInVwZGF0ZWRJblZlciI6IjQxLjEzMS45IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJTa2lwIENoYW5nZWxvZyIsImRlcGVuZGVuY2llcyJdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-10-08 07:55:16 -07:00
David Ashpole
5f5f4af5e5 Document the ordering guarantees provided by the metrics SDK (#7453)
Forked from this discussion here:
https://github.com/open-telemetry/opentelemetry-go/pull/7443#discussion_r2402481912

It seems like a good idea for us as a group to align on and document
what we are comfortable with in terms of how ordered measurements are
reflected in collected metric data.

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2025-10-07 11:21:58 -04:00
David Ashpole
c8e3897521 Use sync.Map and atomics to improve sum performance (#7427)
Alternative to
https://github.com/open-telemetry/opentelemetry-go/pull/7380

This uses a sync.Map and atomics for the sum's counter value. This
intentionally introduces a new race condition that didn't previously
exist:
* It is possible for the exemplar to be recorded in the batch of metrics
after the add() for cumulative sum aggregations. For cumulative, this
isn't a huge issue since exemplars are expected to persist across
collection cycles. This is difficult to fix because we can't manage the
internal storage of an exemplar.Reservoir (to atomically swap between
hot and cold storage). If we are able to make assumptions about how
exemplar reservoirs are managed (i.e. that the number of and order of
exemplars returned is always the same), then we could possibly fix this
by merging at export time.

### Alternatives Considered

#### RWLock for the map instead of sync.Map

This is significantly less performant.

#### Single sync.Map without hotColdWaitGroup

Deleting keys from the sync.Map concurrently with measurements (during
Clear() of the sync.Map) can cause measurements to be made to a counter
that has already been read, exported and deleted. This can produce
incorrect sums when delta is used. Instead, atomically switching writes
to a completely empty sync.Map and waiting for writes to the previous
sync.Map complete eliminates this issue.

#### Use two sync.Map for cumulative sums

One idea I explored was doing a hot-cold swap for cumulative sums just
like we do for delta sums. We would swap the hot and cold sync.Maps,
wait for writes to the cold sync.Map to complete while new writes go to
the hot map. Then, once we are done reading the cold map, we could merge
the contents of the cold map back into the new hot map.

This approach has two issues:

* It isn't possible to "merge" one exemplar reservoir into another. This
is an issue for persistent exemplars that aren't overwritten in a
collection interval.
* We can't keep a consistent set of keys in overflow scenarios.
Measurements that are made to the hot map before the merge of the cold
into hot that should have been overflows will be added as new attribute
sets. That, in turn, means we will need to change previously-exported
attribute sets to the overflow set, which will cause issues for users.

### Benchmarks

Parallel:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: AMD EPYC 7B12
                                                                                  │  main24.txt   │            new24_new.txt            │
                                                                                  │    sec/op     │    sec/op     vs base               │
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/0-24                   255.65n ± 13%   68.06n ±  3%  -73.38% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/1-24                   286.70n ±  8%   67.66n ±  4%  -76.40% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/10-24                  287.15n ± 14%   69.90n ±  3%  -75.66% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/0-24                 244.75n ±  9%   68.83n ±  4%  -71.88% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/1-24                 267.20n ± 14%   65.86n ±  3%  -75.35% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/10-24                291.50n ± 13%   66.59n ± 11%  -77.15% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/0-24             247.85n ±  7%   66.06n ±  3%  -73.34% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/1-24             286.75n ± 10%   68.52n ±  2%  -76.10% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/10-24            289.50n ± 20%   67.45n ±  4%  -76.70% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/0-24           246.25n ± 14%   66.69n ±  2%  -72.92% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/1-24           289.55n ±  9%   65.54n ±  5%  -77.36% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/10-24          286.05n ± 14%   67.55n ±  2%  -76.39% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/0-24                      254.8n ± 23%   225.9n ± 17%  -11.32% (p=0.026 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/1-24                      304.4n ± 13%   234.4n ± 19%  -23.01% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/10-24                     308.9n ± 20%   217.6n ± 10%  -29.56% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/0-24                    267.8n ± 14%   220.1n ± 19%  -17.80% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/1-24                    274.1n ± 21%   226.5n ±  5%  -17.38% (p=0.024 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/10-24                   239.0n ± 14%   236.1n ± 18%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/0-24                  223.7n ± 11%   234.8n ±  7%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/1-24                  253.9n ± 10%   244.8n ± 11%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/10-24                 272.6n ±  7%   250.0n ± 12%   -8.33% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/0-24                232.6n ±  4%   232.2n ±  8%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/1-24                276.7n ± 20%   249.2n ± 11%        ~ (p=0.485 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/10-24               265.9n ± 18%   246.4n ±  9%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/0-24       294.0n ± 11%   269.0n ±  5%   -8.47% (p=0.015 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/1-24       314.6n ± 10%   268.8n ±  6%  -14.54% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/10-24      303.9n ± 11%   285.4n ±  4%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/0-24     274.7n ± 13%   262.9n ±  7%        ~ (p=0.145 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/1-24     296.1n ±  6%   288.9n ±  9%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/10-24    276.0n ± 14%   299.4n ± 12%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/0-24                     191.4n ±  4%   176.0n ±  3%   -8.05% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/1-24                     223.2n ±  8%   172.8n ±  3%  -22.54% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/10-24                    265.7n ± 19%   172.2n ±  2%  -35.21% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/0-24                   179.4n ± 18%   171.0n ±  3%   -4.74% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/1-24                   209.1n ± 16%   175.4n ±  5%  -16.07% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/10-24                  222.5n ± 17%   175.6n ±  4%  -21.08% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/0-24               194.4n ± 11%   176.9n ±  5%   -9.03% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/1-24               207.5n ± 13%   175.1n ±  2%  -15.66% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/10-24              243.7n ± 13%   172.6n ±  3%  -29.15% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/0-24             218.3n ± 10%   177.6n ±  2%  -18.67% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/1-24             193.5n ± 10%   176.1n ±  2%   -8.99% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/10-24            192.8n ± 11%   173.7n ±  2%   -9.91% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/0-24                       185.1n ±  9%   204.8n ±  9%  +10.61% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/1-24                       218.8n ± 14%   229.7n ± 16%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/10-24                      242.7n ±  8%   209.1n ± 18%  -13.84% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/0-24                     182.8n ± 42%   255.2n ±  8%  +39.67% (p=0.015 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/1-24                     198.0n ±  7%   280.6n ± 22%  +41.72% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/10-24                    236.3n ± 18%   261.7n ±  8%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/0-24                   223.2n ±  9%   226.9n ±  4%        ~ (p=0.965 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/1-24                   270.1n ± 10%   280.2n ±  6%        ~ (p=0.143 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/10-24                  257.2n ±  7%   252.0n ±  7%        ~ (p=0.485 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/0-24                 277.0n ±  5%   310.4n ± 12%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/1-24                 287.3n ±  9%   271.2n ± 12%        ~ (p=0.699 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/10-24                281.8n ±  9%   316.5n ± 22%  +12.29% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/0-24        289.1n ±  9%   297.1n ± 12%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/1-24        277.8n ±  6%   353.1n ± 11%  +27.11% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/10-24       281.8n ± 11%   352.2n ± 16%  +24.94% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/0-24      294.1n ±  7%   317.5n ±  9%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/1-24      281.7n ± 10%   332.1n ±  8%  +17.89% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/10-24     238.9n ± 12%   318.1n ±  9%  +33.13% (p=0.002 n=6)
geomean                                                                              251.9n         184.4n        -26.77%
```


Single-threaded:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
                                                                               │  main1.txt   │              sync1.txt              │
                                                                               │    sec/op    │    sec/op     vs base               │
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/0                   109.8n ±  7%   113.4n ± 23%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/1                   115.0n ±  4%   113.3n ± 20%        ~ (p=0.729 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/10                  177.1n ± 34%   110.2n ± 16%  -37.78% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/0                 110.5n ± 42%   109.2n ± 19%        ~ (p=0.457 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/1                 118.8n ±  2%   118.4n ±  5%        ~ (p=0.619 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/10                119.0n ±  2%   116.8n ± 42%        ~ (p=0.699 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/0             106.9n ±  1%   102.5n ±  5%   -4.16% (p=0.030 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/1             117.2n ±  2%   116.9n ±  7%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/10            115.4n ±  1%   115.1n ±  5%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/0           109.5n ±  5%   104.2n ±  8%   -4.84% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/1           118.7n ± 14%   113.8n ± 35%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/10          116.6n ±  1%   116.8n ±  8%        ~ (p=0.968 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/0                     106.6n ±  4%   109.4n ±  5%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/1                     114.7n ±  4%   117.9n ±  4%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/10                    115.2n ±  4%   114.5n ±  1%        ~ (p=0.162 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/0                   109.4n ±  5%   107.5n ±  3%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/1                   118.3n ±  2%   117.9n ±  3%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/10                  117.7n ±  2%   120.8n ± 14%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/0                 96.78n ±  1%   99.37n ±  3%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/1                 103.0n ±  3%   116.5n ± 26%  +13.16% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/10                102.8n ±  1%   107.6n ± 22%   +4.67% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/0               93.95n ± 22%   99.88n ± 18%   +6.32% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/1               102.7n ±  5%   106.2n ±  6%        ~ (p=0.089 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/10              104.1n ±  4%   108.3n ± 27%   +4.03% (p=0.026 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/0      146.3n ±  1%   154.0n ± 24%   +5.23% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/1      154.8n ±  3%   161.2n ±  2%   +4.20% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/10     155.5n ±  1%   164.0n ±  4%   +5.43% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/0    145.9n ±  2%   159.7n ± 12%   +9.42% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/1    155.2n ±  0%   164.0n ±  6%   +5.70% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/10   219.3n ± 29%   159.5n ±  3%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/0                    263.6n ± 36%   177.2n ±  1%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/1                    189.1n ±  8%   190.4n ± 12%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/10                   184.3n ±  3%   189.4n ±  6%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/0                  180.7n ±  1%   182.7n ±  2%        ~ (p=0.457 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/1                  192.8n ±  9%   192.0n ±  1%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/10                 192.3n ±  4%   190.2n ±  4%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/0              176.5n ±  2%   181.7n ±  4%   +2.95% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/1              184.0n ±  4%   192.0n ±  1%   +4.32% (p=0.015 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/10             184.4n ±  1%   195.2n ±  3%   +5.83% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/0            183.0n ±  3%   177.4n ±  5%   -3.06% (p=0.048 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/1            194.4n ±  4%   188.1n ±  5%        ~ (p=0.084 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/10           193.0n ±  5%   194.1n ±  5%        ~ (p=0.699 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/0                      178.4n ± 14%   185.6n ± 29%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/1                      189.0n ±  8%   193.2n ±  2%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/10                     197.7n ±  5%   198.8n ±  2%        ~ (p=0.619 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/0                    185.5n ±  3%   188.8n ±  4%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/1                    191.2n ±  3%   190.2n ±  7%        ~ (p=0.732 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/10                   186.8n ±  2%   197.1n ±  6%   +5.54% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/0                  224.2n ±  4%   227.3n ±  2%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/1                  232.5n ±  3%   242.5n ±  5%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/10                 232.5n ±  3%   237.1n ±  5%   +2.00% (p=0.045 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/0                227.5n ±  2%   238.5n ±  5%   +4.81% (p=0.017 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/1                239.4n ±  8%   250.1n ±  6%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/10               241.5n ±  4%   254.0n ±  2%   +5.18% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/0       231.1n ±  5%   239.2n ±  3%        ~ (p=0.084 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/1       260.2n ± 16%   253.8n ±  4%        ~ (p=0.190 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/10      234.3n ±  1%   246.8n ±  2%   +5.29% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/0     221.8n ±  6%   232.0n ±  4%   +4.58% (p=0.037 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/1     228.2n ±  7%   240.6n ±  1%   +5.41% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/10    228.6n ±  7%   244.7n ±  1%   +7.04% (p=0.015 n=6)
geomean                                                                          158.1n         158.1n         +0.00%
```

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2025-10-07 09:40:23 -04:00
Mahendra Bishnoi
a10652b501 sdk/trace: trace id high 64 bit tests (#7212)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7160

- Modified `testIDGenerator` to have both low and high bits (in uint64
form) since we can't store 128 bits integer
- start with high seed values (taken from
https://github.com/open-telemetry/opentelemetry-go/pull/7155)
- validate both high and low 64 bits of trace id

Does not need a CHANGELOG entry - test only.

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: dmathieu <damien.mathieu@elastic.co>
2025-10-06 11:13:51 +02:00
David Ashpole
bd1b3da91c Add exemplar reservoir parallel benchmarks (#7441)
This also fixes a bug introduced in
https://github.com/open-telemetry/opentelemetry-go/pull/7423, where we
were only locking around storage and not around other shared fields
(e.g. count). Fixing the bug is required for benchmarks to run properly,
but wasn't caught by concurrent safe tests because the SDK does not
currently call exemplar methods concurrently.

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric/exemplar
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkFixedSizeReservoirOffer-24    	  498955	       248.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkHistogramReservoirOffer-24    	  478068	       250.1 ns/op	       0 B/op	       0 allocs/op
```
2025-10-03 09:11:00 +02:00
Dave Protasowski
dee11e6ae3 Add temporality selector functions (#7434)
From: https://github.com/open-telemetry/opentelemetry-go/pull/7346

This PR exposes the default TemporalitySelector funcs that are used by
the OTel env var processing.

The reason to expose these funcs is because there is some discrepancy in
various vendor documentation on how to enable these settings using go
option args WithTemporalitySelector

https://cloud-native.slack.com/archives/C01NPAXACKT/p1757443233624599

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: David Ashpole <dashpole@google.com>
2025-10-02 16:13:59 +02:00
David Ashpole
ea38204f20 Allow optimizing locking for built-in exemplar reservoirs (#7423)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7388

Benchmarks seem like mostly noise. It isn't actually necessary to lock
in the exemplar reservoir today because of our SDK design, but this
allows us to make optimizations in the future. After
https://github.com/open-telemetry/opentelemetry-go/pull/7427,
improvements to exemplar reservoir locking will greatly improve the
ExemplarEnabled benchmarks.

Parallel benchmarks:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
                                                                                  │  main24.txt  │           exemplar24.txt            │
                                                                                  │    sec/op    │    sec/op     vs base               │
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/0-24                   399.5n ± 16%   367.8n ± 17%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/1-24                   369.4n ± 27%   410.2n ± 11%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/10-24                  372.6n ± 23%   398.9n ±  8%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/0-24                 313.4n ± 12%   357.7n ± 20%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/1-24                 389.9n ± 12%   379.5n ±  9%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/10-24                441.4n ± 13%   359.1n ± 18%  -18.64% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/0-24             415.8n ± 22%   400.3n ± 16%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/1-24             346.9n ±  8%   364.6n ± 19%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/10-24            358.9n ± 14%   407.1n ± 17%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/0-24           381.9n ± 27%   375.2n ± 10%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/1-24           361.9n ± 19%   389.6n ± 23%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/10-24          356.0n ±  8%   416.1n ± 14%  +16.90% (p=0.015 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/0-24                     313.9n ± 11%   385.7n ± 19%  +22.88% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/1-24                     368.8n ± 18%   387.6n ± 17%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/10-24                    346.1n ± 40%   460.3n ± 16%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/0-24                   325.9n ± 10%   357.8n ± 19%   +9.77% (p=0.026 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/1-24                   372.1n ± 18%   395.2n ± 14%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/10-24                  353.5n ± 23%   416.0n ± 15%  +17.66% (p=0.024 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/0-24                 351.8n ± 15%   362.7n ±  7%        ~ (p=0.699 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/1-24                 378.8n ± 17%   413.4n ± 13%        ~ (p=0.288 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/10-24                361.5n ± 13%   418.2n ± 14%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/0-24               305.0n ± 21%   361.9n ± 13%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/1-24               411.1n ± 12%   403.9n ±  9%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/10-24              353.4n ± 39%   380.9n ± 17%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/0-24      457.5n ± 33%   454.2n ± 13%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/1-24      436.6n ± 23%   459.0n ± 10%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/10-24     383.3n ± 22%   461.9n ± 12%  +20.51% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/0-24    371.9n ± 14%   421.4n ± 19%  +13.33% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/1-24    433.7n ± 20%   490.8n ± 10%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/10-24   433.2n ± 18%   511.4n ±  9%  +18.05% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/0-24                    477.5n ± 14%   384.6n ±  7%  -19.47% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/1-24                    481.1n ± 17%   430.0n ± 18%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/10-24                   425.1n ± 27%   436.3n ± 12%        ~ (p=0.699 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/0-24                  394.5n ±  8%   415.5n ± 15%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/1-24                  434.4n ± 13%   440.8n ± 15%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/10-24                 481.3n ± 19%   404.1n ± 14%  -16.05% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/0-24              364.9n ± 29%   424.3n ±  8%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/1-24              401.2n ± 24%   482.2n ± 12%  +20.20% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/10-24             438.6n ± 19%   404.8n ± 18%        ~ (p=0.485 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/0-24            392.7n ± 17%   427.7n ± 25%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/1-24            392.6n ±  5%   388.5n ±  7%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/10-24           401.3n ± 19%   409.7n ±  8%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/0-24                      369.8n ± 15%   374.2n ± 17%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/1-24                      359.4n ± 13%   387.1n ± 16%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/10-24                     393.2n ± 18%   450.0n ± 10%  +14.43% (p=0.015 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/0-24                    399.8n ± 23%   361.2n ± 11%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/1-24                    439.4n ± 25%   412.0n ± 10%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/10-24                   401.7n ± 17%   380.0n ± 11%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/0-24                  508.8n ± 18%   532.6n ± 16%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/1-24                  505.9n ± 22%   494.8n ± 14%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/10-24                 597.8n ± 10%   490.5n ± 23%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/0-24                566.2n ± 21%   482.9n ± 10%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/1-24                440.2n ±  9%   549.3n ±  8%  +24.77% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/10-24               436.3n ± 16%   530.8n ± 19%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/0-24       395.8n ± 25%   441.6n ±  9%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/1-24       440.2n ±  9%   455.2n ±  7%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/10-24      415.7n ± 12%   527.5n ±  9%  +26.91% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/0-24     376.1n ± 19%   461.9n ± 13%  +22.81% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/1-24     383.6n ± 10%   422.7n ± 26%  +10.21% (p=0.015 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/10-24    398.5n ±  9%   538.5n ±  7%  +35.13% (p=0.002 n=6)
geomean                                                                             399.4n         422.3n         +5.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   │            exemplar1.txt            │
                                                                               │    sec/op    │    sec/op     vs base               │
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/0                   180.1n ± 21%   156.2n ± 10%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/1                   168.4n ±  9%   179.2n ± 11%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/10                  164.0n ± 10%   199.0n ± 20%  +21.30% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/0                 153.9n ±  6%   170.1n ±  2%  +10.53% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/1                 178.0n ±  5%   178.5n ±  6%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/10                175.8n ±  7%   165.3n ± 18%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/0             152.0n ±  8%   163.1n ± 26%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/1             168.1n ±  8%   168.0n ± 14%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/10            167.4n ±  4%   164.3n ± 12%        ~ (p=0.699 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/0           151.7n ± 17%   156.0n ± 28%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/1           173.6n ±  5%   169.3n ±  5%   -2.45% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/10          169.3n ±  4%   165.7n ±  7%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/0                     155.5n ± 15%   153.8n ± 11%        ~ (p=0.558 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/1                     166.7n ±  3%   173.5n ±  7%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/10                    174.4n ± 17%   167.6n ± 13%        ~ (p=0.699 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/0                   180.1n ± 32%   154.8n ±  5%  -14.02% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/1                   204.6n ± 23%   173.8n ± 19%        ~ (p=0.069 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/10                  226.6n ± 28%   174.5n ± 10%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/0                 132.7n ± 13%   140.7n ± 14%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/1                 143.4n ±  9%   162.6n ±  9%  +13.42% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/10                154.7n ±  7%   172.3n ±  6%  +11.38% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/0               136.8n ± 10%   145.5n ± 14%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/1               148.4n ± 11%   159.7n ±  8%        ~ (p=0.167 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/10              193.0n ± 25%   165.5n ±  9%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/0      249.8n ± 47%   229.5n ±  7%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/1      262.1n ± 20%   245.1n ± 12%        ~ (p=0.699 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/10     285.4n ± 20%   249.9n ± 17%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/0    272.9n ± 20%   216.3n ±  6%  -20.75% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/1    311.8n ± 29%   234.4n ±  6%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/10   228.2n ±  6%   234.2n ±  4%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/0                    289.2n ± 39%   263.3n ± 10%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/1                    271.9n ± 18%   280.6n ±  8%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/10                   272.1n ±  6%   303.7n ± 14%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/0                  280.1n ±  8%   268.8n ±  5%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/1                  291.6n ± 81%   268.8n ±  7%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/10                 276.3n ± 13%   278.1n ±  6%        ~ (p=0.784 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/0              254.7n ±  7%   282.4n ±  5%  +10.85% (p=0.026 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/1              277.5n ± 11%   285.2n ± 16%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/10             267.0n ± 10%   275.9n ±  5%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/0            256.9n ±  3%   286.4n ±  8%  +11.46% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/1            267.9n ± 16%   278.0n ± 12%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/10           272.5n ±  4%   267.4n ±  6%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/0                      272.5n ± 22%   266.2n ± 14%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/1                      355.2n ± 11%   275.2n ±  7%  -22.52% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/10                     281.3n ±  7%   268.9n ±  4%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/0                    257.0n ±  9%   308.9n ±  7%  +20.20% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/1                    265.9n ±  9%   319.6n ±  7%  +20.18% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/10                   279.9n ±  3%   332.9n ±  7%  +18.92% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/0                  313.9n ± 11%   345.1n ± 10%   +9.91% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/1                  332.1n ±  7%   359.9n ±  9%   +8.37% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/10                 366.4n ± 55%   380.1n ±  4%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/0                336.8n ± 12%   346.3n ±  7%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/1                361.9n ± 18%   375.0n ±  8%   +3.62% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/10               351.8n ±  6%   392.1n ±  4%  +11.46% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/0       358.8n ±  9%   344.3n ±  5%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/1       352.0n ±  7%   331.5n ±  5%   -5.84% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/10      373.5n ± 10%   353.7n ±  9%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/0     328.5n ±  9%   345.4n ±  5%   +5.14% (p=0.015 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/1     349.1n ± 28%   337.8n ±  9%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/10    347.5n ± 10%   344.2n ± 10%        ~ (p=1.000 n=6)
geomean                                                                          235.3n         234.4n         -0.38%
```
2025-10-01 12:32:00 -04:00
David Ashpole
45539cf5a3 Only enforce cardinality limits when the attribute set does not already exist (#7422)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7035

Benchmarks with a default value of 2000.

Parallel 
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
                                                                                  │  main24.txt  │         newwithlimit24.txt          │
                                                                                  │    sec/op    │    sec/op     vs base               │
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/0-24                   272.4n ±  6%   287.6n ± 11%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/1-24                   318.1n ±  9%   289.9n ± 11%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/10-24                  305.5n ± 13%   273.4n ±  9%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/0-24                 263.4n ± 14%   273.1n ± 12%        ~ (p=0.485 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/1-24                 276.8n ±  8%   284.3n ± 10%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/10-24                266.2n ± 10%   285.9n ± 16%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/0-24             265.9n ± 11%   286.4n ± 14%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/1-24             301.6n ± 16%   286.1n ±  6%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/10-24            256.1n ± 16%   282.7n ± 14%  +10.41% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/0-24           269.1n ± 19%   272.0n ±  6%        ~ (p=0.485 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/1-24           299.5n ± 12%   261.6n ± 16%  -12.67% (p=0.013 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/10-24          286.3n ± 16%   275.8n ± 10%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/0-24                     265.4n ±  4%   243.1n ± 11%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/1-24                     260.6n ± 10%   258.7n ± 17%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/10-24                    266.6n ± 15%   251.8n ± 16%        ~ (p=0.699 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/0-24                   265.4n ±  9%   263.3n ± 13%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/1-24                   271.7n ± 15%   305.4n ± 21%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/10-24                  287.4n ± 13%   265.7n ±  9%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/0-24                 276.6n ±  9%   300.4n ± 25%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/1-24                 294.9n ± 11%   276.8n ± 21%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/10-24                308.3n ±  8%   281.4n ± 20%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/0-24               296.1n ± 13%   286.5n ± 14%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/1-24               329.0n ± 19%   299.6n ±  8%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/10-24              288.1n ± 28%   309.9n ± 14%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/0-24      298.3n ± 12%   282.9n ±  9%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/1-24      309.7n ±  4%   355.2n ± 11%  +14.67% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/10-24     308.5n ± 12%   307.6n ± 15%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/0-24    294.1n ± 17%   289.1n ± 24%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/1-24    326.6n ± 13%   299.2n ± 14%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/10-24   329.8n ± 19%   283.7n ± 15%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/0-24                    269.9n ± 15%   266.7n ±  6%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/1-24                    297.4n ±  9%   271.9n ±  5%   -8.59% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/10-24                   326.4n ± 20%   276.3n ±  5%  -15.32% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/0-24                  298.1n ± 10%   259.6n ± 10%  -12.92% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/1-24                  311.4n ±  6%   276.8n ±  7%  -11.11% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/10-24                 312.4n ±  7%   264.1n ±  8%  -15.45% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/0-24              286.2n ±  8%   272.9n ± 13%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/1-24              310.1n ±  4%   289.2n ± 11%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/10-24             329.8n ±  8%   277.1n ± 11%  -15.95% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/0-24            261.4n ± 17%   262.8n ±  7%        ~ (p=0.965 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/1-24            292.3n ± 10%   271.2n ±  8%   -7.22% (p=0.026 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/10-24           306.6n ± 12%   271.9n ±  7%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/0-24                      263.2n ± 22%   254.7n ±  6%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/1-24                      284.8n ±  5%   285.0n ± 11%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/10-24                     285.7n ± 17%   296.6n ± 10%        ~ (p=0.485 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/0-24                    272.3n ± 11%   261.4n ±  8%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/1-24                    281.9n ± 21%   287.8n ± 11%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/10-24                   283.3n ± 15%   254.3n ± 12%  -10.24% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/0-24                  296.1n ± 13%   295.5n ±  9%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/1-24                  310.0n ± 19%   301.7n ± 11%        ~ (p=0.485 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/10-24                 298.8n ± 17%   297.1n ±  3%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/0-24                303.4n ±  7%   280.9n ±  8%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/1-24                292.2n ± 14%   290.7n ± 13%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/10-24               313.9n ± 20%   314.4n ±  8%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/0-24       289.8n ±  3%   287.3n ±  3%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/1-24       321.0n ±  6%   308.7n ±  8%   -3.82% (p=0.041 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/10-24      313.1n ±  9%   315.4n ±  5%        ~ (p=0.818 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/0-24     318.9n ± 13%   285.8n ± 24%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/1-24     319.0n ±  9%   317.0n ± 12%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/10-24    396.8n ± 15%   300.3n ±  5%  -24.30% (p=0.002 n=6)
geomean                                                                             294.1n         282.9n         -3.80%
```

Single-threaded:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
                                                                               │  main1.txt   │          newwithlimit1.txt          │
                                                                               │    sec/op    │    sec/op     vs base               │
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/0                   117.5n ±  5%   109.8n ± 20%        ~ (p=0.089 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/1                   128.5n ± 35%   118.5n ±  3%   -7.79% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/10                  126.4n ±  4%   117.3n ±  4%   -7.16% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/0                 110.4n ±  1%   112.2n ±  3%   +1.59% (p=0.028 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/1                 119.8n ±  2%   118.4n ±  4%        ~ (p=0.171 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/10                120.1n ±  2%   121.9n ±  3%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/0             117.3n ± 38%   109.5n ±  2%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/1             120.8n ± 28%   119.9n ±  8%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/10            121.1n ±  3%   117.0n ±  2%   -3.38% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/0           111.8n ± 11%   111.0n ±  2%        ~ (p=0.331 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/1           121.7n ±  9%   117.5n ±  1%   -3.49% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/10          126.5n ±  4%   122.3n ±  8%        ~ (p=0.290 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/0                     125.5n ± 25%   109.2n ±  3%  -12.98% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/1                     121.7n ±  6%   116.5n ±  6%   -4.31% (p=0.022 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Gauge/Attributes/10                    119.9n ±  4%   120.8n ±  4%        ~ (p=0.838 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/0                   112.5n ±  6%   109.7n ± 40%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/1                   121.2n ±  6%   121.4n ±  3%        ~ (p=0.727 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Gauge/Attributes/10                  118.6n ±  2%   120.5n ±  2%   +1.69% (p=0.045 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/0                 97.38n ± 14%   96.56n ± 10%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/1                 107.1n ±  4%   105.6n ±  5%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/10                109.7n ±  5%   108.4n ±  3%        ~ (p=0.221 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/0               98.30n ±  4%   96.02n ±  2%   -2.31% (p=0.015 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/1               107.9n ±  9%   106.2n ± 14%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/10              107.6n ±  1%   107.0n ±  1%        ~ (p=0.485 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/0      151.5n ±  3%   149.7n ±  2%        ~ (p=0.071 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/1      161.2n ±  2%   158.5n ±  3%   -1.67% (p=0.035 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/10     162.3n ±  2%   159.9n ± 37%        ~ (p=0.240 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/0    154.7n ± 10%   149.0n ±  1%   -3.68% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/1    161.0n ±  2%   160.5n ±  3%        ~ (p=0.732 n=6)
SyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/10   162.9n ±  1%   162.6n ± 27%        ~ (p=0.838 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/0                    180.1n ±  4%   174.0n ±  7%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/1                    193.2n ± 12%   198.7n ± 10%        ~ (p=1.000 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/10                   191.4n ± 43%   183.8n ±  3%   -4.02% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/0                  182.7n ±  5%   179.8n ±  4%        ~ (p=0.132 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/1                  199.4n ±  3%   185.1n ±  2%   -7.17% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/10                 198.5n ±  6%   193.0n ±  5%        ~ (p=0.589 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/0              184.7n ± 19%   173.5n ±  5%        ~ (p=0.058 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/1              183.2n ±  7%   180.7n ±  2%   -1.39% (p=0.037 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/10             185.3n ± 21%   183.6n ±  3%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/0            187.4n ±  7%   183.8n ±  6%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/1            194.6n ±  4%   189.2n ±  2%   -2.75% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/10           199.9n ±  5%   189.4n ±  3%   -5.23% (p=0.026 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/0                      179.2n ±  5%   187.7n ±  4%        ~ (p=0.065 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/1                      188.6n ±  2%   192.1n ±  4%        ~ (p=0.221 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Gauge/Attributes/10                     186.2n ±  1%   189.9n ±  3%   +2.04% (p=0.009 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/0                    179.4n ±  4%   183.6n ±  8%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/1                    188.0n ±  2%   190.6n ±  2%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Gauge/Attributes/10                   197.1n ±  6%   188.3n ±  6%        ~ (p=0.180 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/0                  222.6n ± 10%   227.8n ±  5%        ~ (p=0.310 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/1                  224.2n ±  7%   230.8n ±  6%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/10                 240.6n ± 10%   233.6n ±  6%        ~ (p=0.394 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/0                216.9n ±  4%   222.0n ±  5%        ~ (p=0.937 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/1                223.3n ±  3%   221.4n ±  4%        ~ (p=0.372 n=6)
SyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/10               240.8n ±  5%   224.5n ± 19%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/0       224.5n ±  2%   218.2n ±  2%   -2.83% (p=0.030 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/1       230.9n ±  2%   228.8n ±  1%   -0.95% (p=0.026 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/10      231.5n ±  4%   242.1n ±  5%        ~ (p=0.093 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/0     237.1n ±  3%   221.8n ±  6%   -6.47% (p=0.004 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/1     245.3n ±  0%   234.4n ±  4%   -4.46% (p=0.002 n=6)
SyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/10    249.3n ± 11%   240.9n ± 17%        ~ (p=0.589 n=6)
geomean                                                                          159.1n         156.0n         -1.97%
```

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2025-09-29 11:33:27 -04:00
ternua8
0db5ac7e0f sdk/trace/internal/x: generate x package from x component template #7385 (#7411)
Fix #7385

### Summary

This PR adds code generation for the `sdk/trace/internal/x` package
using the shared x component template.

It mirrors the implementation in `sdk/log/internal/x` (#7389) for the
trace SDK.

### Changes

- Added `gen.go` to run `go:generate` for `x.go` and `x_test.go`.
- Generated `x/x.go` and `x/x_test.go` using the shared template.
- Added `feature.go` with the `Observability` experimental feature flag
for the trace SDK,
  following the pattern used in the log SDK.

### Verification

- `go generate ./...` successfully generates the files.
- Unit tests in `x_test.go` pass.

### References

- Log implementation for reference: #7389
- Trace issue: #7385

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2025-09-27 08:01:11 -07:00
David Ashpole
22cfbcec0c Add concurrent safe tests for metric aggregations (#7379)
Prerequisite for
https://github.com/open-telemetry/opentelemetry-go/pull/7189.

Add tests to try to catch race conditions for concurrent measurements.
2025-09-25 21:05:09 -04:00
David Ashpole
97a78c1525 Add measure benchmarks with exemplars recorded (#7406)
Part of https://github.com/open-telemetry/opentelemetry-go/issues/7388

This adds benchmarks for making measurements that also record an
exemplar. This will help demonstrate any improvements to locking in the
exemplar reservoir.

Parallel benchmarks:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/0-24         	   57819	       258.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/1-24         	   46058	       255.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/10-24        	   70351	       271.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/0-24       	   67525	       220.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/1-24       	   67789	       248.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/10-24      	   63385	       246.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/0-24   	   67786	       213.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/1-24   	   73093	       226.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/10-24  	   55597	       230.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/0-24 	   77805	       216.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/1-24 	   71512	       234.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/10-24         	   60094	       258.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/0-24                	   66192	       266.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/1-24                	   50511	       242.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/10-24               	   42548	       295.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/0-24              	   48874	       229.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/1-24              	   50904	       271.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/10-24             	   59074	       253.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/0-24     	   55216	       292.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/1-24     	   53492	       375.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/10-24    	   40346	       273.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/0-24   	   51520	       310.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/1-24   	   43227	       303.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/10-24  	   44754	       295.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/0-24                   	   44091	       294.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/1-24                   	   43164	       300.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/10-24                  	   46014	       269.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/0-24                 	   38978	       281.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/1-24                 	   41292	       316.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/10-24                	   38986	       303.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/0-24             	   33555	       299.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/1-24             	   44396	       322.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/10-24            	   38211	       273.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/0-24           	   45652	       296.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/1-24           	   38984	       270.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/10-24          	   36280	       313.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/0-24                 	   34377	       437.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/1-24                 	   34992	       344.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/10-24                	   33795	       384.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/0-24               	   38080	       353.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/1-24               	   36568	       315.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/10-24              	   32418	       309.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/0-24      	   33217	       320.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/1-24      	   27937	       407.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/10-24     	   30818	       350.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/0-24    	   36286	       346.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/1-24    	   35863	       342.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/10-24   	   32378	       327.8 ns/op	       0 B/op	       0 allocs/op
```

Single-threaded benchmarks:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/0         	  115218	       109.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/1         	  106142	       112.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Counter/Attributes/10        	  101562	       115.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/0       	   93019	       112.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/1       	  107089	       117.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Counter/Attributes/10      	  106411	       117.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/0   	  110683	       113.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/1   	   84825	       122.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64UpDownCounter/Attributes/10  	   98952	       113.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/0 	  115419	       105.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/1 	   97251	       114.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64UpDownCounter/Attributes/10         	  106036	       111.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/0                	  130296	        92.98 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/1                	  120679	       100.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Int64Histogram/Attributes/10               	  116985	       102.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/0              	  125479	        96.42 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/1              	  115527	       103.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/Float64Histogram/Attributes/10             	   89858	       117.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/0     	   76768	       152.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/1     	   72832	       161.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialInt64Histogram/Attributes/10    	   73298	       160.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/0   	   81826	       154.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/1   	   73779	       158.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsDisabled/ExponentialFloat64Histogram/Attributes/10  	   75606	       161.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/0                   	   61503	       188.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/1                   	   63260	       185.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Counter/Attributes/10                  	   62704	       189.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/0                 	   63615	       180.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/1                 	   62072	       190.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Counter/Attributes/10                	   61260	       192.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/0             	   61561	       182.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/1             	   60334	       192.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64UpDownCounter/Attributes/10            	   64114	       192.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/0           	   63980	       181.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/1           	   61138	       189.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64UpDownCounter/Attributes/10          	   62150	       196.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/0                 	   51895	       237.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/1                 	   52554	       230.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Int64Histogram/Attributes/10                	   53581	       228.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/0               	   55407	       221.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/1               	   50701	       226.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/Float64Histogram/Attributes/10              	   50460	       231.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/0      	   53390	       221.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/1      	   51373	       229.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialInt64Histogram/Attributes/10     	   51154	       228.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/0    	   52167	       230.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/1    	   48598	       247.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExemplarsEnabled/ExponentialFloat64Histogram/Attributes/10   	   51086	       230.8 ns/op	       0 B/op	       0 allocs/op
```
2025-09-25 09:55:45 -04:00
David Ashpole
2e0b5b4235 Add benchmark for synchronous gauge measurement (#7407)
These were missing from our benchmarks for synchronous instruments.

Single-threaded:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkSyncMeasure/NoView/Float64Gauge/Attributes/0         	  114369	       106.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Float64Gauge/Attributes/1         	  106424	       119.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Float64Gauge/Attributes/10        	   79513	       128.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Int64Gauge/Attributes/0         	  110667	       166.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Int64Gauge/Attributes/1         	  103809	       150.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Int64Gauge/Attributes/10        	   76430	       144.2 ns/op	       0 B/op	       0 allocs/op
```

Parallel:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkSyncMeasure/NoView/Float64Gauge/Attributes/0-24         	   40507	       283.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Float64Gauge/Attributes/1-24         	   43918	       305.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Float64Gauge/Attributes/10-24        	   41348	       291.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Int64Gauge/Attributes/0-24         	   48070	       291.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Int64Gauge/Attributes/1-24         	   43290	       274.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/Int64Gauge/Attributes/10-24        	   40003	       325.0 ns/op	       0 B/op	       0 allocs/op
```
2025-09-25 09:30:27 -04:00
Tyler Yahn
97e2244e5b [chore]: Clean-up unused obsScopeName const (#7408) 2025-09-24 13:33:39 -07:00
Robert Pająk
0cc2eb946f sdk/log: BenchmarkAddAttributes, BenchmarkSetAttributes, BenchmarkSetBody (#7387)
Towards https://github.com/open-telemetry/opentelemetry-go/issues/7364

This will help making sure that the fix for
https://github.com/open-telemetry/opentelemetry-go/issues/7364 is not
adding unnecessary overhead when limits do not cause dropping and
deduplication is not happening.

```
$ go test -bench="AddAttributes|SetAttributes|SetBody" -run=^$ -benchtime=100ms
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/log
cpu: 13th Gen Intel(R) Core(TM) i7-13800H
BenchmarkAddAttributes/Single/NoLimits-20         	 2025201	        59.20 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddAttributes/Single/AllowDuplicates-20  	 4987790	        24.05 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddAttributes/Unique/NoLimits-20         	  672564	       183.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddAttributes/Unique/AllowDuplicates-20  	 1736347	        68.13 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddAttributes/Deduplication/Enabled-20   	  865591	       135.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddAttributes/NestedDeduplication/Enabled-20         	  275410	       431.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddAttributes/NestedDeduplication/Disabled-20        	  713812	       162.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddAttributes/Deduplication/Disabled-20              	 1775750	        67.73 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddAttributes/CountLimit/Hit-20                      	  210417	       552.0 ns/op	     208 B/op	       1 allocs/op
BenchmarkAddAttributes/CountLimit/NotHit-20                   	  141958	       892.2 ns/op	     640 B/op	       1 allocs/op
BenchmarkAddAttributes/ValueLimit/Hit-20                      	  885476	       133.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkAddAttributes/ValueLimit/NotHit-20                   	  924368	       115.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/Single/NoLimits-20                     	 2024268	        59.23 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/Single/AllowDuplicates-20              	 4996321	        24.14 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/Unique/NoLimits-20                     	  609895	       186.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/Unique/AllowDuplicates-20              	 1393672	        86.26 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/Deduplication/Enabled-20               	  803832	       147.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/Deduplication/Disabled-20              	 1607533	        73.55 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/NestedDeduplication/Enabled-20         	  225752	       444.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/NestedDeduplication/Disabled-20        	  696045	       175.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/CountLimit/Hit-20                      	  202834	       632.3 ns/op	     208 B/op	       1 allocs/op
BenchmarkSetAttributes/CountLimit/NotHit-20                   	  149197	       793.4 ns/op	     640 B/op	       1 allocs/op
BenchmarkSetAttributes/ValueLimit/Hit-20                      	  894547	       134.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/ValueLimit/NotHit-20                   	 1000000	       117.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetAttributes/Overwrite/Existing-20                  	  648174	       173.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/Simple/NoLimits-20                           	 9593739	        14.12 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/Simple/WithLimits-20                         	 9397982	        13.85 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/UniqueMap/NoLimits-20                        	  525252	       207.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/UniqueMap/AllowDuplicates-20                 	10077223	        13.16 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/Deduplication/Enabled-20                     	 1063749	       108.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/Deduplication/Disabled-20                    	 9973114	        13.01 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/NestedDeduplication/Enabled-20               	  581662	       198.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/NestedDeduplication/Disabled-20              	10068196	        13.15 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/ValueLimit/Hit-20                            	 1292136	        92.08 ns/op	       0 B/op	       0 allocs/op
BenchmarkSetBody/ValueLimit/NoHit-20                          	 1414297	        92.29 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	go.opentelemetry.io/otel/sdk/log	12.145s
```
2025-09-23 14:42:58 +02:00
Flc゛
80cb909774 refactor: replace context.Background() with t.Context()/b.Context() in tests (#7352)
Based on the Go version we currently use, the dependency already
supports 1.24+, which allows using `t.Context()` and `b.Context()` in
unit tests and benchmarks respectively.

- Enable `context-background` and `context-todo` in
[`usetesting`](https://golangci-lint.run/docs/linters/configuration/#usetesting)
- Adjust the code to support linter detection

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-09-23 09:52:45 +02:00
nikhilmantri0902
56498ab815 chore: sdk/log/internal/x - generate x package from x component template (#7389)
Closes #7382 

Idea from https://github.com/open-telemetry/opentelemetry-go/pull/7361

Ref: https://github.com/open-telemetry/opentelemetry-go/pull/7361
Components that need to be processed:
[sdk/log/internal/x](7fdebbe3ed/sdk/log/internal/x)

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-09-22 09:28:10 +02:00
Robert Pająk
a189c6bbf9 sdk/log: add TestRecordMethodsInputConcurrentSafe (#7378) 2025-09-19 13:11:34 +02:00
Tyler Yahn
5b808c6ad5 Encapsulate SDK Tracer observability (#7331)
Split from #7316 

[Follow
guidelines](a5dcd68ebb/CONTRIBUTING.md (encapsulation))
and move instrumentation into its own type.

### Benchmarks

#### Added `sdk/trace/internal/observ` benchmarks

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace/internal/observ
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                     │ enc-trace-sdk-tracer-obs.out │
                     │            sec/op            │
Tracer/SpanStarted-8                    7.436n ± 6%
Tracer/SpanLive-8                       9.987n ± 8%
Tracer/SpanEnded-8                      11.32n ± 7%
NewTracer-8                             87.64n ± 6%
geomean                                 16.48n

                     │ enc-trace-sdk-tracer-obs.out │
                     │             B/op             │
Tracer/SpanStarted-8                   0.000 ± 0%
Tracer/SpanLive-8                      0.000 ± 0%
Tracer/SpanEnded-8                     0.000 ± 0%
NewTracer-8                            0.000 ± 0%
geomean                                           ¹
¹ summaries must be >0 to compute geomean

                     │ enc-trace-sdk-tracer-obs.out │
                     │          allocs/op           │
Tracer/SpanStarted-8                   0.000 ± 0%
Tracer/SpanLive-8                      0.000 ± 0%
Tracer/SpanEnded-8                     0.000 ± 0%
NewTracer-8                            0.000 ± 0%
geomean                                           ¹
¹ summaries must be >0 to compute geomean
```

#### Existing `sdk/trace` benchmarks

```console
> benchstat main.out enc-trace-sdk-tracer-obs.out
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                  │  main.out   │     enc-trace-sdk-tracer-obs.out     │
                                  │   sec/op    │    sec/op     vs base                │
SpanEnd/ObservabilityEnabled-8      188.5n ± 4%   131.5n ± 32%  -30.24% (p=0.000 n=10)
TraceStart/ObservabilityEnabled-8   886.9n ± 8%   663.9n ±  2%  -25.14% (p=0.000 n=10)
geomean                             408.9n        295.5n        -27.73%

                                  │  main.out  │      enc-trace-sdk-tracer-obs.out       │
                                  │    B/op    │    B/op     vs base                     │
SpanEnd/ObservabilityEnabled-8      16.00 ± 0%    0.00 ± 0%  -100.00% (p=0.000 n=10)
TraceStart/ObservabilityEnabled-8   608.0 ± 0%   576.0 ± 0%    -5.26% (p=0.000 n=10)
geomean                             98.63                    ?                       ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean

                                  │  main.out  │      enc-trace-sdk-tracer-obs.out       │
                                  │ allocs/op  │ allocs/op   vs base                     │
SpanEnd/ObservabilityEnabled-8      1.000 ± 0%   0.000 ± 0%  -100.00% (p=0.000 n=10)
TraceStart/ObservabilityEnabled-8   5.000 ± 0%   3.000 ± 0%   -40.00% (p=0.000 n=10)
geomean                             2.236                    ?                       ¹ ²
¹ summaries must be >0 to compute geomean
² ratios must be >0 to compute geomean
```

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-09-15 12:18:32 -07:00
Tyler Yahn
e4ab314112 Encapsulate SDK BatchSpanProcessor observability (#7332)
Split from #7316 

[Follow
guidelines](a5dcd68ebb/CONTRIBUTING.md (encapsulation))
and move instrumentation into its own type.

### Benchmarks

#### Added `sdk/trace/internal/observ` benchmarks

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace/internal/observ
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                         │ enc-trace-sdk-bsp-obs.out │
                         │          sec/op           │
BSP/Processed-8                        0.6394n ±  2%
BSP/ProcessedQueueFull-8               0.6806n ±  3%
BSP/Callback-8                          3.591µ ± 12%
geomean                                 11.60n

                         │ enc-trace-sdk-bsp-obs.out │
                         │           B/op            │
BSP/Processed-8                         0.000 ± 0%
BSP/ProcessedQueueFull-8                0.000 ± 0%
BSP/Callback-8                        2.626Ki ± 0%
geomean                                            ¹
¹ summaries must be >0 to compute geomean

                         │ enc-trace-sdk-bsp-obs.out │
                         │         allocs/op         │
BSP/Processed-8                         0.000 ± 0%
BSP/ProcessedQueueFull-8                0.000 ± 0%
BSP/Callback-8                          16.00 ± 0%
geomean                                            ¹
¹ summaries must be >0 to compute geomean
```

#### Existing `sdk/trace` benchmarks

None
2025-09-15 11:18:19 -07:00
renovate[bot]
6243f21805 fix(deps): update module go.opentelemetry.io/auto/sdk to v1.2.1 (#7365)
Coming soon: The Renovate bot (GitHub App) will be renamed to Mend. PRs
from Renovate will soon appear from 'Mend'. Learn more
[here](https://redirect.github.com/renovatebot/renovate/discussions/37842).

This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
|
[go.opentelemetry.io/auto/sdk](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation)
| `v1.1.0` -> `v1.2.1` |
[![age](https://developer.mend.io/api/mc/badges/age/go/go.opentelemetry.io%2fauto%2fsdk/v1.2.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/go.opentelemetry.io%2fauto%2fsdk/v1.1.0/v1.2.1?slim=true)](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>open-telemetry/opentelemetry-go-instrumentation
(go.opentelemetry.io/auto/sdk)</summary>

###
[`v1.2.1`](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/blob/HEAD/CHANGELOG.md#goopentelemetryioautosdk-v121---2025-09-15)

##### Fixed

- Fix `uint32` bounding on 32 bit architectures in the
`go.opentelemetry.io/auto/sdk` module.
([#&#8203;2810](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2810))

###
[`v1.2.0`](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/blob/HEAD/CHANGELOG.md#v0230v120---2025-09-10)

<!-- markdownlint-disable MD028 -->

> \[!NOTE]
> This is the last release version that will support building the
auto-instrumentation CLI using Go 1.23.
> The next release will require development to be done using Go >= 1.24.

<!-- markdownlint-enable MD028 -->

##### Added

- Cache offsets for `golang.org/x/net` `0.42.0`.
([#&#8203;2503](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2503))
- Cache offsets for `google.golang.org/grpc` `1.74.2`.
([#&#8203;2546](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2546))
- Cache offsets for `google.golang.org/grpc` `1.76.0-dev`.
([#&#8203;2596](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2596))
- Allow configuration of the resource using a [resource.Detector].
([#&#8203;2598](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2598))
- The `WithResourceDetector` function is added to
`go.opentelemetry.io/auto/pipeline/otelsdk`.
- The `WithEnv` function is updated to parse the
`OTEL_RESOURCE_DETECTOR` environment variable.
Values are expected to be a comma-separated list of resource detector
IDs registered with the [`autodetect` package].
- Cache offsets for Go `1.23.12`.
([#&#8203;2603](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2603))
- Cache offsets for Go `1.24.6`.
([#&#8203;2603](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2603))
- Cache offsets for `golang.org/x/net` `0.43.0`.
([#&#8203;2615](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2615))
- Cache offsets for Go `1.25.0`.
([#&#8203;2651](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2651))
- Cache offsets for `google.golang.org/grpc` `1.75.0`.
([#&#8203;2686](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2686))
- Cache offsets for `github.com/segmentio/kafka-go` `0.4.49`.
([#&#8203;2699](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2699))
- Cache offsets for `go.opentelemetry.io/otel` `v1.38.0`.
([#&#8203;2726](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2726))
- Cache offsets for Go `1.24.7`.
([#&#8203;2747](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2747))
- Cache offsets for Go `1.25.1`.
([#&#8203;2747](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2747))
- Cache offsets for `golang.org/x/net` `0.44.0`.
([#&#8203;2773](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2773))
- Cache offsets for `google.golang.org/grpc` `1.72.3`.
([#&#8203;2787](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2787))
- Cache offsets for `google.golang.org/grpc` `1.73.1`.
([#&#8203;2787](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2787))
- Cache offsets for `google.golang.org/grpc` `1.74.3`.
([#&#8203;2787](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2787))
- Cache offsets for `google.golang.org/grpc` `1.75.1`.
([#&#8203;2787](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2787))

[resource.Detector]:
https://pkg.go.dev/go.opentelemetry.io/otel/sdk/resource#Detector

[`autodetect` package]:
https://pkg.go.dev/go.opentelemetry.io/contrib/detectors/autodetect

##### Changed

- Upgrade `go.opentelemetry.io/auto` semconv to `v1.37.0`.
([#&#8203;2763](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2763))
- Upgrade `go.opentelemetry.io/auto/sdk` semconv to `v1.37.0`.
([#&#8203;2763](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2763))

##### Fixed

- Add `telemetry.distro.version` resource attribute to the `otelsdk`
handler.
([#&#8203;2383](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2383))
- `active_spans_by_span_ptr` eBPF map used in the traceglobal probe
changed to LRU.
([#&#8203;2509](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation/pull/2509))

</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 becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates 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:eyJjcmVhdGVkSW5WZXIiOiI0MS45Ny4xMCIsInVwZGF0ZWRJblZlciI6IjQxLjk3LjEwIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJTa2lwIENoYW5nZWxvZyIsImRlcGVuZGVuY2llcyJdfQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-15 20:06:06 +02:00
Tyler Yahn
4fdd552782 Track context containing span in recordingSpan (#7354)
Avoid the allocation of re-embedding the span in a context on end by
keeping the one created on start in the span.

### Benchmarks

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                  │  main.out   │    trace-recording-span-ctx.out     │
                                  │   sec/op    │   sec/op     vs base                │
SpanEnd/ObservabilityEnabled-8      248.2n ± 5%   186.2n ± 4%  -24.94% (p=0.000 n=20)
TraceStart/ObservabilityEnabled-8   935.8n ± 2%   995.9n ± 4%   +6.43% (p=0.000 n=20)
geomean                             481.9n        430.7n       -10.62%

                                  │  main.out  │     trace-recording-span-ctx.out     │
                                  │    B/op    │    B/op     vs base                  │
SpanEnd/ObservabilityEnabled-8      64.00 ± 0%   16.00 ± 0%  -75.00% (p=0.000 n=20)
TraceStart/ObservabilityEnabled-8   608.0 ± 0%   608.0 ± 0%        ~ (p=1.000 n=20) ¹
geomean                             197.3        98.63       -50.00%
¹ all samples are equal

                                  │  main.out  │     trace-recording-span-ctx.out     │
                                  │ allocs/op  │ allocs/op   vs base                  │
SpanEnd/ObservabilityEnabled-8      2.000 ± 0%   1.000 ± 0%  -50.00% (p=0.000 n=20)
TraceStart/ObservabilityEnabled-8   5.000 ± 0%   5.000 ± 0%        ~ (p=1.000 n=20) ¹
geomean                             3.162        2.236       -29.29%
¹ all samples are equal
```
2025-09-15 10:54:12 -07:00
Sanoj Subran
285cbe9102 sdk/metric: add example for metricdatatest package (#7323)
The examples use a ManualReader to collect the metrics and verify the
expected data against the actual data using the metricdatatest
package.

---------

Signed-off-by: sanojsubran <sanoj.subran@ibm.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Flc゛ <four_leaf_clover@foxmail.com>
2025-09-11 18:23:59 +02:00
Tyler Yahn
7fdebbe3ed Rename Self-Observability as just Observability (#7302)
Self-Observability is a redundant term, the self being instrumented is
always the self that observability is being provided for. Remove this
redundancy.

Continue to provide backwards compatibility for any users already using
`OTEL_GO_X_SELF_OBSERVABILITY` to enable the feature.

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-09-11 10:01:19 +02:00
Tyler Yahn
b335c0795c Encapsulate observability in Logs SDK (#7315)
- [Follow
guidelines](a5dcd68ebb/CONTRIBUTING.md (encapsulation))
and encapsulate the Observability for the Logs SDK logger by moving it
into a single function.
- Add benchmarks to ensure no performance regressions

### Benchmarks

```console
$ benchstat main_2de26d1de.txt enc-sdk-log-obs_c06e888.txt
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/log
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                   │ main_2de26d1de.txt │    enc-sdk-log-obs_c06e888.txt     │
                                   │       sec/op       │   sec/op     vs base               │
LoggerEmitObservability/Disabled-8          167.8n ± 4%   167.3n ± 5%       ~ (p=0.796 n=10)
LoggerEmitObservability/Enabled-8           556.6n ± 4%   556.1n ± 4%       ~ (p=0.955 n=10)
geomean                                     305.6n        305.0n       -0.19%

                                   │ main_2de26d1de.txt │     enc-sdk-log-obs_c06e888.txt     │
                                   │        B/op        │    B/op     vs base                 │
LoggerEmitObservability/Disabled-8           448.0 ± 0%   448.0 ± 0%       ~ (p=1.000 n=10) ¹
LoggerEmitObservability/Enabled-8            448.0 ± 0%   448.0 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                      448.0        448.0       +0.00%
¹ all samples are equal

                                   │ main_2de26d1de.txt │     enc-sdk-log-obs_c06e888.txt     │
                                   │     allocs/op      │ allocs/op   vs base                 │
LoggerEmitObservability/Disabled-8           1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
LoggerEmitObservability/Enabled-8            1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                      1.000        1.000       +0.00%
¹ all samples are equal
```
2025-09-08 07:29:01 -07:00
David Ashpole
567ef26abf Add benchmark for exponential histogram measurements (#7305)
This is helpful for my work optimizing locking in
https://github.com/open-telemetry/opentelemetry-go/pull/7189

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Xeon(R) CPU @ 2.20GHz
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/0-24         	   43419	       306.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/0-24         	   40675	       316.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/0-24         	   53746	       305.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/0-24         	   38224	       296.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/0-24         	   53796	       330.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/0-24         	   47823	       316.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/1-24         	   32172	       373.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/1-24         	   33084	       379.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/1-24         	   29956	       360.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/1-24         	   33921	       370.1 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/1-24         	   34449	       387.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/1-24         	   29156	       393.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/10-24        	   10768	      1040 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/10-24        	   11190	      1056 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/10-24        	   11078	      1176 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/10-24        	   10929	      1219 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/10-24        	   10454	      1066 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/NoView/ExponentialFloat64Histogram/Attributes/10-24        	   10501	      1064 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/0-24       	 5919898	         1.879 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/0-24       	 5834685	         1.990 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/0-24       	 5782334	         2.433 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/0-24       	 5320924	         2.404 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/0-24       	 5742800	         2.109 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/0-24       	 5885475	         2.056 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/1-24       	 4331547	         2.758 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/1-24       	 3848244	         2.725 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/1-24       	 4542189	         2.636 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/1-24       	 4201015	         2.641 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/1-24       	 4597094	         2.608 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/1-24       	 4869811	         2.491 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/10-24      	 4826077	         2.329 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/10-24      	 4866612	         2.382 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/10-24      	 5149305	         2.310 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/10-24      	 5101305	         2.384 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/10-24      	 4854940	         2.440 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/DropView/ExponentialFloat64Histogram/Attributes/10-24      	 4874742	         2.501 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/0-24 	   55272	       359.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/0-24 	   52195	       318.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/0-24 	   52324	       330.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/0-24 	   49879	       321.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/0-24 	   56212	       351.3 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/0-24 	   43362	       301.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/1-24 	   30296	       461.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/1-24 	   24178	       469.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/1-24 	   24901	       477.0 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/1-24 	   21748	       477.6 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/1-24 	   23972	       512.9 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/1-24 	   28039	       499.5 ns/op	       0 B/op	       0 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/10-24         	    7598	      1646 ns/op	     704 B/op	       2 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/10-24         	    7452	      1660 ns/op	     704 B/op	       2 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/10-24         	    7620	      1644 ns/op	     704 B/op	       2 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/10-24         	    6459	      1853 ns/op	     704 B/op	       2 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/10-24         	    7950	      1575 ns/op	     704 B/op	       2 allocs/op
BenchmarkSyncMeasure/AttrFilterView/ExponentialFloat64Histogram/Attributes/10-24         	    8948	      1421 ns/op	     704 B/op	       2 allocs/op
```
2025-09-08 09:19:44 +02:00
renovate[bot]
8ac554a28b fix(deps): update golang.org/x (#7320)
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
| golang.org/x/sync | `v0.16.0` -> `v0.17.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fsync/v0.17.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fsync/v0.16.0/v0.17.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/sys | `v0.35.0` -> `v0.36.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fsys/v0.36.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fsys/v0.35.0/v0.36.0?slim=true)](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:eyJjcmVhdGVkSW5WZXIiOiI0MS45MS4xIiwidXBkYXRlZEluVmVyIjoiNDEuOTEuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-09-07 07:53:31 -07:00
David Ashpole
b218e4bb5a Don't track min and max when disabled (#7306)
Minor optimization for histogram `measure()`. When min/max are disabled
for histograms, don't track it during measure().

the `bin` function is split into `bin` and `minMax` to facilitate this.

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2025-09-06 08:46:00 -07:00
Damien Mathieu
0174808b2b Fix schema urls (#7288)
The 1.0.0 schema now returns a 404 on opentelemetry.io.
2025-09-02 14:51:02 +02:00
ADITYA RAUT
5e3b939f4b Add tracetest example for testing instrumentation (#7107)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7051
2025-09-01 22:15:17 +02:00
Tyler Yahn
8ab8e421a5 Drop support for Go 1.23 (#7274) 2025-08-31 07:52:30 -07:00
Tyler Yahn
84e3f3ac8b Release v1.38.0 (#7271)
This release is the last to support [Go 1.23].
The next release will require at least [Go 1.24].

### Added

- Add native histogram exemplar support in
`go.opentelemetry.io/otel/exporters/prometheus`. (#6772)
- Add template attribute functions to the
`go.opentelmetry.io/otel/semconv/v1.34.0` package. (#6939)
  - `ContainerLabel`
  - `DBOperationParameter`
  - `DBSystemParameter`
  - `HTTPRequestHeader`
  - `HTTPResponseHeader`
  - `K8SCronJobAnnotation`
  - `K8SCronJobLabel`
  - `K8SDaemonSetAnnotation`
  - `K8SDaemonSetLabel`
  - `K8SDeploymentAnnotation`
  - `K8SDeploymentLabel`
  - `K8SJobAnnotation`
  - `K8SJobLabel`
  - `K8SNamespaceAnnotation`
  - `K8SNamespaceLabel`
  - `K8SNodeAnnotation`
  - `K8SNodeLabel`
  - `K8SPodAnnotation`
  - `K8SPodLabel`
  - `K8SReplicaSetAnnotation`
  - `K8SReplicaSetLabel`
  - `K8SStatefulSetAnnotation`
  - `K8SStatefulSetLabel`
  - `ProcessEnvironmentVariable`
  - `RPCConnectRPCRequestMetadata`
  - `RPCConnectRPCResponseMetadata`
  - `RPCGRPCRequestMetadata`
  - `RPCGRPCResponseMetadata`
- Add `ErrorType` attribute helper function to the
`go.opentelmetry.io/otel/semconv/v1.34.0` package. (#6962)
- Add `WithAllowKeyDuplication` in `go.opentelemetry.io/otel/sdk/log`
which can be used to disable deduplication for log records. (#6968)
- Add `WithCardinalityLimit` option to configure the cardinality limit
in `go.opentelemetry.io/otel/sdk/metric`. (#6996, #7065, #7081, #7164,
#7165, #7179)
- Add `Clone` method to `Record` in `go.opentelemetry.io/otel/log` that
returns a copy of the record with no shared state. (#7001)
- Add experimental self-observability span and batch span processor
metrics in `go.opentelemetry.io/otel/sdk/trace`. Check the
`go.opentelemetry.io/otel/sdk/trace/internal/x` package documentation
for more information. (#7027, #6393, #7209)
- The `go.opentelemetry.io/otel/semconv/v1.36.0` package. The package
contains semantic conventions from the `v1.36.0` version of the
OpenTelemetry Semantic Conventions. See the [migration
documentation](./semconv/v1.36.0/MIGRATION.md) for information on how to
upgrade from `go.opentelemetry.io/otel/semconv/v1.34.0.`(#7032, #7041)
- Add support for configuring Prometheus name translation using
`WithTranslationStrategy` option in
`go.opentelemetry.io/otel/exporters/prometheus`. The current default
translation strategy when UTF-8 mode is enabled is
`NoUTF8EscapingWithSuffixes`, but a future release will change the
default strategy to `UnderscoreEscapingWithSuffixes` for compliance with
the specification. (#7111)
- Add experimental self-observability log metrics in
`go.opentelemetry.io/otel/sdk/log`. Check the
`go.opentelemetry.io/otel/sdk/log/internal/x` package documentation for
more information. (#7121)
- Add experimental self-observability trace exporter metrics in
`go.opentelemetry.io/otel/exporters/stdout/stdouttrace`. Check the
`go.opentelemetry.io/otel/exporters/stdout/stdouttrace/internal/x`
package documentation for more information. (#7133)
- Support testing of [Go 1.25]. (#7187)
- The `go.opentelemetry.io/otel/semconv/v1.37.0` package. The package
contains semantic conventions from the `v1.37.0` version of the
OpenTelemetry Semantic Conventions. See the [migration
documentation](./semconv/v1.37.0/MIGRATION.md) for information on how to
upgrade from `go.opentelemetry.io/otel/semconv/v1.36.0.`(#7254)

### Changed

- Optimize `TraceIDFromHex` and `SpanIDFromHex` in
`go.opentelemetry.io/otel/sdk/trace`. (#6791)
- Change `AssertEqual` in `go.opentelemetry.io/otel/log/logtest` to
accept `TestingT` in order to support benchmarks and fuzz tests. (#6908)
- Change `DefaultExemplarReservoirProviderSelector` in
`go.opentelemetry.io/otel/sdk/metric` to use `runtime.GOMAXPROCS(0)`
instead of `runtime.NumCPU()` for the `FixedSizeReservoirProvider`
default size. (#7094)

### Fixed

- `SetBody` method of `Record` in `go.opentelemetry.io/otel/sdk/log` now
deduplicates key-value collections (`log.Value` of `log.KindMap` from
`go.opentelemetry.io/otel/log`). (#7002)
- Fix `go.opentelemetry.io/otel/exporters/prometheus` to not append a
suffix if it's already present in metric name. (#7088)
- Fix the `go.opentelemetry.io/otel/exporters/stdout/stdouttrace`
self-observability component type and name. (#7195)
- Fix partial export count metric in
`go.opentelemetry.io/otel/exporters/stdout/stdouttrace`. (#7199)

### Deprecated

- Deprecate `WithoutUnits` and `WithoutCounterSuffixes` options,
preferring `WithTranslationStrategy` instead. (#7111)
- Deprecate support for `OTEL_GO_X_CARDINALITY_LIMIT` environment
variable in `go.opentelemetry.io/otel/sdk/metric`. Use
`WithCardinalityLimit` option instead. (#7166)
2025-08-29 12:42:52 -07:00
Tyler Yahn
9798759463 Statically define trace observability attributes (#7263)
There are a finite set of attributes that can be recorded with self
observability instruments. Cache these combinations to avoid computation
and allocations on the hot-path of tracing.

### Benchmarks

```console
$ benchstat main_25d02741f.txt cache-trace-obs-sets_05fd6ee.txt
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                                      │ main_25d02741f.txt │  cache-trace-obs-sets_05fd6ee.txt   │
                                      │       sec/op       │   sec/op     vs base                │
SpanEnd/SelfObservabilityEnabled-8             366.2n ± 5%   229.2n ± 3%  -37.39% (p=0.000 n=10)
TraceStart/SelfObservabilityEnabled-8         1076.0n ± 2%   800.2n ± 2%  -25.63% (p=0.000 n=10)
geomean                                        627.7n        428.3n       -31.76%

                                      │ main_25d02741f.txt │  cache-trace-obs-sets_05fd6ee.txt  │
                                      │        B/op        │    B/op     vs base                │
SpanEnd/SelfObservabilityEnabled-8             192.00 ± 0%   64.00 ± 0%  -66.67% (p=0.000 n=10)
TraceStart/SelfObservabilityEnabled-8           992.0 ± 0%   608.0 ± 0%  -38.71% (p=0.000 n=10)
geomean                                         436.4        197.3       -54.80%

                                      │ main_25d02741f.txt │  cache-trace-obs-sets_05fd6ee.txt  │
                                      │     allocs/op      │ allocs/op   vs base                │
SpanEnd/SelfObservabilityEnabled-8              4.000 ± 0%   2.000 ± 0%  -50.00% (p=0.000 n=10)
TraceStart/SelfObservabilityEnabled-8           9.000 ± 0%   5.000 ± 0%  -44.44% (p=0.000 n=10)
geomean                                         6.000        3.162       -47.30%
```
2025-08-29 08:36:54 -07:00
Tyler Yahn
be1e57fb36 Refactor BSP observability setup (#7264)
Do not rely on side-effects from the configureSelfObservability method.
Instead, initialize with the new pure newBSPObs func.
2025-08-29 08:05:29 -07:00
Tyler Yahn
5358fd737d Upgrade semconv dependencies to v1.37.0 (#7260)
Resolve https://github.com/open-telemetry/opentelemetry-go/issues/7255
2025-08-28 11:29:52 +02:00
renovate[bot]
25d02741f7 fix(deps): update module github.com/stretchr/testify to v1.11.1 (#7261)
This PR contains the following updates:

| Package | Change | Age | Confidence |
|---|---|---|---|
|
[github.com/stretchr/testify](https://redirect.github.com/stretchr/testify)
| `v1.11.0` -> `v1.11.1` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fstretchr%2ftestify/v1.11.1?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fstretchr%2ftestify/v1.11.0/v1.11.1?slim=true)](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>stretchr/testify (github.com/stretchr/testify)</summary>

###
[`v1.11.1`](https://redirect.github.com/stretchr/testify/releases/tag/v1.11.1)

[Compare
Source](https://redirect.github.com/stretchr/testify/compare/v1.11.0...v1.11.1)

This release fixes
[#&#8203;1785](https://redirect.github.com/stretchr/testify/issues/1785)
introduced in v1.11.0 where expected argument values implementing the
stringer interface (`String() string`) with a method which mutates their
value, when passed to mock.Mock.On (`m.On("Method",
<expected>).Return()`) or actual argument values passed to
mock.Mock.Called may no longer match one another where they previously
did match. The behaviour prior to v1.11.0 where the stringer is always
called is restored. Future testify releases may not call the stringer
method at all in this case.

#### What's Changed

- Backport
[#&#8203;1786](https://redirect.github.com/stretchr/testify/issues/1786)
to release/1.11: mock: revert to pre-v1.11.0 argument matching behavior
for mutating stringers by
[@&#8203;brackendawson](https://redirect.github.com/brackendawson) in
[#&#8203;1788](https://redirect.github.com/stretchr/testify/pull/1788)

**Full Changelog**:
<https://github.com/stretchr/testify/compare/v1.11.0...v1.11.1>

</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 these
updates 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:eyJjcmVhdGVkSW5WZXIiOiI0MS44Mi43IiwidXBkYXRlZEluVmVyIjoiNDEuODIuNyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: dmathieu <damien.mathieu@elastic.co>
2025-08-27 20:20:20 +02:00
Tyler Yahn
c8b89e9780 Propagate context to self-observability measurements in sdk/trace (#7209)
Ensures metric functionality that integrates with trace context (e.g.
exemplars) correctly receive the trace context and anything else the
user has passed.
2025-08-26 08:58:35 -07:00
Joe Schafer
49be00144e trace: optimize id parsing and string functions (#6791)
With specialized routines, we can avoid the allocation of
hex.DecodeString since we know the structure of the IDs.

We can use `==` instead of bytes.Equal for arrays. From the Go [spec]:

> Array types are comparable if their array element types are
comparable. Two
> array values are equal if their corresponding element values are
equal. The
> elements are compared in ascending index order, and comparison stops
as soon
> as two element values differ (or all elements have been compared).

[spec]: https://go.dev/ref/spec#Comparison_operators

### Benchstat

To generate:
```sh
mkdir private
cd sdk
go test -run=xxxxMatchNothingxxxx -bench=. -count=10 go.opentelemetry.io/otel/sdk/trace -timeout=30m | tee ../private/base.txt
go test -run=xxxxMatchNothingxxxx -bench=. -count=10 go.opentelemetry.io/otel/sdk/trace -timeout=30m | tee ../private/new.txt
benchstat ../private/base.txt ../private/new.txt
```

### Results as of 2025-08-21
```
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: Apple M2 Max
                                              │ ../private/base.txt │          ../private/new.txt           │
                                              │       sec/op        │    sec/op      vs base                │
Truncate/Unlimited-12                                 0.2274n ±  2%   0.2262n ±  1%        ~ (p=0.971 n=10)
Truncate/Zero-12                                      0.3252n ±  1%   0.3267n ±  1%        ~ (p=0.171 n=10)
Truncate/Short-12                                     0.2250n ±  1%   0.2247n ±  1%        ~ (p=0.897 n=10)
Truncate/ASCII-12                                     0.7280n ±  0%   0.7297n ±  0%        ~ (p=0.159 n=10)
Truncate/ValidUTF-8-12                                 1.373n ±  3%    1.376n ±  9%        ~ (p=0.084 n=10)
Truncate/InvalidUTF-8-12                               9.605n ±  4%    9.724n ±  7%        ~ (p=0.289 n=10)
Truncate/MixedUTF-8-12                                 17.54n ±  2%    17.56n ±  1%        ~ (p=0.839 n=10)
RecordingSpanSetAttributes/WithLimit/false-12          2.046µ ±  1%    2.055µ ±  1%        ~ (p=0.383 n=10)
RecordingSpanSetAttributes/WithLimit/true-12           4.329µ ±  0%    4.335µ ±  0%        ~ (p=0.108 n=10)
SpanEnd-12                                             90.10n ± 30%   102.26n ± 20%        ~ (p=0.143 n=10)
TraceStart/with_a_simple_span-12                       300.4n ±  7%    290.1n ±  4%        ~ (p=0.353 n=10)
TraceStart/with_several_links-12                       416.8n ±  3%    407.0n ±  2%   -2.34% (p=0.014 n=10)
TraceStart/with_attributes-12                          460.6n ±  1%    446.5n ±  2%   -3.04% (p=0.000 n=10)
SpanLimits/AttributeValueLengthLimit-12                4.425µ ±  3%    4.254µ ±  1%   -3.86% (p=0.000 n=10)
SpanLimits/AttributeCountLimit-12                      4.138µ ±  1%    3.986µ ±  1%   -3.65% (p=0.000 n=10)
SpanLimits/EventCountLimit-12                          3.926µ ±  1%    3.780µ ±  1%   -3.73% (p=0.000 n=10)
SpanLimits/LinkCountLimit-12                           3.879µ ±  1%    3.738µ ±  1%   -3.64% (p=0.000 n=10)
SpanLimits/AttributePerEventCountLimit-12              4.249µ ±  1%    4.216µ ±  1%        ~ (p=0.066 n=10)
SpanLimits/AttributePerLinkCountLimit-12               4.175µ ±  1%    4.226µ ±  0%   +1.22% (p=0.037 n=10)
SpanSetAttributesOverCapacity-12                       1.648µ ±  0%    1.635µ ±  6%        ~ (p=0.382 n=10)
StartEndSpan/AlwaysSample-12                           305.3n ±  1%    298.9n ±  2%   -2.10% (p=0.045 n=10)
StartEndSpan/NeverSample-12                            137.0n ±  0%    132.9n ±  0%   -3.03% (p=0.000 n=10)
SpanWithAttributes_4/AlwaysSample-12                   516.3n ±  1%    507.6n ±  0%   -1.68% (p=0.000 n=10)
SpanWithAttributes_4/NeverSample-12                    228.7n ±  1%    221.8n ±  1%   -3.00% (p=0.000 n=10)
SpanWithAttributes_8/AlwaysSample-12                   706.6n ±  1%    689.0n ±  0%   -2.50% (p=0.000 n=10)
SpanWithAttributes_8/NeverSample-12                    313.0n ±  1%    307.1n ±  0%   -1.87% (p=0.000 n=10)
SpanWithAttributes_all/AlwaysSample-12                 565.0n ±  1%    560.8n ±  0%   -0.75% (p=0.002 n=10)
SpanWithAttributes_all/NeverSample-12                  251.2n ±  1%    247.5n ±  4%   -1.45% (p=0.034 n=10)
SpanWithAttributes_all_2x/AlwaysSample-12              823.4n ±  1%    812.0n ±  1%   -1.39% (p=0.028 n=10)
SpanWithAttributes_all_2x/NeverSample-12               368.8n ±  1%    360.6n ±  0%   -2.22% (p=0.000 n=10)
SpanWithEvents_4/AlwaysSample-12                       709.3n ±  0%    699.6n ±  0%   -1.37% (p=0.000 n=10)
SpanWithEvents_4/NeverSample-12                        139.4n ±  0%    137.0n ±  0%   -1.72% (p=0.000 n=10)
SpanWithEvents_8/AlwaysSample-12                       1.091µ ±  1%    1.073µ ±  0%   -1.60% (p=0.000 n=10)
SpanWithEvents_8/NeverSample-12                        142.1n ±  0%    140.1n ±  0%   -1.41% (p=0.000 n=10)
SpanWithEvents_WithStackTrace/AlwaysSample-12          424.6n ±  0%    417.9n ±  0%   -1.57% (p=0.000 n=10)
SpanWithEvents_WithStackTrace/NeverSample-12           151.3n ±  0%    148.1n ±  0%   -2.15% (p=0.000 n=10)
SpanWithEvents_WithTimestamp/AlwaysSample-12           412.6n ±  0%    407.6n ±  0%   -1.19% (p=0.000 n=10)
SpanWithEvents_WithTimestamp/NeverSample-12            174.5n ±  0%    172.7n ±  0%   -1.03% (p=0.000 n=10)
TraceIDFromHex-12                                      57.22n ±  0%    15.88n ±  0%  -72.25% (p=0.000 n=10)
SpanIDFromHex-12                                      35.000n ±  0%    8.676n ±  0%  -75.21% (p=0.000 n=10)
TraceID_DotString-12                                   42.39n ±  0%    24.22n ±  0%  -42.85% (p=0.000 n=10)
SpanID_DotString-12                                    31.41n ±  0%    16.98n ±  0%  -45.94% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_10-12             164.0n ±  0%    163.8n ±  0%   -0.12% (p=0.021 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_100-12            1.640µ ±  0%    1.637µ ±  0%   -0.18% (p=0.016 n=10)
SpanProcessorOnEnd/batch:_100,_spans:_10-12            164.0n ±  0%    163.7n ±  0%   -0.18% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_100,_spans:_100-12           1.641µ ±  0%    1.636µ ±  0%   -0.30% (p=0.000 n=10)
SpanProcessorVerboseLogging-12                         6.413µ ±  2%    6.444µ ±  5%        ~ (p=0.424 n=10)
geomean                                                204.9n          187.0n         -8.69%

                                              │ ../private/base.txt │            ../private/new.txt             │
                                              │        B/op         │     B/op      vs base                     │
Truncate/Unlimited-12                                  0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/Zero-12                                       0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/Short-12                                      0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/ASCII-12                                      0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/ValidUTF-8-12                                 0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/InvalidUTF-8-12                               16.00 ± 0%       16.00 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/MixedUTF-8-12                                 32.00 ± 0%       32.00 ± 0%         ~ (p=1.000 n=10) ¹
RecordingSpanSetAttributes/WithLimit/false-12        6.891Ki ± 0%     6.891Ki ± 0%         ~ (p=1.000 n=10) ¹
RecordingSpanSetAttributes/WithLimit/true-12         7.023Ki ± 0%     7.023Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanEnd-12                                             0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
TraceStart/with_a_simple_span-12                       528.0 ± 0%       528.0 ± 0%         ~ (p=1.000 n=10) ¹
TraceStart/with_several_links-12                       704.0 ± 0%       704.0 ± 0%         ~ (p=1.000 n=10) ¹
TraceStart/with_attributes-12                          784.0 ± 0%       784.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/AttributeValueLengthLimit-12              10.56Ki ± 0%     10.56Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/AttributeCountLimit-12                    9.844Ki ± 0%     9.844Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/EventCountLimit-12                        9.422Ki ± 0%     9.422Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/LinkCountLimit-12                         9.031Ki ± 0%     9.031Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/AttributePerEventCountLimit-12            10.47Ki ± 0%     10.47Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/AttributePerLinkCountLimit-12             10.47Ki ± 0%     10.47Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanSetAttributesOverCapacity-12                       592.0 ± 0%       592.0 ± 0%         ~ (p=1.000 n=10) ¹
StartEndSpan/AlwaysSample-12                           528.0 ± 0%       528.0 ± 0%         ~ (p=1.000 n=10) ¹
StartEndSpan/NeverSample-12                            144.0 ± 0%       144.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_4/AlwaysSample-12                 1.016Ki ± 0%     1.016Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_4/NeverSample-12                    400.0 ± 0%       400.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_8/AlwaysSample-12                 1.516Ki ± 0%     1.516Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_8/NeverSample-12                    656.0 ± 0%       656.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_all/AlwaysSample-12               1.141Ki ± 0%     1.141Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_all/NeverSample-12                  464.0 ± 0%       464.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_all_2x/AlwaysSample-12            1.891Ki ± 0%     1.891Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_all_2x/NeverSample-12               848.0 ± 0%       848.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_4/AlwaysSample-12                     1.016Ki ± 0%     1.016Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_4/NeverSample-12                        144.0 ± 0%       144.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_8/AlwaysSample-12                     1.641Ki ± 0%     1.641Ki ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_8/NeverSample-12                        144.0 ± 0%       144.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_WithStackTrace/AlwaysSample-12          624.0 ± 0%       624.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_WithStackTrace/NeverSample-12           160.0 ± 0%       160.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_WithTimestamp/AlwaysSample-12           648.0 ± 0%       648.0 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_WithTimestamp/NeverSample-12            184.0 ± 0%       184.0 ± 0%         ~ (p=1.000 n=10) ¹
TraceIDFromHex-12                                      16.00 ± 0%        0.00 ± 0%  -100.00% (p=0.000 n=10)
SpanIDFromHex-12                                       8.000 ± 0%       0.000 ± 0%  -100.00% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_10-12             0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_10,_spans:_100-12            0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_100,_spans:_10-12            0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_100,_spans:_100-12           0.000 ± 0%       0.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanProcessorVerboseLogging-12                       9.562Ki ± 0%     9.562Ki ± 0%         ~ (p=1.000 n=10) ¹
geomean                                                           ²                 ?                       ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean

                                              │ ../private/base.txt │           ../private/new.txt            │
                                              │      allocs/op      │ allocs/op   vs base                     │
Truncate/Unlimited-12                                  0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/Zero-12                                       0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/Short-12                                      0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/ASCII-12                                      0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/ValidUTF-8-12                                 0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/InvalidUTF-8-12                               1.000 ± 0%     1.000 ± 0%         ~ (p=1.000 n=10) ¹
Truncate/MixedUTF-8-12                                 1.000 ± 0%     1.000 ± 0%         ~ (p=1.000 n=10) ¹
RecordingSpanSetAttributes/WithLimit/false-12          3.000 ± 0%     3.000 ± 0%         ~ (p=1.000 n=10) ¹
RecordingSpanSetAttributes/WithLimit/true-12           10.00 ± 0%     10.00 ± 0%         ~ (p=1.000 n=10) ¹
SpanEnd-12                                             0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
TraceStart/with_a_simple_span-12                       2.000 ± 0%     2.000 ± 0%         ~ (p=1.000 n=10) ¹
TraceStart/with_several_links-12                       3.000 ± 0%     3.000 ± 0%         ~ (p=1.000 n=10) ¹
TraceStart/with_attributes-12                          4.000 ± 0%     4.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/AttributeValueLengthLimit-12                41.00 ± 0%     41.00 ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/AttributeCountLimit-12                      38.00 ± 0%     38.00 ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/EventCountLimit-12                          35.00 ± 0%     35.00 ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/LinkCountLimit-12                           35.00 ± 0%     35.00 ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/AttributePerEventCountLimit-12              38.00 ± 0%     38.00 ± 0%         ~ (p=1.000 n=10) ¹
SpanLimits/AttributePerLinkCountLimit-12               38.00 ± 0%     38.00 ± 0%         ~ (p=1.000 n=10) ¹
SpanSetAttributesOverCapacity-12                       3.000 ± 0%     3.000 ± 0%         ~ (p=1.000 n=10) ¹
StartEndSpan/AlwaysSample-12                           2.000 ± 0%     2.000 ± 0%         ~ (p=1.000 n=10) ¹
StartEndSpan/NeverSample-12                            2.000 ± 0%     2.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_4/AlwaysSample-12                   4.000 ± 0%     4.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_4/NeverSample-12                    3.000 ± 0%     3.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_8/AlwaysSample-12                   4.000 ± 0%     4.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_8/NeverSample-12                    3.000 ± 0%     3.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_all/AlwaysSample-12                 4.000 ± 0%     4.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_all/NeverSample-12                  3.000 ± 0%     3.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_all_2x/AlwaysSample-12              4.000 ± 0%     4.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithAttributes_all_2x/NeverSample-12               3.000 ± 0%     3.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_4/AlwaysSample-12                       5.000 ± 0%     5.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_4/NeverSample-12                        2.000 ± 0%     2.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_8/AlwaysSample-12                       6.000 ± 0%     6.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_8/NeverSample-12                        2.000 ± 0%     2.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_WithStackTrace/AlwaysSample-12          4.000 ± 0%     4.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_WithStackTrace/NeverSample-12           3.000 ± 0%     3.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_WithTimestamp/AlwaysSample-12           5.000 ± 0%     5.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanWithEvents_WithTimestamp/NeverSample-12            4.000 ± 0%     4.000 ± 0%         ~ (p=1.000 n=10) ¹
TraceIDFromHex-12                                      1.000 ± 0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
SpanIDFromHex-12                                       1.000 ± 0%     0.000 ± 0%  -100.00% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_10-12             0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_10,_spans:_100-12            0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_100,_spans:_10-12            0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanProcessorOnEnd/batch:_100,_spans:_100-12           0.000 ± 0%     0.000 ± 0%         ~ (p=1.000 n=10) ¹
SpanProcessorVerboseLogging-12                         36.00 ± 0%     36.00 ± 0%         ~ (p=1.000 n=10) ¹
geomean                                                           ²               ?                       ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean
```

Issue: #6721
2025-08-26 14:54:11 +02:00
Cijo Thomas
2512a6b087 Clarify overflow attribute description in doc.go to indicate it is boolean true (#7247)
and not string "true"

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2025-08-26 11:04:11 +02:00
Joe Stephenson
a8e15000b6 sdk/log: Deduplicate key-value collections in Record.SetBody (#7002)
Fixes #6982 

```
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/sdk/log
cpu: Apple M2 Pro
                   │   old.txt    │               new.txt               │
                   │    sec/op    │   sec/op     vs base                │
SetBody/SetBody-12   196.5n ± 14%   365.9n ± 4%  +86.26% (p=0.000 n=10)

                   │  old.txt   │            new.txt             │
                   │    B/op    │    B/op     vs base            │
SetBody/SetBody-12   363.0 ± 0%   363.0 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

                   │  old.txt   │            new.txt             │
                   │ allocs/op  │ allocs/op   vs base            │
SetBody/SetBody-12   4.000 ± 0%   4.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal
```

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2025-08-25 18:25:57 +02:00
Yevhenii Solomchenko
3cd63fab03 sdk/metric: Add Documentation for Cardinality Limits (#7179)
Fixes #6979
Towards #6887

## What

- Documentation includes a section on cardinality limits.
- Adding guidance around what cardinality is, why it is important to
consider, how to control it, and what defaults the SDK provides

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2025-08-25 18:15:56 +02:00
Tyler Yahn
4b2bef6dd9 [chore] Upgrade semconv pkg use to v1.36.0 (#7237)
Fix #7236
2025-08-25 16:33:34 +02:00