-
Notifications
You must be signed in to change notification settings - Fork 541
feat: Leverage Suppression Context in Sdk #2868
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 16 commits into
open-telemetry:main
from
cijothomas:cijothomas/suppress-sdk
Mar 28, 2025
Merged
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2440573
feat: Leverage Suppression Context in Sdk
cijothomas 52604ef
Check suppression during sampling
cijothomas 5ca9ef6
add comment
cijothomas cc2f09f
remove unwanted comment
cijothomas 3b8929f
add test
cijothomas 06e69dc
review comments, move test to sdk itself
cijothomas 8a19bf3
move to tracer
cijothomas fe04128
changelog pr links
cijothomas bf29dfb
fix fmt
cijothomas 4d79c1c
Merge branch 'main' into cijothomas/suppress-sdk
cijothomas ac3b61a
better comment to reflect current state
cijothomas 002ce8b
Apply suggestions from code review
cijothomas df06287
Merge branch 'main' into cijothomas/suppress-sdk
cijothomas fad8c5d
pR comment
cijothomas 3d23694
Merge branch 'main' into cijothomas/suppress-sdk
cijothomas 668ca50
Merge branch 'main' into cijothomas/suppress-sdk
cijothomas 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 |
---|---|---|
|
@@ -285,8 +285,8 @@ mod tests { | |
use opentelemetry::logs::Severity; | ||
use opentelemetry::trace::TracerProvider; | ||
use opentelemetry::trace::{TraceContextExt, TraceFlags, Tracer}; | ||
use opentelemetry::InstrumentationScope; | ||
use opentelemetry::{logs::AnyValue, Key}; | ||
use opentelemetry::{Context, InstrumentationScope}; | ||
use opentelemetry_sdk::error::{OTelSdkError, OTelSdkResult}; | ||
use opentelemetry_sdk::logs::{InMemoryLogExporter, LogProcessor}; | ||
use opentelemetry_sdk::logs::{LogBatch, LogExporter}; | ||
|
@@ -319,25 +319,26 @@ mod tests { | |
|
||
impl LogExporter for ReentrantLogExporter { | ||
async fn export(&self, _batch: LogBatch<'_>) -> OTelSdkResult { | ||
// This will cause a deadlock as the export itself creates a log | ||
let _suppress = Context::enter_telemetry_suppressed_scope(); | ||
scottgerring marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Without the suppression above, this will cause a deadlock as the export itself creates a log | ||
// while still within the lock of the SimpleLogProcessor. | ||
warn!(name: "my-event-name", target: "reentrant", event_id = 20, user_name = "otel", user_email = "[email protected]"); | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[test] | ||
#[ignore = "See issue: https://github.com/open-telemetry/opentelemetry-rust/issues/1745"] | ||
#[ignore = "While this test runs fine, this uses global subscriber and does not play well with other tests and hence ignored in CI."] | ||
cijothomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fn simple_processor_deadlock() { | ||
// TODO: This test maybe better suited in the opentelemetry-sdk crate tests | ||
let exporter: ReentrantLogExporter = ReentrantLogExporter; | ||
let logger_provider = SdkLoggerProvider::builder() | ||
.with_simple_exporter(exporter.clone()) | ||
.with_simple_exporter(exporter) | ||
.build(); | ||
|
||
let layer = layer::OpenTelemetryTracingBridge::new(&logger_provider); | ||
|
||
// Setting subscriber as global as that is the only way to test this scenario. | ||
tracing_subscriber::registry().with(layer).init(); | ||
|
||
warn!(name: "my-event-name", target: "my-system", event_id = 20, user_name = "otel", user_email = "[email protected]"); | ||
} | ||
|
||
|
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.