Skip to content

Statically define trace observability attributes#7263

Merged
MrAlias merged 4 commits intoopen-telemetry:mainfrom
MrAlias:cache-trace-obs-sets
Aug 29, 2025
Merged

Statically define trace observability attributes#7263
MrAlias merged 4 commits intoopen-telemetry:mainfrom
MrAlias:cache-trace-obs-sets

Conversation

@MrAlias
Copy link
Copy Markdown
Contributor

@MrAlias MrAlias commented Aug 27, 2025

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

$ 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%

@MrAlias MrAlias added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Aug 27, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented Aug 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.9%. Comparing base (be1e57f) to head (2486759).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #7263   +/-   ##
=====================================
  Coverage   82.8%   82.9%           
=====================================
  Files        265     265           
  Lines      24900   24894    -6     
=====================================
- Hits       20641   20638    -3     
+ Misses      3882    3880    -2     
+ Partials     377     376    -1     
Files with missing lines Coverage Δ
sdk/trace/span.go 85.3% <100.0%> (+0.4%) ⬆️
sdk/trace/tracer.go 100.0% <100.0%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.
@MrAlias MrAlias force-pushed the cache-trace-obs-sets branch from 7c5caa4 to 05fd6ee Compare August 27, 2025 20:47
@MrAlias MrAlias marked this pull request as ready for review August 27, 2025 21:04
Copy link
Copy Markdown
Member

@flc1125 flc1125 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Copy Markdown
Member

@pellared pellared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Comment thread sdk/trace/tracer.go
@MrAlias MrAlias mentioned this pull request Aug 28, 2025
@MrAlias MrAlias added this to the v1.38.0 milestone Aug 29, 2025
@MrAlias MrAlias merged commit 9798759 into open-telemetry:main Aug 29, 2025
37 checks passed
@MrAlias MrAlias deleted the cache-trace-obs-sets branch August 29, 2025 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Skip Changelog PRs that do not require a CHANGELOG.md entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants