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
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
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
Tyler Yahn
97e2244e5b
[chore]: Clean-up unused obsScopeName const ( #7408 )
2025-09-24 13:33:39 -07: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
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
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
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
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
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
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
Bryan Boreham
8b17b897d2
sdk/trace: More trace id tests ( #7155 )
...
* Check that IDs round-trip between binary and hex string formats.
`TestIDsRoundTrip` is patterned after `TestNewIDs`.
* Check that bad values give the expected errors.
* Use larger values in `TestWithIDGenerator`. Previously, nearly all the
bits were zero so a mistake in encoding/decoding higher bits could be
missed.
Start with arbitrary values with more bits set.
(Span ID still has top half as zero due to taking an uint64)
* Modify `testIDGenerator` so this ^^ change runs on 32-bit platforms.
The idea for more tests arose while considering #6791 .
Does not need a CHANGELOG entry - test only.
---------
Signed-off-by: Bryan Boreham <bjboreham@gmail.com >
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2025-08-21 09:23:32 -07:00
Tyler Yahn
bb5b0a8e61
Use t.Cleanup instead of defer in sdk/trace ( #7208 )
...
Let the testing system ensure proper cleanup ordering and execution. Do
not wait to function return to run all the `defer`s from the loops.
2025-08-18 12:42:16 +02:00
Tyler Yahn
bb8d6f74b0
Fix callbackAttributesOpt variable name ( #7210 )
2025-08-18 11:46:16 +02:00
Tyler Yahn
e39a02f568
Fix minor grammatical error in sdk/trace/internal/x README.md ( #7211 )
2025-08-18 10:44:47 +02:00
Tyler Yahn
150f6b4dbc
Flatten tracer.initSelfObservability into TracerProvider.Tracer ( #7205 )
...
- Do not use [side-effect
programming](https://en.wikipedia.org/wiki/Side_effect_(computer_science) )
to setup a `tracer`. Make the setup explicit, unique, and local.
- Add the `newInst` function to ensure DRY and scope instrument creation
2025-08-18 10:37:38 +02:00
Tyler Yahn
9488493043
sdk/trace: do not defer if not self-observing ( #7206 )
...
Allow branch prediction to help avoid tail function call instead of the
other way around.
2025-08-18 10:25:36 +02:00
David Ashpole
fcc3417677
sdk/trace: self-observability: batch span processor metrics ( #6393 )
...
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7005
Adds `otel.sdk.processor.span.queue.size`,
`otel.sdk.processor.span.queue.capacity`, and
`otel.sdk.processor.span.processed.count` metrics to the trace batch
span processor.
These are defined in
cb11bb9bac/docs/otel/sdk-metrics.md ,
and are experimental. Because of this, metrics are behind the
OTEL_GO_X_SELF_OBSERVABILITY feature gate.
Given the feature is experimental, it always uses the global
meterprovider when enabled.
---------
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2025-08-11 16:15:00 -04:00
Matthieu MOREL
68841fa6db
chore: enable unused-receiver rule from revive ( #7130 )
...
#### Description
Enable and fixes
[unused-receiver](https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-receiver )
rule from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com >
2025-08-08 15:38:22 -07:00
Matthieu MOREL
d464abf1f3
chore: enable unused-parameter rule from revive ( #7122 )
...
#### Description
Enable and fixes
[unused-parameter](https://github.com/mgechev/revive/blob/HEAD/RULES_DESCRIPTIONS.md#unused-parameter )
rule from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com >
2025-08-04 12:48:04 -07:00
Matthieu MOREL
1bae8f7347
chore: enable extra-rules from gofumpt ( #7114 )
...
#### Description
Enable extra rules from
[gofumpt](https://golangci-lint.run/usage/formatters/#gofumpt ) that also
fixes paramTypeCombine from go-critic
Also defines `go.opentelemetry.io/otel` as in
https://github.com/open-telemetry/opentelemetry-go-contrib/pull/7637
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com >
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2025-08-03 08:24:33 -07:00
Robert Pająk
30a00f2103
Fix names in experimental readmes ( #7106 )
2025-07-30 15:51:06 +02:00
Matthieu MOREL
982391315f
chore: enable gocritic linter ( #7095 )
...
#### Description
Enable and fixes several rules from
[gocritic](https://golangci-lint.run/usage/linters/#gocritic ) linter
---------
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com >
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2025-07-29 09:20:32 -07:00
Mikhail Mazurskiy
5e1c62a2d5
Modernize ( #7089 )
...
Use
https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/modernize
to update code to new style.
---------
Co-authored-by: Flc゛ <four_leaf_clover@foxmail.com >
Co-authored-by: Damien Mathieu <42@dmathieu.com >
2025-07-29 10:19:11 +02:00
Robert Pająk
1737ab8666
docs: unify doc comments for functions returning bool ( #7064 )
...
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7063
If also fixes Go Doc comment for `SpanID.IsEmpty`.
The pattern is based on the way the Go standard library documents
functions returning a boolean.
2025-07-23 07:58:50 +02:00
Robert Pająk
186def7c56
sdk/trace: self-observability: span metrics ( #7027 )
...
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/7003
Implement following self-observability metrics from
https://github.com/open-telemetry/semantic-conventions/blob/v1.36.0/docs/otel/sdk-metrics.md
for https://pkg.go.dev/go.opentelemetry.io/otel/sdk/trace :
- `otel.sdk.span.live`
- `otel.sdk.span.started`
2025-07-22 11:36:06 +02:00
Robert Pająk
a6782b9ca9
sdk/trace: remove unused version function ( #7036 )
...
The unexported `version()` function in `sdk/trace` is not used anywhere.
Not mentioning that the value it is returning is wrong.
There is already a `Version` function in `sdk` (which is in the same Go
module).
2025-07-16 20:24:48 +02:00
Corentin
86640ceae0
Clarify DefaultMaxQueueSize and DefaultScheduleDelay usage ( #6974 )
...
### Description
OpenTelemetry uses `DefaultScheduleDelay` and `DefaultExportTimeout`
values as milliseconds but Go time package will understand them as
nanoseconds.
I understand that this is a stable library and that those value will
probably never change, so can we at least clarify their usage?
Right above the defaults declaration it says `// Defaults for
BatchSpanProcessorOptions.` which is confusing.
We used `trace.DefaultScheduleDelay` as a fallback value for our tracing
setup.
This confusion led to high CPU usage due to the frequent batch exports.
### Confusing behavior
```go
processor := trace.NewBatchSpanProcessor(exporter,
// set timeout to 5000 ns instead of the expected 5000 ms
trace.WithBatchTimeout(trace.DefaultScheduleDelay),
// set timeout to 30000 ns instead of the expected 30000 ms
trace.WithExportTimeout(trace.DefaultExportTimeout),
)
```
### Correct way to use those values
```go
processor := trace.NewBatchSpanProcessor(exporter,
trace.WithBatchTimeout(trace.DefaultScheduleDelay * time.Millisecond),
trace.WithExportTimeout(trace.DefaultExportTimeout * time.Millisecond),
)
```
---------
Co-authored-by: Damien Mathieu <42@dmathieu.com >
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2025-07-09 11:18:17 +02:00
Sebastiaan van Stijn
78f873f083
sdk/trace: ReadOnlySpan.InstrumentationLibrary: fix deprecation comment ( #6960 )
...
Commit 575e1bb270 deprecated the Library
type in favor of Scope, but did not add an empty line before the
deprecation comment. Go's formatting rules require an empty line;
omitting the empty line can cause some tools to not detect the
deprecation.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl >
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2025-07-03 14:48:26 +02:00
Damien Mathieu
351a51f1ed
Use existing schema URLs in tests ( #6924 )
...
The 1.2.0 schema URL isn't avaibable (anymore?). So link checks are
failing.
This upgrades the schema URLs to 1.21.0.
See
https://cloud-native.slack.com/archives/C02UN96HZH6/p1750664367346769
---------
Co-authored-by: Robert Pająk <pellared@hotmail.com >
2025-06-24 09:02:21 +02:00
Joe Stephenson
94ab03f569
Remove internal matchers ( #6907 )
...
Modifies the only remaining use of the internal matchers to use
`require` and closes #6541
2025-06-17 16:49:22 +02:00
Sam Xie
a4055c21bc
Use the cause of the context error in OTLP retry ( #6898 )
...
Part of #6588
For a demo code like this
```go
package main
import (
"context"
"fmt"
"log"
"time"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace"
"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
func main() {
ctx := context.Background()
exp, err := newExporter(ctx)
if err != nil {
log.Fatalf("failed to initialize trace exporter: %v", err)
}
tp, err := newTracerProvider(exp)
if err != nil {
log.Fatalf("failed to initialize trace provider: %v", err)
}
defer func() { _ = tp.Shutdown(ctx) }()
otel.SetTracerProvider(tp)
generateSpan()
select {}
}
func generateSpan() {
log.Println("Generating a dummy span")
_, span := otel.Tracer("").Start(context.Background(), "dummy")
defer span.End()
}
func newTracerProvider(exp sdktrace.SpanExporter) (*sdktrace.TracerProvider, error) {
return sdktrace.NewTracerProvider(
sdktrace.WithBatcher(exp),
), nil
}
func newExporter(ctx context.Context) (*otlptrace.Exporter, error) {
traceExporter, err := otlptrace.New(
ctx,
otlptracegrpc.NewClient(
otlptracegrpc.WithEndpoint("127.0.0.1:4317"),
otlptracegrpc.WithInsecure(),
otlptracegrpc.WithRetry(otlptracegrpc.RetryConfig{
Enabled: true,
InitialInterval: 1 * time.Second,
MaxInterval: 30 * time.Second,
MaxElapsedTime: time.Minute,
}),
),
)
if err != nil {
return nil, fmt.Errorf("failed to create trace exporter: %w", err)
}
return traceExporter, nil
}
```
the error result from
```
traces export: context deadline exceeded: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:4317: connect: connection refused"
```
become
```
traces export: exporter export timeout: rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing: dial tcp 127.0.0.1:4317: connect: connection refused"
```
2025-06-12 19:02:35 +02:00
Tyler Yahn
33eb582188
Upgrade semconv to 1.34.0 in sdk/trace ( #6835 )
2025-05-28 11:10:10 -07:00
Sean Liao
a571c52b0a
all: replace math/rand with math/rand/v2 ( #6732 )
...
Update to new stdlib apis.
The new Float64 is uniform, which resolves a long comment.
https://cs.opensource.google/go/go/+/refs/tags/go1.24.2:src/math/rand/v2/rand.go;l=209
> // There are exactly 1<<53 float64s in [0,1). Use Intn(1<<53) /
(1<<53).
return float64(r.Uint64()<<11>>11) / (1 << 53)
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/sdk/trace
cpu: 12th Gen Intel(R) Core(TM) i7-1260P
│ old.txt │ new.txt │
│ sec/op │ sec/op vs base │
TraceStart/with_a_simple_span-16 387.1n ± 5% 306.8n ± 15% -20.73% (p=0.000 n=10)
TraceStart/with_several_links-16 542.2n ± 5% 501.0n ± 2% -7.61% (p=0.000 n=10)
TraceStart/with_attributes-16 521.4n ± 14% 571.6n ± 6% +9.64% (p=0.009 n=10)
geomean 478.3n 444.6n -7.05%
│ old.txt │ new.txt │
│ B/op │ B/op vs base │
TraceStart/with_a_simple_span-16 528.0 ± 0% 528.0 ± 0% ~ (p=1.000 n=10) ¹
TraceStart/with_several_links-16 704.0 ± 0% 704.0 ± 0% ~ (p=1.000 n=10) ¹
TraceStart/with_attributes-16 784.0 ± 0% 784.0 ± 0% ~ (p=1.000 n=10) ¹
geomean 663.0 663.0 +0.00%
¹ all samples are equal
│ old.txt │ new.txt │
│ allocs/op │ allocs/op vs base │
TraceStart/with_a_simple_span-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
TraceStart/with_several_links-16 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹
TraceStart/with_attributes-16 4.000 ± 0% 4.000 ± 0% ~ (p=1.000 n=10) ¹
geomean 2.884 2.884 +0.00%
¹ all samples are equal
```
---------
Co-authored-by: Robert Pająk <pellared@hotmail.com >
Co-authored-by: Damien Mathieu <42@dmathieu.com >
2025-05-15 09:21:49 +02:00
Zhengke Zhou
a486ca5722
sdk/trace: Move testing harness to trace ( #6589 )
...
Closes : #6543
---------
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2025-04-10 08:59:11 -07:00
Tyler Yahn
7512a2be2e
Add the golines golangci-lint formatter ( #6513 )
...
Ensure consistent line wrapping (<= 120 characters) within the project.
2025-03-30 03:46:44 -07:00
Zhengke Zhou
63f3cfe1b5
sdk/trace: Manage trace environment variables in testing package ( #6552 )
...
Fix : #6542
Co-authored-by: Damien Mathieu <42@dmathieu.com >
2025-03-28 09:45:34 +01:00
renovate[bot]
05de07bcf5
chore(deps): update module github.com/antonboom/testifylint to v1.6.0 ( #6440 )
...
This PR contains the following updates:
| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/Antonboom/testifylint](https://redirect.github.com/Antonboom/testifylint )
| `v1.5.2` -> `v1.6.0` |
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
[](https://docs.renovatebot.com/merge-confidence/ )
|
---
> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.
---
### Release Notes
<details>
<summary>Antonboom/testifylint
(github.com/Antonboom/testifylint)</summary>
###
[`v1.6.0`](https://redirect.github.com/Antonboom/testifylint/releases/tag/v1.6.0 ):
– new `equal-values` and `suite-method-signature`
[Compare
Source](https://redirect.github.com/Antonboom/testifylint/compare/v1.5.2...v1.6.0 )
#### What's Changed
##### New checkers
- new checker `equal-values` by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/223 ](https://redirect.github.com/Antonboom/testifylint/pull/223 )
- new checker `suite-method-signature` by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/228 ](https://redirect.github.com/Antonboom/testifylint/pull/228 )
##### New features
- `len`: support len-len and value-len cases by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/204 ](https://redirect.github.com/Antonboom/testifylint/pull/204 )
- `error-is-as`: support NotErrorAs by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/219 ](https://redirect.github.com/Antonboom/testifylint/pull/219 )
- `useless-assert`: add NotElementsMatch and NotErrorAs by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/220 ](https://redirect.github.com/Antonboom/testifylint/pull/220 )
- `formatter`: support non-string-message checks by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/221 ](https://redirect.github.com/Antonboom/testifylint/pull/221 )
- `formatter`: warn on empty message by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/225 ](https://redirect.github.com/Antonboom/testifylint/pull/225 )
- `empty`: support empty strings, Zero for strings and len + bubbled
useless-assert cases by
[@​ccoVeille](https://redirect.github.com/ccoVeille ) in
[https://github.com/Antonboom/testifylint/pull/129 ](https://redirect.github.com/Antonboom/testifylint/pull/129 )
##### New fixes
- `negative-positive`: remove untyping, ignore Negative for len
comparisons by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/226 ](https://redirect.github.com/Antonboom/testifylint/pull/226 )
- fixes: support `assert.CollectT` by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/233 ](https://redirect.github.com/Antonboom/testifylint/pull/233 )
##### Bump deps
- Upgrade testdata to v1.10.0 of testify by
[@​Antonboom](https://redirect.github.com/Antonboom ) in
[https://github.com/Antonboom/testifylint/pull/218 ](https://redirect.github.com/Antonboom/testifylint/pull/218 )
- Go 1.24 by [@​Antonboom](https://redirect.github.com/Antonboom )
in
[https://github.com/Antonboom/testifylint/pull/234 ](https://redirect.github.com/Antonboom/testifylint/pull/234 )
- build(deps): bump golang.org/x/tools from 0.26.0 to 0.27.0 by
[@​dependabot](https://redirect.github.com/dependabot ) in
[https://github.com/Antonboom/testifylint/pull/206 ](https://redirect.github.com/Antonboom/testifylint/pull/206 )
- build(deps): bump rlespinasse/github-slug-action from 4.4.1 to 5.0.0
by [@​dependabot](https://redirect.github.com/dependabot ) in
[https://github.com/Antonboom/testifylint/pull/207 ](https://redirect.github.com/Antonboom/testifylint/pull/207 )
- build(deps): bump golang.org/x/tools from 0.27.0 to 0.29.0 by
[@​dependabot](https://redirect.github.com/dependabot ) in
[https://github.com/Antonboom/testifylint/pull/214 ](https://redirect.github.com/Antonboom/testifylint/pull/214 )
**Full Changelog**:
https://github.com/Antonboom/testifylint/compare/v1.5.2...v1.6.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:eyJjcmVhdGVkSW5WZXIiOiIzOS4yMDAuMiIsInVwZGF0ZWRJblZlciI6IjM5LjIwMC4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJTa2lwIENoYW5nZWxvZyIsImRlcGVuZGVuY2llcyJdfQ==-->
---------
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
Co-authored-by: Tyler Yahn <codingalias@gmail.com >
2025-03-13 14:31:12 -07:00
David Ashpole
e2aee3aff8
Move trace sdk tests from trace_test into trace package ( #6400 )
...
I would like to be able to use a private option in
https://github.com/open-telemetry/opentelemetry-go/pull/6393 in tests,
and decided to split this refactoring out into its own PR.
This moves the batch span processor benchmarks into benchmark_test.go,
and replaces one instance of the tracetest.NewInMemoryExporter with a
different test exporter implementation. It then moves most unit tests
from `trace_test` to the main `trace` package.
2025-03-04 21:29:11 -05:00
Robert Pająk
9be18c14cb
sdk/trace: Fix gorountine leak in batchSpanProcessor.ForceFlush ( #6369 )
...
Fixes https://github.com/open-telemetry/opentelemetry-go/issues/6360
Per
https://github.com/open-telemetry/opentelemetry-go/issues/6360#issuecomment-2678080742 :
> So I'd fix this issue with the first proposed solution, and open an
issue to change the behavior in a separate PR.
```
$ go test -run=TestBatchSpanProcessorForceFlushTimeout -count=1000
PASS
ok go.opentelemetry.io/otel/sdk/trace 1.701s
$ go test -run=TestBatchSpanProcessorForceFlushTimeout -count=1000 -race
PASS
ok go.opentelemetry.io/otel/sdk/trace 4.056s
```
@peterbourgon, thank you for your contribution 🏅
2025-02-27 11:28:31 +01:00
Robert Pająk
44d50457d9
sdk/trace: Fix goroutine leak in simpleSpanProcessor.Shutdown ( #6368 )
...
Side-effect when working towards
https://github.com/open-telemetry/opentelemetry-go/issues/6360
- Fix goroutine leaks from tests in places where batch processor was not
shut down
- Fix goroutine leak in simpleSpanProcessor.Shutdown
2025-02-26 23:32:15 +01:00
Damien Mathieu
f62232fa1b
Replace tenv with usetesting ( #6313 )
...
The `tenv` linter is deprecated in favor of `usetesting`.
2025-02-13 11:18:37 +01:00
Sam Xie
d46bfb04fe
Fix comment of the RecordOnly sampling decision ( #6257 )
...
Co-authored-by: Tyler Yahn <MrAlias@users.noreply.github.com >
2025-02-06 10:06:15 -08: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