-
Notifications
You must be signed in to change notification settings - Fork 523
feat: Add Suppression flag to context #2821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
cijothomas
merged 25 commits into
open-telemetry:main
from
cijothomas:cijothomas/context-suppress
Mar 26, 2025
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
361f2cd
feat: Add Suppression flag to context
cijothomas ea670ca
simplif
cijothomas 7e64aa9
nit comment
cijothomas 5f55f42
clippy to simplify
cijothomas 23ce8e3
fix perf
cijothomas 84f3727
inline boost
cijothomas f9678c0
Merge branch 'main' into cijothomas/context-suppress
cijothomas c2714c1
Merge branch 'main' into cijothomas/context-suppress
lalitb a4d8c70
Merge branch 'main' into cijothomas/context-suppress
cijothomas f5ea469
reduce public api
cijothomas f4bb48f
comment on text
cijothomas ba4be0a
clip
cijothomas 32d217c
Merge branch 'main' into cijothomas/context-suppress
cijothomas fb73294
comment
cijothomas 5a29bf5
Merge branch 'main' into cijothomas/context-suppress
cijothomas 9dc674f
fmt and add test expose more methods as required
cijothomas c043437
rename
cijothomas 5ac4cda
fmts
cijothomas b474512
Merge branch 'main' into cijothomas/context-suppress
cijothomas 73518bc
remove dummywor
cijothomas c7ba6a0
Merge branch 'main' into cijothomas/context-suppress
cijothomas 1550d53
improve tests
cijothomas ce59a31
Merge branch 'main' into cijothomas/context-suppress
cijothomas 0148509
Merge branch 'main' into cijothomas/context-suppress
cijothomas e13c2c6
Merge branch 'main' into cijothomas/context-suppress
lalitb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use opentelemetry::Context; | ||
|
||
// Run this benchmark with: | ||
// cargo bench --bench context_suppression | ||
|
||
// The benchmark results: | ||
// criterion = "0.5.1" | ||
// Hardware: Apple M4 Pro | ||
// Total Number of Cores: 14 (10 performance and 4 efficiency) | ||
// | Benchmark | Time | | ||
// |---------------------------------------|--------| | ||
// | enter_telemetry_suppressed_scope | 8.3 ns | | ||
// | normal_attach | 9.1 ns | | ||
// | is_current_telemetry_suppressed_false | 750 ps | | ||
// | is_current_telemetry_suppressed_true | 750 ps | | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("telemetry_suppression"); | ||
|
||
// Benchmark the cost of entering a suppressed scope | ||
group.bench_function("enter_telemetry_suppressed_scope", |b| { | ||
b.iter(|| { | ||
let _guard = black_box(Context::enter_telemetry_suppressed_scope()); | ||
}); | ||
}); | ||
|
||
// For comparison - normal context attach | ||
group.bench_function("normal_attach", |b| { | ||
b.iter(|| { | ||
let _guard = black_box(Context::current().attach()); | ||
}); | ||
}); | ||
|
||
// Benchmark checking if current is suppressed (when not suppressed) | ||
group.bench_function("is_current_telemetry_suppressed_false", |b| { | ||
// Make sure we're in a non-suppressed context | ||
let _restore_ctx = Context::current().attach(); | ||
b.iter(|| { | ||
let is_suppressed = black_box(Context::is_current_telemetry_suppressed()); | ||
black_box(is_suppressed); | ||
}); | ||
}); | ||
|
||
// Benchmark checking if current is suppressed (when suppressed) | ||
group.bench_function("is_current_telemetry_suppressed_true", |b| { | ||
// Enter suppressed context for the duration of the benchmark | ||
let _suppressed_guard = Context::enter_telemetry_suppressed_scope(); | ||
b.iter(|| { | ||
let is_suppressed = black_box(Context::is_current_telemetry_suppressed()); | ||
black_box(is_suppressed); | ||
}); | ||
}); | ||
|
||
group.finish(); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add PR link as well.