1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-26 21:05:00 +02:00
Commit Graph

1020 Commits

Author SHA1 Message Date
Tyler Yahn
8c38f80ec3
Release v1.33.0 (#6035)
### Added

- Add `Reset` method to `SpanRecorder` in
`go.opentelemetry.io/otel/sdk/trace/tracetest`. (#5994)
- Add `EnabledInstrument` interface in
`go.opentelemetry.io/otel/sdk/metric/internal/x`. This is an
experimental interface that is implemented by synchronous instruments
provided by `go.opentelemetry.io/otel/sdk/metric`. Users can use it to
avoid performing computationally expensive operations when recording
measurements. It does not fall within the scope of the OpenTelemetry Go
versioning and stability [policy](./VERSIONING.md) and it may be changed
in backwards incompatible ways or removed in feature releases. (#6016)

### Changed

- The default global API now supports full auto-instrumentation from the
`go.opentelemetry.io/auto` package. See that package for more
information. (#5920)
- Propagate non-retryable error messages to client in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#5929)
- Propagate non-retryable error messages to client in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#5929)
- Propagate non-retryable error messages to client in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#5929)
- Performance improvements for attribute value `AsStringSlice`,
`AsFloat64Slice`, `AsInt64Slice`, `AsBoolSlice`. (#6011)
- Change `EnabledParameters` to have a `Severity` field instead of a
getter and setter in `go.opentelemetry.io/otel/log`. (#6009)

### Fixed

- Fix inconsistent request body closing in
`go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp`. (#5954)
- Fix inconsistent request body closing in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#5954)
- Fix inconsistent request body closing in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#5954)
- Fix invalid exemplar keys in
`go.opentelemetry.io/otel/exporters/prometheus`. (#5995)
- Fix attribute value truncation in
`go.opentelemetry.io/otel/sdk/trace`. (#5997)
- Fix attribute value truncation in `go.opentelemetry.io/otel/sdk/log`.
(#6032)
2024-12-12 09:54:13 -08:00
Tyler Yahn
aa95895dfa
Fix sdk/log record attr value limit (#6032)
Fix #6004 

Copy of #5997

### Correctness

From the [OTel
specification](88bffeac48/specification/common/README.md (attribute-limits)):

> - set an attribute value length limit such that for each attribute
value:
> - if it is a string, if it exceeds that limit (counting any character
in it as 1), SDKs MUST truncate that value, so that its length is at
most equal to the limit...

Our current implementation truncates on number of bytes not characters.

Unit tests are added/updated to validate this fix and prevent
regressions.

### Performance

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/log
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                        │ commit-e9c7aac2(old).txt │       commit-878043b9(new).txt       │
                        │          sec/op          │    sec/op     vs base                │
Truncate/Unlimited-8                 0.8323n ±  3%   0.7367n ± 3%  -11.49% (p=0.000 n=10)
Truncate/Zero-8                       1.923n ± 32%    1.359n ± 2%  -29.34% (p=0.000 n=10)
Truncate/Short-8                    14.6050n ±  4%   0.8785n ± 1%  -93.98% (p=0.000 n=10)
Truncate/ASCII-8                      8.205n ±  2%    3.601n ± 7%  -56.12% (p=0.000 n=10)
Truncate/ValidUTF-8-8                11.335n ±  1%    7.206n ± 1%  -36.43% (p=0.000 n=10)
Truncate/InvalidUTF-8-8               58.26n ±  1%    36.61n ± 1%  -37.17% (p=0.000 n=10)
Truncate/MixedUTF-8-8                 81.16n ±  1%    52.30n ± 1%  -35.56% (p=0.000 n=10)
geomean                               10.04n          4.601n       -54.16%

                        │ commit-e9c7aac2(old).txt │      commit-878043b9(new).txt       │
                        │           B/op           │    B/op     vs base                 │
Truncate/Unlimited-8                  0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/Zero-8                       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/Short-8                      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/ASCII-8                      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/ValidUTF-8-8                 0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/InvalidUTF-8-8               16.00 ± 0%     16.00 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/MixedUTF-8-8                 32.00 ± 0%     32.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                          ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                        │ commit-e9c7aac2(old).txt │      commit-878043b9(new).txt       │
                        │        allocs/op         │ allocs/op   vs base                 │
Truncate/Unlimited-8                  0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/Zero-8                       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/Short-8                      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/ASCII-8                      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/ValidUTF-8-8                 0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/InvalidUTF-8-8               1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/MixedUTF-8-8                 1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                          ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```
2024-12-12 09:52:40 +01:00
Alex Boten
0598dae234
sdk/metric: Add experimental Enabled method to synchronous instruments (#6016)
Fixes #6002

---------

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-12-06 10:25:12 +01:00
renovate[bot]
b4a91a210c
chore(deps): update module go.opentelemetry.io/auto/sdk to v1.1.0 (#6025)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[go.opentelemetry.io/auto/sdk](https://redirect.github.com/open-telemetry/opentelemetry-go-instrumentation)
| `v1.0.0` -> `v1.1.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/go.opentelemetry.io%2fauto%2fsdk/v1.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/go.opentelemetry.io%2fauto%2fsdk/v1.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/go.opentelemetry.io%2fauto%2fsdk/v1.0.0/v1.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/go.opentelemetry.io%2fauto%2fsdk/v1.0.0/v1.1.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzOS40Mi40IiwidXBkYXRlZEluVmVyIjoiMzkuNDIuNCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-05 12:57:07 -08:00
renovate[bot]
f654116f6c
chore(deps): update module golang.org/x/sys to v0.28.0 (#6019)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| golang.org/x/sys | `v0.27.0` -> `v0.28.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fsys/v0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2fsys/v0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2fsys/v0.27.0/v0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fsys/v0.27.0/v0.28.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzOS40Mi40IiwidXBkYXRlZEluVmVyIjoiMzkuNDIuNCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-12-04 17:43:50 +01:00
Alex Boten
01fe929572
chore: fix a typo in TestMeterCreatesInstruments (#6015)
updating histogram vars to histo from gauge

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-12-04 08:44:33 +01:00
Robert Pająk
2f0bf8e095
log: Change EnabledParameters to have a field instead of getter and setter (#6009)
Allow users to to write less verbose code by changing methods to field.
2024-12-03 18:36:49 +01:00
Damien Mathieu
bab246013b
Fix span option typo in SDK span End, and WithAttributes only being available on span start (#6006) 2024-11-27 16:53:10 +01:00
Tyler Yahn
e016a78c9f
Fix attribute value truncation (#5997)
Fix #5996

### Correctness

From the [OTel
specification](88bffeac48/specification/common/README.md (attribute-limits)):

> - set an attribute value length limit such that for each attribute
value:
> - if it is a string, if it exceeds that limit (counting any character
in it as 1), SDKs MUST truncate that value, so that its length is at
most equal to the limit...

Our current implementation truncates on number of bytes not characters.

Unit tests are added/updated to validate this fix and prevent
regressions.

### Performance

```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                        │ commit-b6264913(old).txt │       commit-54c61ac2(new).txt        │
                        │          sec/op          │    sec/op      vs base                │
Truncate/Unlimited-8                  1.2300n ± 7%   0.8757n ±  3%  -28.80% (p=0.000 n=10)
Truncate/Zero-8                        2.341n ± 2%    1.550n ±  9%  -33.77% (p=0.000 n=10)
Truncate/Short-8                     31.6800n ± 3%   0.9960n ±  4%  -96.86% (p=0.000 n=10)
Truncate/ASCII-8                       8.821n ± 1%    3.567n ±  3%  -59.57% (p=0.000 n=10)
Truncate/ValidUTF-8-8                 11.960n ± 1%    7.163n ±  1%  -40.10% (p=0.000 n=10)
Truncate/InvalidUTF-8-8                56.35n ± 0%    37.34n ± 18%  -33.74% (p=0.000 n=10)
Truncate/MixedUTF-8-8                  81.83n ± 1%    50.00n ±  1%  -38.90% (p=0.000 n=10)
geomean                                12.37n         4.865n        -60.68%

                        │ commit-b6264913(old).txt │      commit-54c61ac2(new).txt       │
                        │           B/op           │    B/op     vs base                 │
Truncate/Unlimited-8                  0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/Zero-8                       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/Short-8                      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/ASCII-8                      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/ValidUTF-8-8                 0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/InvalidUTF-8-8               16.00 ± 0%     16.00 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/MixedUTF-8-8                 32.00 ± 0%     32.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                          ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                        │ commit-b6264913(old).txt │      commit-54c61ac2(new).txt       │
                        │        allocs/op         │ allocs/op   vs base                 │
Truncate/Unlimited-8                  0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/Zero-8                       0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/Short-8                      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/ASCII-8                      0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/ValidUTF-8-8                 0.000 ± 0%     0.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/InvalidUTF-8-8               1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
Truncate/MixedUTF-8-8                 1.000 ± 0%     1.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                          ²               +0.00%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```

#### Values shorter than limit

This is the default code path. Most attribute values will be shorter
than the default 128 limit that users will not modify.

The current code, `safeTruncate` requires a full iteration of the value
to determine it is valid and under the limit.

The replacement, `truncate`, first checks if the number of bytes in the
value are less than or equal to the limit (which guarantees the number
of characters are less than or equal to the limit) and returns
immediately. This will mean that invalid encoding less than the limit is
not changed, which meets the specification requirements.

#### Values longer than the limit

For values who's number of bytes exceeds the limit, they are iterated
only once with the replacement, `truncate`.

In comparison, the current code, `safeTruncate`, can iterate the string
up to three separate times when the string contains invalid characters.
2024-11-26 09:41:55 +01:00
Flc゛
814a41388b
feat(trace): add concurrent-safe Reset method to SpanRecorder (#5994)
Add Reset method to reuse it for testing. Just like in InMemoryExporter.
2024-11-25 21:20:46 +01:00
ian
e90ab80076
Corrent comments for the metric data storage location (#5999)
Replace the term "out" with "rm" for better clarity.
Original comments referred to "out", which can be ambiguous in this
context.
2024-11-25 10:29:04 +01:00
renovate[bot]
8b510c36ed
fix(deps): update module github.com/stretchr/testify to v1.10.0 (#6000)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/stretchr/testify](https://redirect.github.com/stretchr/testify)
| `v1.9.0` -> `v1.10.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fstretchr%2ftestify/v1.10.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fstretchr%2ftestify/v1.10.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fstretchr%2ftestify/v1.9.0/v1.10.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fstretchr%2ftestify/v1.9.0/v1.10.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>stretchr/testify (github.com/stretchr/testify)</summary>

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

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

#### What's Changed

##### Functional Changes

- Add PanicAssertionFunc by
[@&#8203;fahimbagar](https://redirect.github.com/fahimbagar) in
[https://github.com/stretchr/testify/pull/1337](https://redirect.github.com/stretchr/testify/pull/1337)
- assert: deprecate CompareType by
[@&#8203;dolmen](https://redirect.github.com/dolmen) in
[https://github.com/stretchr/testify/pull/1566](https://redirect.github.com/stretchr/testify/pull/1566)
- assert: make YAML dependency pluggable via build tags by
[@&#8203;dolmen](https://redirect.github.com/dolmen) in
[https://github.com/stretchr/testify/pull/1579](https://redirect.github.com/stretchr/testify/pull/1579)
- assert: new assertion NotElementsMatch by
[@&#8203;hendrywiranto](https://redirect.github.com/hendrywiranto) in
[https://github.com/stretchr/testify/pull/1600](https://redirect.github.com/stretchr/testify/pull/1600)
- mock: in order mock calls by
[@&#8203;ReyOrtiz](https://redirect.github.com/ReyOrtiz) in
[https://github.com/stretchr/testify/pull/1637](https://redirect.github.com/stretchr/testify/pull/1637)
- Add assertion for NotErrorAs by
[@&#8203;palsivertsen](https://redirect.github.com/palsivertsen) in
[https://github.com/stretchr/testify/pull/1129](https://redirect.github.com/stretchr/testify/pull/1129)
- Record Return Arguments of a Call by
[@&#8203;jayd3e](https://redirect.github.com/jayd3e) in
[https://github.com/stretchr/testify/pull/1636](https://redirect.github.com/stretchr/testify/pull/1636)
- assert.EqualExportedValues: accepts everything by
[@&#8203;redachl](https://redirect.github.com/redachl) in
[https://github.com/stretchr/testify/pull/1586](https://redirect.github.com/stretchr/testify/pull/1586)

##### Fixes

- assert: make tHelper a type alias by
[@&#8203;dolmen](https://redirect.github.com/dolmen) in
[https://github.com/stretchr/testify/pull/1562](https://redirect.github.com/stretchr/testify/pull/1562)
- Do not get argument again unnecessarily in Arguments.Error() by
[@&#8203;TomWright](https://redirect.github.com/TomWright) in
[https://github.com/stretchr/testify/pull/820](https://redirect.github.com/stretchr/testify/pull/820)
- Fix time.Time compare by
[@&#8203;myxo](https://redirect.github.com/myxo) in
[https://github.com/stretchr/testify/pull/1582](https://redirect.github.com/stretchr/testify/pull/1582)
- assert.Regexp: handle \[]byte array properly by
[@&#8203;kevinburkesegment](https://redirect.github.com/kevinburkesegment)
in
[https://github.com/stretchr/testify/pull/1587](https://redirect.github.com/stretchr/testify/pull/1587)
- assert: collect.FailNow() should not panic by
[@&#8203;marshall-lee](https://redirect.github.com/marshall-lee) in
[https://github.com/stretchr/testify/pull/1481](https://redirect.github.com/stretchr/testify/pull/1481)
- mock: simplify implementation of FunctionalOptions by
[@&#8203;dolmen](https://redirect.github.com/dolmen) in
[https://github.com/stretchr/testify/pull/1571](https://redirect.github.com/stretchr/testify/pull/1571)
- mock: caller information for unexpected method call by
[@&#8203;spirin](https://redirect.github.com/spirin) in
[https://github.com/stretchr/testify/pull/1644](https://redirect.github.com/stretchr/testify/pull/1644)
- suite: fix test failures by
[@&#8203;stevenh](https://redirect.github.com/stevenh) in
[https://github.com/stretchr/testify/pull/1421](https://redirect.github.com/stretchr/testify/pull/1421)
- Fix issue
[#&#8203;1662](https://redirect.github.com/stretchr/testify/issues/1662)
(comparing infs should fail) by
[@&#8203;ybrustin](https://redirect.github.com/ybrustin) in
[https://github.com/stretchr/testify/pull/1663](https://redirect.github.com/stretchr/testify/pull/1663)
- NotSame should fail if args are not pointers
[#&#8203;1661](https://redirect.github.com/stretchr/testify/issues/1661)
by [@&#8203;sikehish](https://redirect.github.com/sikehish) in
[https://github.com/stretchr/testify/pull/1664](https://redirect.github.com/stretchr/testify/pull/1664)
- Increase timeouts in Test_Mock_Called_blocks to reduce flakiness in CI
by [@&#8203;sikehish](https://redirect.github.com/sikehish) in
[https://github.com/stretchr/testify/pull/1667](https://redirect.github.com/stretchr/testify/pull/1667)
- fix: compare functional option names for indirect calls by
[@&#8203;arjun-1](https://redirect.github.com/arjun-1) in
[https://github.com/stretchr/testify/pull/1626](https://redirect.github.com/stretchr/testify/pull/1626)

##### Documantation, Build & CI

- .gitignore: ignore "go test -c" binaries by
[@&#8203;dolmen](https://redirect.github.com/dolmen) in
[https://github.com/stretchr/testify/pull/1565](https://redirect.github.com/stretchr/testify/pull/1565)
- mock: improve doc by
[@&#8203;dolmen](https://redirect.github.com/dolmen) in
[https://github.com/stretchr/testify/pull/1570](https://redirect.github.com/stretchr/testify/pull/1570)
- mock: fix FunctionalOptions docs by
[@&#8203;snirye](https://redirect.github.com/snirye) in
[https://github.com/stretchr/testify/pull/1433](https://redirect.github.com/stretchr/testify/pull/1433)
- README: link out to the excellent testifylint by
[@&#8203;brackendawson](https://redirect.github.com/brackendawson) in
[https://github.com/stretchr/testify/pull/1568](https://redirect.github.com/stretchr/testify/pull/1568)
- assert: fix typo in comment by
[@&#8203;JohnEndson](https://redirect.github.com/JohnEndson) in
[https://github.com/stretchr/testify/pull/1580](https://redirect.github.com/stretchr/testify/pull/1580)
- Correct the EventuallyWithT and EventuallyWithTf example by
[@&#8203;JonCrowther](https://redirect.github.com/JonCrowther) in
[https://github.com/stretchr/testify/pull/1588](https://redirect.github.com/stretchr/testify/pull/1588)
- CI: bump softprops/action-gh-release from 1 to 2 by
[@&#8203;dependabot](https://redirect.github.com/dependabot) in
[https://github.com/stretchr/testify/pull/1575](https://redirect.github.com/stretchr/testify/pull/1575)
- mock: document more alternatives to deprecated AnythingOfTypeArgument
by [@&#8203;dolmen](https://redirect.github.com/dolmen) in
[https://github.com/stretchr/testify/pull/1569](https://redirect.github.com/stretchr/testify/pull/1569)
- assert: Correctly document EqualValues behavior by
[@&#8203;brackendawson](https://redirect.github.com/brackendawson) in
[https://github.com/stretchr/testify/pull/1593](https://redirect.github.com/stretchr/testify/pull/1593)
- fix: grammar in godoc by
[@&#8203;miparnisari](https://redirect.github.com/miparnisari) in
[https://github.com/stretchr/testify/pull/1607](https://redirect.github.com/stretchr/testify/pull/1607)
- .github/workflows: Run tests for Go 1.22 by
[@&#8203;HaraldNordgren](https://redirect.github.com/HaraldNordgren) in
[https://github.com/stretchr/testify/pull/1629](https://redirect.github.com/stretchr/testify/pull/1629)
- Document suite's lack of support for t.Parallel by
[@&#8203;brackendawson](https://redirect.github.com/brackendawson) in
[https://github.com/stretchr/testify/pull/1645](https://redirect.github.com/stretchr/testify/pull/1645)
- assert: fix typos in comments by
[@&#8203;alexandear](https://redirect.github.com/alexandear) in
[https://github.com/stretchr/testify/pull/1650](https://redirect.github.com/stretchr/testify/pull/1650)
- mock: fix doc comment for NotBefore by
[@&#8203;alexandear](https://redirect.github.com/alexandear) in
[https://github.com/stretchr/testify/pull/1651](https://redirect.github.com/stretchr/testify/pull/1651)
- Generate better comments for require package by
[@&#8203;Neokil](https://redirect.github.com/Neokil) in
[https://github.com/stretchr/testify/pull/1610](https://redirect.github.com/stretchr/testify/pull/1610)
- README: replace Testify V2 notice with
[@&#8203;dolmen](https://redirect.github.com/dolmen)'s V2 manifesto by
[@&#8203;hendrywiranto](https://redirect.github.com/hendrywiranto) in
[https://github.com/stretchr/testify/pull/1518](https://redirect.github.com/stretchr/testify/pull/1518)

#### New Contributors

- [@&#8203;fahimbagar](https://redirect.github.com/fahimbagar) made
their first contribution in
[https://github.com/stretchr/testify/pull/1337](https://redirect.github.com/stretchr/testify/pull/1337)
- [@&#8203;TomWright](https://redirect.github.com/TomWright) made their
first contribution in
[https://github.com/stretchr/testify/pull/820](https://redirect.github.com/stretchr/testify/pull/820)
- [@&#8203;snirye](https://redirect.github.com/snirye) made their first
contribution in
[https://github.com/stretchr/testify/pull/1433](https://redirect.github.com/stretchr/testify/pull/1433)
- [@&#8203;myxo](https://redirect.github.com/myxo) made their first
contribution in
[https://github.com/stretchr/testify/pull/1582](https://redirect.github.com/stretchr/testify/pull/1582)
- [@&#8203;JohnEndson](https://redirect.github.com/JohnEndson) made
their first contribution in
[https://github.com/stretchr/testify/pull/1580](https://redirect.github.com/stretchr/testify/pull/1580)
- [@&#8203;JonCrowther](https://redirect.github.com/JonCrowther) made
their first contribution in
[https://github.com/stretchr/testify/pull/1588](https://redirect.github.com/stretchr/testify/pull/1588)
- [@&#8203;miparnisari](https://redirect.github.com/miparnisari) made
their first contribution in
[https://github.com/stretchr/testify/pull/1607](https://redirect.github.com/stretchr/testify/pull/1607)
- [@&#8203;marshall-lee](https://redirect.github.com/marshall-lee) made
their first contribution in
[https://github.com/stretchr/testify/pull/1481](https://redirect.github.com/stretchr/testify/pull/1481)
- [@&#8203;spirin](https://redirect.github.com/spirin) made their first
contribution in
[https://github.com/stretchr/testify/pull/1644](https://redirect.github.com/stretchr/testify/pull/1644)
- [@&#8203;ReyOrtiz](https://redirect.github.com/ReyOrtiz) made their
first contribution in
[https://github.com/stretchr/testify/pull/1637](https://redirect.github.com/stretchr/testify/pull/1637)
- [@&#8203;stevenh](https://redirect.github.com/stevenh) made their
first contribution in
[https://github.com/stretchr/testify/pull/1421](https://redirect.github.com/stretchr/testify/pull/1421)
- [@&#8203;jayd3e](https://redirect.github.com/jayd3e) made their first
contribution in
[https://github.com/stretchr/testify/pull/1636](https://redirect.github.com/stretchr/testify/pull/1636)
- [@&#8203;Neokil](https://redirect.github.com/Neokil) made their first
contribution in
[https://github.com/stretchr/testify/pull/1610](https://redirect.github.com/stretchr/testify/pull/1610)
- [@&#8203;redachl](https://redirect.github.com/redachl) made their
first contribution in
[https://github.com/stretchr/testify/pull/1586](https://redirect.github.com/stretchr/testify/pull/1586)
- [@&#8203;ybrustin](https://redirect.github.com/ybrustin) made their
first contribution in
[https://github.com/stretchr/testify/pull/1663](https://redirect.github.com/stretchr/testify/pull/1663)
- [@&#8203;sikehish](https://redirect.github.com/sikehish) made their
first contribution in
[https://github.com/stretchr/testify/pull/1664](https://redirect.github.com/stretchr/testify/pull/1664)
- [@&#8203;arjun-1](https://redirect.github.com/arjun-1) made their
first contribution in
[https://github.com/stretchr/testify/pull/1626](https://redirect.github.com/stretchr/testify/pull/1626)

**Full Changelog**:
https://github.com/stretchr/testify/compare/v1.9.0...v1.10.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 becomes conflicted, 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:eyJjcmVhdGVkSW5WZXIiOiIzOS4xOS4wIiwidXBkYXRlZEluVmVyIjoiMzkuMTkuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <codingalias@gmail.com>
2024-11-23 07:49:00 -08:00
Tyler Yahn
99c3c661e0
Use auto-instrumentation SDK in global tracing (#5920)
When the auto-instrumentation attaches to a process using the global
TracerProvider, and there has not been a delegate set, create a span
from the go.opentelemetry.io/auto/sdk package so the OTel Go
auto-instrumentation can instrument the application by default.

Resolve #5702

### Benchmarks

```terminal
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/internal/global
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                    │   old.txt    │            new.txt             │
                    │    sec/op    │    sec/op     vs base          │
StartEndSpanNoSDK-8   244.2n ± 21%   250.2n ± 23%  ~ (p=0.739 n=10)
```
2024-11-21 10:54:58 -08:00
Matthieu MOREL
74937a2952
[chore]: enable all rules of perfsprint (#5978)
#### Description

[perfsprint](https://github.com/catenacyber/perfsprint) is a linter for
performance, aiming at usages of fmt.Sprintf which have faster
alternatives.

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-18 10:04:50 +01:00
Matthieu MOREL
61e9b35139
[chore]: enable int-conversion rule of perfsprint (#5964)
[perfsprint](https://github.com/catenacyber/perfsprint) is a linter for
performance, aiming at usages of fmt.Sprintf which have faster
alternatives.

This PR enables int-conversion rule

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-14 19:17:37 +01:00
Damien Mathieu
2c15a77942
Fix lint issues for golangci-lint 1.62.0 (#5967)
This fixes the new lint issues brough by the golangci-lint upgrade in
https://github.com/open-telemetry/opentelemetry-go/pull/5966
2024-11-13 08:58:59 +01:00
Robert Pająk
7cfbd86a60
Release v1.32.0/v0.54.0/v0.8.0/v0.0.11 (#5960)
### Added

- Add `go.opentelemetry.io/otel/sdk/metric/exemplar.AlwaysOffFilter`,
which can be used to disable exemplar recording. (#5850)
- Add `go.opentelemetry.io/otel/sdk/metric.WithExemplarFilter`, which
can be used to configure the exemplar filter used by the metrics SDK.
(#5850)
- Add `ExemplarReservoirProviderSelector` and
`DefaultExemplarReservoirProviderSelector` to
`go.opentelemetry.io/otel/sdk/metric`, which defines the exemplar
reservoir to use based on the aggregation of the metric. (#5861)
- Add `ExemplarReservoirProviderSelector` to
`go.opentelemetry.io/otel/sdk/metric.Stream` to allow using views to
configure the exemplar reservoir to use for a metric. (#5861)
- Add `ReservoirProvider`, `HistogramReservoirProvider` and
`FixedSizeReservoirProvider` to
`go.opentelemetry.io/otel/sdk/metric/exemplar` to make it convenient to
use providers of Reservoirs. (#5861)
- The `go.opentelemetry.io/otel/semconv/v1.27.0` package.
The package contains semantic conventions from the `v1.27.0` version of
the OpenTelemetry Semantic Conventions. (#5894)
- Add `Attributes attribute.Set` field to `Scope` in
`go.opentelemetry.io/otel/sdk/instrumentation`. (#5903)
- Add `Attributes attribute.Set` field to `ScopeRecords` in
`go.opentelemetry.io/otel/log/logtest`. (#5927)
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` adds
instrumentation scope attributes. (#5934)
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp` adds
instrumentation scope attributes. (#5934)
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`
adds instrumentation scope attributes. (#5935)
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`
adds instrumentation scope attributes. (#5935)
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` adds
instrumentation scope attributes. (#5933)
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp` adds
instrumentation scope attributes. (#5933)
- `go.opentelemetry.io/otel/exporters/prometheus` adds instrumentation
scope attributes in `otel_scope_info` metric as labels. (#5932)

### Changed

- Support scope attributes and make them as identifying for `Tracer` in
`go.opentelemetry.io/otel` and `go.opentelemetry.io/otel/sdk/trace`.
(#5924)
- Support scope attributes and make them as identifying for `Meter` in
`go.opentelemetry.io/otel` and `go.opentelemetry.io/otel/sdk/metric`.
(#5926)
- Support scope attributes and make them as identifying for `Logger` in
`go.opentelemetry.io/otel` and `go.opentelemetry.io/otel/sdk/log`.
(#5925)
- Make schema URL and scope attributes as identifying for `Tracer` in
`go.opentelemetry.io/otel/bridge/opentracing`. (#5931)
- Clear unneeded slice elements to allow GC to collect the objects in
`go.opentelemetry.io/otel/sdk/metric` and
`go.opentelemetry.io/otel/sdk/trace`. (#5804)

### Fixed

- Global MeterProvider registration unwraps global instrument Observers,
the undocumented Unwrap() methods are now private. (#5881)
- `go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`
now keeps the metadata already present in the context when `WithHeaders`
is used. (#5892)
- `go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc` now
keeps the metadata already present in the context when `WithHeaders` is
used. (#5911)
- `go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc` now
keeps the metadata already present in the context when `WithHeaders` is
used. (#5915)
- Fix `go.opentelemetry.io/otel/exporters/prometheus` trying to add
exemplars to Gauge metrics, which is unsupported. (#5912)
- Fix `WithEndpointURL` to always use a secure connection when an https
URL is passed in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc`.
(#5944)
- Fix `WithEndpointURL` to always use a secure connection when an https
URL is passed in
`go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp`.
(#5944)
- Fix `WithEndpointURL` to always use a secure connection when an https
URL is passed in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc`.
(#5944)
- Fix `WithEndpointURL` to always use a secure connection when an https
URL is passed in
`go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp`.
(#5944)
- Fix incorrect metrics generated from callbacks when multiple readers
are used in `go.opentelemetry.io/otel/sdk/metric`. (#5900)

### Removed

- Remove all examples under `go.opentelemetry.io/otel/example` as they
are moved to [Contrib
repository](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/examples).
(#5930)
2024-11-08 18:52:26 +01:00
renovate[bot]
ef12bf858d
chore(deps): update golang.org/x (#5957)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| golang.org/x/sys | `v0.26.0` -> `v0.27.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fsys/v0.27.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2fsys/v0.27.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2fsys/v0.26.0/v0.27.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fsys/v0.26.0/v0.27.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/text | `v0.19.0` -> `v0.20.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2ftext/v0.20.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2ftext/v0.20.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2ftext/v0.19.0/v0.20.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2ftext/v0.19.0/v0.20.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzOS43LjEiLCJ1cGRhdGVkSW5WZXIiOiIzOS43LjEiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbIlNraXAgQ2hhbmdlbG9nIiwiZGVwZW5kZW5jaWVzIl19-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-08 09:18:44 +01:00
Mikhail Mazurskiy
85eb76f2fd
Allow GC to collect unneeded slice elements (#5804)
```go
type interInst struct {
	x int
}

type inter interface {
}

var sink []inter

func BenchmarkX(b *testing.B) {
	sink = make([]inter, b.N)
	for i := 0; i < b.N; i++ {
		sink[i] = &interInst{}
	}
	clear(sink)
	sink = sink[:0]
	runtime.GC()
	var ms runtime.MemStats
	runtime.ReadMemStats(&ms)
	b.Log(b.N, ms.Frees) // Frees is the cumulative count of heap objects freed.
}
```

```
clear:
    ioz_test.go:35: 1 589
    ioz_test.go:35: 100 711
    ioz_test.go:35: 10000 10729
    ioz_test.go:35: 1000000 1010750  <-- 1m+ freed
    ioz_test.go:35: 16076874 17087643
    ioz_test.go:35: 19514749 36602412
```
```
no clear:
    ioz_test.go:35: 1 585
    ioz_test.go:35: 100 606
    ioz_test.go:35: 10000 725
    ioz_test.go:35: 1000000 10745  <-- some "overhead" objects freed, not the slice.
    ioz_test.go:35: 16391445 1010765
    ioz_test.go:35: 21765238 17402230
```

This is documented at https://go.dev/wiki/SliceTricks:

> NOTE If the type of the element is a pointer or a struct with pointer
fields, which need to be garbage collected, the above implementations of
Cut and Delete have a potential memory leak problem: some elements with
values are still referenced by slice a’s underlying array, just not
“visible” in the slice. Because the “deleted” value is referenced in the
underlying array, the deleted value is still “reachable” during GC, even
though the value cannot be referenced by your code. If the underlying
array is long-lived, this represents a leak.

Followed by examples of how zeroing out the slice elements solves
the problem. This PR does the same.
2024-11-08 07:36:35 +01:00
pree-dew
1492efa719
Fix incorrect metrics getting generated from multiple readers (#5900)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/5866

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-11-08 07:29:38 +01:00
Alex Boten
fb2b32bb1b
docs: updating outdated comments (#5940)
Found some comments that reference WithoutBuiltin that was removed some
time ago, and being able to pass in a parameter into WithTelemetrySDK
which is not valid.

Signed-off-by: Alex Boten <223565+codeboten@users.noreply.github.com>
2024-11-04 09:17:24 +01:00
Robert Pająk
6a2f7de06d
Make scope attributes as identifying for Logger (#5925)
Towards https://github.com/open-telemetry/opentelemetry-go/issues/3368
2024-10-30 06:34:24 +01:00
Robert Pająk
ee56fb97e0
Make scope attributes as identifying for Meter (#5926)
Towards https://github.com/open-telemetry/opentelemetry-go/issues/3368
2024-10-30 06:29:32 +01:00
Robert Pająk
3742c54497
Make scope attributes as identifying for Tracer (#5924)
Towards https://github.com/open-telemetry/opentelemetry-go/issues/3368
2024-10-30 06:24:32 +01:00
Robert Pająk
30c0f3fa6e
sdk/instrumentation: Add Attributes to Scope (#5903)
Towards https://github.com/open-telemetry/opentelemetry-go/issues/3368
2024-10-29 13:47:14 +01:00
Sam Xie
3429e15b9a
Revert Cleanup interaction of exemplar and aggregation (#5913)
Topic: #5249

This reverts commit 8041156518 (PR: #5899)
due to the performance degradation found by Benchmarks CI
https://github.com/open-telemetry/opentelemetry-go/actions/runs/11447364022/job/31848519243

Here is the benchmark test on my machine:

```
goos: darwin
goarch: arm64
pkg: go.opentelemetry.io/otel/sdk/metric
                                       │   old.txt   │                new.txt                 │
                                       │   sec/op    │    sec/op     vs base                  │
Instrument/instrumentImpl/aggregate-10   3.378µ ± 3%   49.366µ ± 1%  +1361.40% (p=0.000 n=10)
Instrument/observable/observe-10         2.288µ ± 2%   37.791µ ± 1%  +1551.73% (p=0.000 n=10)
geomean                                  2.780µ         43.19µ       +1453.65%

                                       │   old.txt    │                 new.txt                 │
                                       │     B/op     │     B/op       vs base                  │
Instrument/instrumentImpl/aggregate-10   1.245Ki ± 1%   22.363Ki ± 0%  +1696.08% (p=0.000 n=10)
Instrument/observable/observe-10           823.0 ± 1%    17432.5 ± 0%  +2018.17% (p=0.000 n=10)
geomean                                  1.000Ki         19.51Ki       +1850.48%

                                       │  old.txt   │                new.txt                │
                                       │ allocs/op  │  allocs/op   vs base                  │
Instrument/instrumentImpl/aggregate-10   1.000 ± 0%   21.000 ± 0%  +2000.00% (p=0.000 n=10)
Instrument/observable/observe-10         1.000 ± 0%   16.000 ± 0%  +1500.00% (p=0.000 n=10)
```
2024-10-23 10:48:07 -07:00
Tyler Yahn
92ccad7bd9
[chore] Use errors.Join to unify errors (#5907)
Resolve #3544

Replace all custom implementations for multi-error unification with the
`errors.Join` function of the standard library.
2024-10-22 15:10:05 -07:00
David Ashpole
8041156518
Cleanup interaction of exemplar and aggregation (#5899)
Follow-up to
https://github.com/open-telemetry/opentelemetry-go/pull/5861. This is an
attempt to:

* Limit the API surface of the aggregate package
* Try to use predefined types (e.g. exemplar.Filter) over custom
functions where possible.
* Avoid using nil, and use No-Ops where it makes sense

This makes `aggregate.NewFilteredExemplarReservoir` no longer exported,
removes the `aggregate.FilteredExemplarReservoir` interface, and removes
the `aggregate.dropReservoir`.
2024-10-21 15:37:32 -04:00
Joshua MacDonald
2578accaa8
otel: conceal unwrapping for global async instrument registration (#5881)
~Two defects are fixed here. However, note that async instrument
delegation appears to have been broken a long time.~

Internalizes and tests the behavior of the Global MeterProvider. This
moves the call to `Unwrap()` out of the SDK, fully concealing it within
the internal/global package (using an un-exported method).

This adds a test for the new functionality. While this test is not
comprehensive, because it doesn't test every instrument variation, it
explicitly tests that both the NewCallback function and the Observe
functions receive objects constructed by the alternate SDK.

Fixes #5827

---------

Co-authored-by: David Ashpole <dashpole@google.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-10-18 10:36:05 -07:00
David Ashpole
81b2a33e1b
Add selector of exemplar reservoir providers to metric.Stream configuration (#5861)
Resolve https://github.com/open-telemetry/opentelemetry-go/issues/5249

### Spec

> exemplar_reservoir: A functional type that generates an exemplar
reservoir a MeterProvider will use when storing exemplars. This
functional type needs to be a factory or callback similar to aggregation
selection functionality which allows different reservoirs to be chosen
by the aggregation.

> Users can provide an exemplar_reservoir, but it is up to their
discretion. Therefore, the stream configuration parameter needs to be
structured to accept an exemplar_reservoir, but MUST NOT obligate a user
to provide one. If the user does not provide an exemplar_reservoir
value, the MeterProvider MUST apply a [default exemplar
reservoir](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#exemplar-defaults).

Also,

> the reservoir MUST be given the Attributes associated with its
timeseries point either at construction so that additional sampling
performed by the reservoir has access to all attributes from a
measurement in the "offer" method.

### Changes

In sdk/metric/exemplar, add:
* `exemplar.ReservoirProvider`
* `exemplar.HistogramReservoirProvider`
* `exemplar.FixedSizeReservoirProvider`

In sdk/metric, add:
* `metric.ExemplarReservoirProviderSelector` (func Aggregation ->
ReservoirProvider)
* `metric.DefaultExemplarReservoirProviderSelector` (our default
implementation)
* `ExemplarReservoirProviderSelector` added to `metric.Stream`

Note: the only required public types are
`metric.ExemplarReservoirProviderSelector` and
`ExemplarReservoirProviderSelector` in `metric.Stream`. Others are for
convenience and readability.

### Alternatives considered

#### Add ExemplarReservoirProvider directly to metric.Stream, instead of
ExemplarReservoirProviderSelector

This would mean users can configure a `func() exemplar.Reservoir`
instead of a `func(Aggregation) func() exemplar.Reservoir`.

I don't think this complies with the statement: `This functional type
needs to be a factory or callback similar to aggregation selection
functionality which allows different reservoirs to be chosen by the
aggregation.`. I'm interpreting "allows different reservoirs to be
chosen by the aggregation" as meaning "allows different reservoirs to be
chosen **based on the** aggregation", rather than meaning that the
aggregation is somehow choosing the reservoir.

### Future work

There is some refactoring I plan to do after this to simplify the
interaction between the internal/aggregate and exemplar package. I've
omitted that from this PR to keep the diff smaller.

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-10-18 09:05:10 -04:00
David Ashpole
6b251b804c
Allow configuring the exemplar filter on the metrics SDK (#5850)
Part of https://github.com/open-telemetry/opentelemetry-go/issues/5249

### Spec

https://opentelemetry.io/docs/specs/otel/metrics/sdk/#exemplarfilter

> The ExemplarFilter configuration MUST allow users to select between
one of the built-in ExemplarFilters. While ExemplarFilter determines
which measurements are eligible for becoming an Exemplar, the
ExemplarReservoir makes the final decision if a measurement becomes an
exemplar and is stored.

> The ExemplarFilter SHOULD be a configuration parameter of a
MeterProvider for an SDK. The default value SHOULD be TraceBased. The
filter configuration SHOULD follow the [environment variable
specification](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#exemplar).

> An OpenTelemetry SDK MUST support the following filters:

> *
[AlwaysOn](https://opentelemetry.io/docs/specs/otel/metrics/sdk/#alwayson)
> *
[AlwaysOff](https://opentelemetry.io/docs/specs/otel/metrics/sdk/#alwaysoff)
> *
[TraceBased](https://opentelemetry.io/docs/specs/otel/metrics/sdk/#tracebased)

### Changes

* adds exemplar.AlwaysOffFilter, which is one of the required filters
from the SDK:
https://opentelemetry.io/docs/specs/otel/metrics/sdk/#alwaysoff
* adds `metric.WithExemplarFilter` as an option for the metrics SDK.
* moves handling of `OTEL_METRICS_EXEMPLAR_FILTER` to the same location
as config handling to make code easier to navigate.



dropReservoir can actually be removed, but I plan to do that in a
follow-up refactor, since it will be a large diff.

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Chester Cheung <cheung.zhy.csu@gmail.com>
2024-10-11 16:02:20 -04:00
David Ashpole
bc2fe88756
Release v1.31.0/v0.53.0/v0.7.0/v0.0.10 (#5883)
### Added

- Add `go.opentelemetry.io/otel/sdk/metric/exemplar` package which
includes `Exemplar`, `Filter`, `TraceBasedFilter`, `AlwaysOnFilter`,
`HistogramReservoir`, `FixedSizeReservoir`, `Reservoir`, `Value` and
`ValueType` types. These will be used for configuring the exemplar
reservoir for the metrics sdk. (#5747, #5862)
- Add `WithExportBufferSize` option to log batch processor.(#5877)

### Changed

- Enable exemplars by default in `go.opentelemetry.io/otel/sdk/metric`.
Exemplars can be disabled by setting
`OTEL_METRICS_EXEMPLAR_FILTER=always_off` (#5778)
- `Logger.Enabled` in `go.opentelemetry.io/otel/log` now accepts a newly
introduced `EnabledParameters` type instead of `Record`. (#5791)
- `FilterProcessor.Enabled` in
`go.opentelemetry.io/otel/sdk/log/internal/x` now accepts
`EnabledParameters` instead of `Record`. (#5791)
- The `Record` type in `go.opentelemetry.io/otel/log` is no longer
comparable. (#5847)
- Performance improvements for the trace SDK `SetAttributes` method in
`Span`. (#5864)
- Reduce memory allocations for the `Event` and `Link` lists in `Span`.
(#5858)
- Performance improvements for the trace SDK `AddEvent`, `AddLink`,
`RecordError` and `End` methods in `Span`. (#5874)

### Deprecated

- Deprecate all examples under `go.opentelemetry.io/otel/example` as
they are moved to [Contrib
repository](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/examples).
(#5854)

### Fixed

- The race condition for multiple `FixedSize` exemplar reservoirs
identified in #5814 is resolved. (#5819)
- Fix log records duplication in case of heterogeneous resource
attributes by correctly mapping each log record to it's resource and
scope. (#5803)
- Fix timer channel drain to avoid hanging on Go 1.23. (#5868)
- Fix delegation for global meter providers, and panic when calling
otel.SetMeterProvider. (#5827)
- Change the `reflect.TypeOf` to use a nil pointer to not allocate on
the heap unless necessary. (#5827)
2024-10-11 12:59:27 -04:00
Murphy Chen
a7d5c1aef7
Add an option to configure the exporter buffer of the BatchProcessor (#5877)
resolve: https://github.com/open-telemetry/opentelemetry-go/issues/5238

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-10 01:16:46 -07:00
Warnar Boekkooi
64416533d5
Performance improvements for the trace SDK in Span. (#5874)
Good day,
Thanks for review this PR!
This PR follows from
https://github.com/open-telemetry/opentelemetry-go/pull/5864 and avoid
multiple locks in `End`, `RecordError`, `AddEvent` and `AddLink`.

Benchstats result are:
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz
           │ event-3cbd9671.txt │        event-pr-e9744b48.txt        │
           │       sec/op       │                 │
SpanEnd-12          63.07n ± 1%   53.63n ± 1%  -14.97% (p=0.000 n=10)

           │ event-3cbd9671.txt │     event-pr-e9744b48.txt      │
           │        B/op        │    B/op     vs base            │
SpanEnd-12           0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

           │ event-3cbd9671.txt │     event-pr-e9744b48.txt      │
           │     allocs/op      │ allocs/op   vs base            │
SpanEnd-12           0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

```

---------

Co-authored-by: David Ashpole <dashpole@google.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-09 09:51:17 +02:00
Warnar Boekkooi
8fbaa97084
Reduce newEvictedQueueLink and newEvictedQueueEvent memory allocations (#5858)
Good day,

While doing some profile with pprof on one of our services I notices
that `sync.OnceFunc` was allocating a nice amount of objects. These
`sync.OnceFunc` calls where done by `newEvictedQueueEvent` and
`newEvictedQueueLink`.

So to avoid these extra allocation I created this PR which replaces the
`sync.OnceFunc` with `sync.Once` which is now part of the evictedQueue.
This resulted in the following benchstat result (commit
baad07e574):
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: 11th Gen Intel(R) Core(TM) i5-11400H @ 2.70GHz
                                              │ 1727937489-attr-old.txt │        evic-new1728018933.txt        │
                                              │         sec/op          │    sec/op     vs base                │
RecordingSpanSetAttributes/WithLimit/false-12              6.579µ ±  9%   5.875µ ±  8%  -10.71% (p=0.000 n=10)
RecordingSpanSetAttributes/WithLimit/true-12               14.27µ ± 10%   11.82µ ± 16%  -17.18% (p=0.009 n=10)
SpanEnd-12                                                 63.44n ±  0%   75.97n ±  2%  +19.75% (p=0.000 n=10)
TraceStart/with_a_simple_span-12                           728.0n ±  3%   412.7n ±  1%  -43.31% (p=0.000 n=10)
TraceStart/with_several_links-12                           881.5n ±  1%   553.2n ±  3%  -37.25% (p=0.000 n=10)
TraceStart/with_attributes-12                              916.5n ±  2%   598.4n ±  2%  -34.70% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_10-12                 151.9n ±  3%   144.1n ±  3%   -5.13% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_10,_spans:_100-12                1.497µ ±  2%   1.435µ ±  2%   -4.14% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_100,_spans:_10-12                148.5n ±  2%   143.0n ±  2%   -3.67% (p=0.000 n=10)
SpanProcessorOnEnd/batch:_100,_spans:_100-12               1.481µ ±  3%   1.442µ ±  4%   -2.67% (p=0.022 n=10)
SpanProcessorVerboseLogging-12                             9.376µ ±  1%   6.662µ ±  2%  -28.94% (p=0.000 n=10)
SpanLimits/AttributeValueLengthLimit-12                    7.221µ ±  4%   6.605µ ±  3%   -8.54% (p=0.002 n=10)
SpanLimits/AttributeCountLimit-12                          6.300µ ±  6%   6.091µ ±  6%   -3.30% (p=0.007 n=10)
SpanLimits/EventCountLimit-12                              5.921µ ±  4%   5.506µ ±  7%   -7.02% (p=0.011 n=10)
SpanLimits/LinkCountLimit-12                               6.073µ ±  6%   5.423µ ±  3%  -10.71% (p=0.000 n=10)
SpanLimits/AttributePerEventCountLimit-12                  6.455µ ±  3%   5.294µ ±  9%  -17.98% (p=0.000 n=10)
SpanLimits/AttributePerLinkCountLimit-12                   6.263µ ±  4%   5.850µ ±  7%   -6.59% (p=0.000 n=10)
SpanSetAttributesOverCapacity-12                           1.683µ ±  1%   1.391µ ±  0%  -17.35% (p=0.000 n=10)
StartEndSpan/AlwaysSample-12                               803.0n ±  4%   531.4n ±  5%  -33.82% (p=0.000 n=10)
StartEndSpan/NeverSample-12                                216.0n ±  2%   212.7n ±  2%        ~ (p=0.055 n=10)
SpanWithAttributes_4/AlwaysSample-12                      1216.5n ±  2%   877.6n ±  9%  -27.85% (p=0.000 n=10)
SpanWithAttributes_4/NeverSample-12                        370.4n ±  5%   374.5n ±  3%        ~ (p=0.197 n=10)
SpanWithAttributes_8/AlwaysSample-12                       1.494µ ±  4%   1.117µ ±  4%  -25.27% (p=0.000 n=10)
SpanWithAttributes_8/NeverSample-12                        477.1n ±  3%   475.1n ±  7%        ~ (p=0.739 n=10)
SpanWithAttributes_all/AlwaysSample-12                    1310.5n ±  5%   971.5n ±  6%  -25.87% (p=0.000 n=10)
SpanWithAttributes_all/NeverSample-12                      388.0n ±  5%   389.1n ±  6%        ~ (p=0.699 n=10)
SpanWithAttributes_all_2x/AlwaysSample-12                  1.664µ ±  2%   1.236µ ±  3%  -25.72% (p=0.000 n=10)
SpanWithAttributes_all_2x/NeverSample-12                   522.7n ±  7%   527.2n ±  9%        ~ (p=0.912 n=10)
SpanWithEvents_4/AlwaysSample-12                           1.411µ ±  4%   1.058µ ±  2%  -24.99% (p=0.000 n=10)
SpanWithEvents_4/NeverSample-12                            218.4n ±  3%   218.9n ±  2%        ~ (p=0.971 n=10)
SpanWithEvents_8/AlwaysSample-12                           1.997µ ±  5%   1.657µ ±  4%  -17.03% (p=0.000 n=10)
SpanWithEvents_8/NeverSample-12                            226.6n ±  3%   221.7n ±  2%   -2.14% (p=0.015 n=10)
SpanWithEvents_WithStackTrace/AlwaysSample-12             1016.5n ±  2%   712.5n ±  2%  -29.91% (p=0.000 n=10)
SpanWithEvents_WithStackTrace/NeverSample-12               242.0n ±  3%   241.0n ±  1%        ~ (p=0.254 n=10)
SpanWithEvents_WithTimestamp/AlwaysSample-12              1019.5n ±  3%   713.2n ±  6%  -30.04% (p=0.000 n=10)
SpanWithEvents_WithTimestamp/NeverSample-12                276.4n ±  3%   276.6n ±  2%        ~ (p=0.723 n=10)
TraceID_DotString-12                                       71.94n ±  3%   75.71n ±  3%   +5.23% (p=0.001 n=10)
SpanID_DotString-12                                        50.88n ±  3%   52.35n ±  1%   +2.88% (p=0.001 n=10)
geomean                                                    952.8n         822.2n        -13.71%

                                              │ 1727937489-attr-old.txt │         evic-new1728018933.txt         │
                                              │          B/op           │     B/op      vs base                  │
RecordingSpanSetAttributes/WithLimit/false-12            7.062Ki ± 0%     6.891Ki ± 0%   -2.43% (p=0.000 n=10)
RecordingSpanSetAttributes/WithLimit/true-12             7.564Ki ± 0%     7.393Ki ± 0%   -2.27% (p=0.000 n=10)
SpanEnd-12                                                 0.000 ± 0%       0.000 ± 0%        ~ (p=1.000 n=10) ¹
TraceStart/with_a_simple_span-12                           704.0 ± 0%       528.0 ± 0%  -25.00% (p=0.000 n=10)
TraceStart/with_several_links-12                           880.0 ± 0%       704.0 ± 0%  -20.00% (p=0.000 n=10)
TraceStart/with_attributes-12                              960.0 ± 0%       784.0 ± 0%  -18.33% (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                          10.938Ki ± 0%     9.219Ki ± 0%  -15.71% (p=0.000 n=10)
SpanLimits/AttributeValueLengthLimit-12                  10.76Ki ± 0%     10.59Ki ± 0%   -1.60% (p=0.000 n=10)
SpanLimits/AttributeCountLimit-12                       10.016Ki ± 0%     9.844Ki ± 0%   -1.72% (p=0.000 n=10)
SpanLimits/EventCountLimit-12                            9.594Ki ± 0%     9.422Ki ± 0%   -1.79% (p=0.000 n=10)
SpanLimits/LinkCountLimit-12                             9.203Ki ± 0%     9.031Ki ± 0%   -1.87% (p=0.000 n=10)
SpanLimits/AttributePerEventCountLimit-12                10.64Ki ± 0%     10.47Ki ± 0%   -1.62% (p=0.000 n=10)
SpanLimits/AttributePerLinkCountLimit-12                 10.64Ki ± 0%     10.47Ki ± 0%   -1.62% (p=0.000 n=10)
SpanSetAttributesOverCapacity-12                           768.0 ± 0%       592.0 ± 0%  -22.92% (p=0.000 n=10)
StartEndSpan/AlwaysSample-12                               704.0 ± 0%       528.0 ± 0%  -25.00% (p=0.000 n=10)
StartEndSpan/NeverSample-12                                144.0 ± 0%       144.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_4/AlwaysSample-12                     1.188Ki ± 0%     1.016Ki ± 0%  -14.47% (p=0.000 n=10)
SpanWithAttributes_4/NeverSample-12                        400.0 ± 0%       400.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_8/AlwaysSample-12                     1.688Ki ± 0%     1.516Ki ± 0%  -10.19% (p=0.000 n=10)
SpanWithAttributes_8/NeverSample-12                        656.0 ± 0%       656.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_all/AlwaysSample-12                   1.312Ki ± 0%     1.141Ki ± 0%  -13.10% (p=0.000 n=10)
SpanWithAttributes_all/NeverSample-12                      464.0 ± 0%       464.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_all_2x/AlwaysSample-12                2.062Ki ± 0%     1.891Ki ± 0%   -8.33% (p=0.000 n=10)
SpanWithAttributes_all_2x/NeverSample-12                   848.0 ± 0%       848.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_4/AlwaysSample-12                         1.188Ki ± 0%     1.016Ki ± 0%  -14.47% (p=0.000 n=10)
SpanWithEvents_4/NeverSample-12                            144.0 ± 0%       144.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_8/AlwaysSample-12                         1.812Ki ± 0%     1.641Ki ± 0%   -9.48% (p=0.000 n=10)
SpanWithEvents_8/NeverSample-12                            144.0 ± 0%       144.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_WithStackTrace/AlwaysSample-12              800.0 ± 0%       624.0 ± 0%  -22.00% (p=0.000 n=10)
SpanWithEvents_WithStackTrace/NeverSample-12               160.0 ± 0%       160.0 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_WithTimestamp/AlwaysSample-12               824.0 ± 0%       648.0 ± 0%  -21.36% (p=0.000 n=10)
SpanWithEvents_WithTimestamp/NeverSample-12                184.0 ± 0%       184.0 ± 0%        ~ (p=1.000 n=10) ¹
TraceID_DotString-12                                       64.00 ± 0%       64.00 ± 0%        ~ (p=1.000 n=10) ¹
SpanID_DotString-12                                        32.00 ± 0%       32.00 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                                               ²                  -7.15%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                              │ 1727937489-attr-old.txt │        evic-new1728018933.txt        │
                                              │        allocs/op        │ allocs/op   vs base                  │
RecordingSpanSetAttributes/WithLimit/false-12             15.000 ± 0%     3.000 ± 0%  -80.00% (p=0.000 n=10)
RecordingSpanSetAttributes/WithLimit/true-12              20.000 ± 0%     8.000 ± 0%  -60.00% (p=0.000 n=10)
SpanEnd-12                                                 0.000 ± 0%     0.000 ± 0%        ~ (p=1.000 n=10) ¹
TraceStart/with_a_simple_span-12                          14.000 ± 0%     2.000 ± 0%  -85.71% (p=0.000 n=10)
TraceStart/with_several_links-12                          15.000 ± 0%     3.000 ± 0%  -80.00% (p=0.000 n=10)
TraceStart/with_attributes-12                             16.000 ± 0%     4.000 ± 0%  -75.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                            155.00 ± 0%     35.00 ± 0%  -77.42% (p=0.000 n=10)
SpanLimits/AttributeValueLengthLimit-12                    54.00 ± 0%     42.00 ± 0%  -22.22% (p=0.000 n=10)
SpanLimits/AttributeCountLimit-12                          50.00 ± 0%     38.00 ± 0%  -24.00% (p=0.000 n=10)
SpanLimits/EventCountLimit-12                              47.00 ± 0%     35.00 ± 0%  -25.53% (p=0.000 n=10)
SpanLimits/LinkCountLimit-12                               47.00 ± 0%     35.00 ± 0%  -25.53% (p=0.000 n=10)
SpanLimits/AttributePerEventCountLimit-12                  50.00 ± 0%     38.00 ± 0%  -24.00% (p=0.000 n=10)
SpanLimits/AttributePerLinkCountLimit-12                   50.00 ± 0%     38.00 ± 0%  -24.00% (p=0.000 n=10)
SpanSetAttributesOverCapacity-12                          15.000 ± 0%     3.000 ± 0%  -80.00% (p=0.000 n=10)
StartEndSpan/AlwaysSample-12                              14.000 ± 0%     2.000 ± 0%  -85.71% (p=0.000 n=10)
StartEndSpan/NeverSample-12                                2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_4/AlwaysSample-12                      16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithAttributes_4/NeverSample-12                        3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_8/AlwaysSample-12                      16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithAttributes_8/NeverSample-12                        3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_all/AlwaysSample-12                    16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithAttributes_all/NeverSample-12                      3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithAttributes_all_2x/AlwaysSample-12                 16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithAttributes_all_2x/NeverSample-12                   3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_4/AlwaysSample-12                          17.000 ± 0%     5.000 ± 0%  -70.59% (p=0.000 n=10)
SpanWithEvents_4/NeverSample-12                            2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_8/AlwaysSample-12                          18.000 ± 0%     6.000 ± 0%  -66.67% (p=0.000 n=10)
SpanWithEvents_8/NeverSample-12                            2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_WithStackTrace/AlwaysSample-12             16.000 ± 0%     4.000 ± 0%  -75.00% (p=0.000 n=10)
SpanWithEvents_WithStackTrace/NeverSample-12               3.000 ± 0%     3.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanWithEvents_WithTimestamp/AlwaysSample-12              17.000 ± 0%     5.000 ± 0%  -70.59% (p=0.000 n=10)
SpanWithEvents_WithTimestamp/NeverSample-12                4.000 ± 0%     4.000 ± 0%        ~ (p=1.000 n=10) ¹
TraceID_DotString-12                                       2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
SpanID_DotString-12                                        2.000 ± 0%     2.000 ± 0%        ~ (p=1.000 n=10) ¹
geomean                                                               ²               -47.73%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean
```

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-10-08 09:43:14 +02:00
Warnar Boekkooi
3cbd967152
Performance improvements for recordingSpan SetAttributes and addOverCapAttrs (#5864)
Good day,

While working on
https://github.com/open-telemetry/opentelemetry-go/pull/5858 I found
some other possible improvements.

This PR:
- Adds an early return to `SetAttributes` when no attributes are
provided.
- Only increases `s.attributes` to guarantee that there is enough space
for elements to be added.
- Fixes and issue where `truncateAttr` was not used when a attribute was
being updated in `addOverCapAttrs`.

Thanks for reviewing and please let me know if any changes are needed.

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-07 09:30:29 +02:00
renovate[bot]
9e791a62ba
fix(deps): update golang.org/x (#5872)
This PR contains the following updates:

| Package | Type | Update | Change | Age | Adoption | Passing |
Confidence |
|---|---|---|---|---|---|---|---|
| golang.org/x/exp | require | digest | `701f63a` -> `225e2ab` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fexp/v0.0.0-20241004190924-225e2abe05e6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2fexp/v0.0.0-20241004190924-225e2abe05e6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2fexp/v0.0.0-20240909161429-701f63a606c0/v0.0.0-20241004190924-225e2abe05e6?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-20240909161429-701f63a606c0/v0.0.0-20241004190924-225e2abe05e6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/net | indirect | minor | `v0.29.0` -> `v0.30.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fnet/v0.30.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2fnet/v0.30.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2fnet/v0.29.0/v0.30.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fnet/v0.29.0/v0.30.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/sys | indirect | minor | `v0.25.0` -> `v0.26.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fsys/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2fsys/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2fsys/v0.25.0/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fsys/v0.25.0/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/sys | require | minor | `v0.25.0` -> `v0.26.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2fsys/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2fsys/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2fsys/v0.25.0/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2fsys/v0.25.0/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/text | indirect | minor | `v0.18.0` -> `v0.19.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2ftext/v0.19.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2ftext/v0.19.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2ftext/v0.18.0/v0.19.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2ftext/v0.18.0/v0.19.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| golang.org/x/tools | require | minor | `v0.25.0` -> `v0.26.0` |
[![age](https://developer.mend.io/api/mc/badges/age/go/golang.org%2fx%2ftools/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/golang.org%2fx%2ftools/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/golang.org%2fx%2ftools/v0.25.0/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/golang.org%2fx%2ftools/v0.25.0/v0.26.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzOC45Ny4wIiwidXBkYXRlZEluVmVyIjoiMzguOTcuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-07 09:13:11 +02:00
Jesse Bank
1333b2f73a
Fix delegation for global MeterProviders (#5828)
Fixes #5827
Fixes #5852

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: David Ashpole <dashpole@google.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-04 10:19:41 +02:00
Danny Shemesh
19877b1654
Fix timer channel drain to avoid hanging in Go 1.23 (#5869)
- Fix timer channel drain to avoid hanging in go1.23 w/ asynctimerchan=0
(https://github.com/open-telemetry/opentelemetry-go/issues/5868)

---------

Co-authored-by: Robert Pająk <pellared@hotmail.com>
Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-10-04 09:48:57 +02:00
Robert Pająk
3da26f0e00
[doc] sdk/log: Do not create instances of Record (#5871)
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/5823
2024-10-04 07:00:21 +02:00
David Ashpole
be328ac923
Rename SampledFilter to TraceBasedFilter (#5862)
The specification calls this filter "TraceBased":
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/metrics/sdk.md#tracebased

I don't have a huge preference between the two, but lean towards
TraceBasedFilter to match the specification, and to match our
environment variable configuration (and probably the future file
configuration).

This PR must be merged or closed prior to the v1.31 release, since we
can't change it after the release.

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-10-02 12:54:01 -04:00
Matthieu MOREL
469f3d7e87
[chore]: enable negative-positive rule from testifylint (#5849)
Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[negative-positive](https://github.com/Antonboom/testifylint?tab=readme-ov-file#negative-positive)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-30 08:44:52 +02:00
David Ashpole
481f4983f7
Move exemplar types to non-internal package (#5747)
Part of https://github.com/open-telemetry/opentelemetry-go/issues/5249

This makes all existing types designed to implement the public Exemplar
API public by moving most of `internal/exemplar` to `exemplar`. The only
types that are not being made public are `exemplar.Drop`, and
`exemplar.FilteredReservoir`. Those types are moved to
`internal/aggregate`, and are renamed to `DropReservoir` and
`FilteredExemplarReservoir`.

The following types are made public:

* `exemplar.Exemplar`
* `exemplar.Filter`
* `exemplar.SampledFilter`
* `exemplar.AlwaysOnFilter`
* `exemplar.HistogramReservoir`
* `exemplar.FixedSizeReservoir`
* `exemplar.Reservoir`
* `exemplar.Value`
* `exemplar.ValueType`
2024-09-26 13:25:05 -07:00
Matthieu MOREL
6edc7a63df
[chore]: enable expected-actual rule from testifylint (#5848)
Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[expected-actual](https://github.com/Antonboom/testifylint?tab=readme-ov-file#expected-actual)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-26 12:04:33 +02:00
Matthieu MOREL
d284a86fa5
[chore]: enable error-nil rule from testifylint (#5843)
Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[error-nil](https://github.com/Antonboom/testifylint?tab=readme-ov-file#error-nil)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Co-authored-by: Robert Pająk <pellared@hotmail.com>
2024-09-25 11:07:59 +02:00
Matthieu MOREL
62cc0c7441
[chore]: enable error-is-as rule from testifylint (#5836)
Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[error-is-as](https://github.com/Antonboom/testifylint?tab=readme-ov-file#error-is-as)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-24 19:17:16 +02:00
Matthieu MOREL
561bd49e6c
[chore]: enable suite-extra-assert-call rule from testifylint (#5833)
#### Description

Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[suite-extra-assert-call](https://github.com/Antonboom/testifylint?tab=readme-ov-file#suite-extra-assert-call)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-23 08:56:45 +02:00
Matthieu MOREL
063239fa37
[chore]: enable len and empty rules from testifylint (#5832)
#### Description

Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[empty](https://github.com/Antonboom/testifylint?tab=readme-ov-file#empty)
and
[len](https://github.com/Antonboom/testifylint?tab=readme-ov-file#len)
rules from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-09-21 08:04:28 -07:00
Tyler Yahn
42fd8fe325
Move global random number generator to randRes field (#5819)
Instead of using a global random number generator for all `randRes`,
have each value use its own. This removes the need for locking and
managing concurrent safe access to the global. Also, the field, given
the `Reservoir` type is not concurrent safe and the metric pipeline
guards this, does not need a `sync.Mutex` to guard it.

Supersedes https://github.com/open-telemetry/opentelemetry-go/pull/5815 
Fix #5814

### Performance Analysis

This change has approximately equivalent performance as the existing
code based on existing benchmarks.

```terminal
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/metric
cpu: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
                           │   old.txt   │              new.txt               │
                           │   sec/op    │   sec/op     vs base               │
Exemplars/Int64Counter/8-8   14.00µ ± 3%   13.44µ ± 4%  -3.98% (p=0.001 n=10)

                           │   old.txt    │             new.txt              │
                           │     B/op     │     B/op      vs base            │
Exemplars/Int64Counter/8-8   3.791Ki ± 0%   3.791Ki ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

                           │  old.txt   │            new.txt             │
                           │ allocs/op  │ allocs/op   vs base            │
Exemplars/Int64Counter/8-8   84.00 ± 0%   84.00 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal
```
2024-09-16 07:31:15 -07:00
Damien Mathieu
a3c512aa95
Fix gosec overflow alerts (#5799)
To allow the golangci-lint upgrade in #5796.

---------

Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com>
2024-09-13 09:11:50 +02:00