Skip to content

Use BatchStreamProcessor for console writer #52

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

friendlymatthew
Copy link
Member

This commit replaces SimpleSpanProcessor with BatchSpanProcessor for console span exporting.

Today, the SimpleSpanProcessor exports spans synchronously on the current thread, which can cause deadlocks in async contexts:

Screenshot 2025-05-29 at 12 33 27 PM

BatchStreamProcessor runs on a dedicated thread and avoids this issue (see open-telemetry/opentelemetry-rust#868). It is configured here to process spans immediately (scheduled_delay = 0).

@friendlymatthew friendlymatthew force-pushed the friendlymatthew/use-batch-stream-processor-console-writer branch from f9d14b8 to 2dacc47 Compare May 29, 2025 20:04
@friendlymatthew
Copy link
Member Author

Snapshot tests fail not because the spans are incorrect, but rather they are out of order from the expected. I'm assuming this is because we process spans by batch.

I don't think the orders matter here, so I'll update the snapshots accordingly.

@davidhewitt
Copy link
Contributor

Hmm, I think the order is quite important (especially for single-threaded code) - it would be presumably quite confusing as a developer if prints got mixed up.

I wonder if this means a custom processor sending data over a channel is a better solution than reusing the batch processor.

@adriangb
Copy link
Member

adriangb commented Jun 6, 2025

Right it sounds to me like what we need is BackgroundThreadProcessor which wraps another processor.

The SimpleSpanProcessor is by it's name supposed to be as simple as possible but that means it doesn't do basic things like pushing work into a background thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

combination of export + console breaks tokio sleep
3 participants