-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
ref: Introduce a SessionFlusher #279
Conversation
The flusher maintains a queue that is flushed every minute. Sessions are batched into Envelopes at this point, but in the future might be pre-aggregated.
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.
This looks good, thanks!
One overall suggestion: Instead of always waiting for the flush interval, could we flush as soon as we reach the maximum item count?
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.
I'm realizing one more thing, although this is probably fine: Even if the application is idle or does not log any sessions, your background thread runs once every minute to check an empty queue. Since it is only once per minute, this is not that big of a deal.
The ideal solution would probably be to stop spinning if the queue is empty and wait for a CondVar which is triggered by the enqueue
code. Since there's little benefit to this, I'm fine with keeping it this way.
sentry-core/src/session.rs
Outdated
queue.len() >= MAX_SESSION_ITEMS | ||
}; | ||
if flush_immediately { | ||
SessionFlusher::flush(&self.queue, &self.transport); |
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.
This is potentially racy. Between checking the queue length and calling flush
, another thread could enqueue and flush, or a flush could happen.
To avoid this, consider keeping the lock and passing a lock guard into flush
.
* master: (59 commits) fix: Correctly apply environment from env (#293) fix: Make Rust 1.48 clippy happy (#294) docs: Document integrations and the Hub better (#291) ref: Remove deprecated error-chain and failure crates (#290) release: 0.21.0 meta: Update Changelog feat: End sessions with explicit status (#289) fix: Scope transaction name can be overriden in sentry-actix (#287) fix: sentry-actix should not capture client errors (#286) fix: Clean up sentry-actix toml (#285) ref: Remove empty integrations (#283) feat: Add support for actix-web 3 (#282) feat: Preliminary work to integrate Performance Monitoring (#276) ref: Introduce a SessionFlusher (#279) fix: Set a default environment based on debug_assertions (#280) ref: Rearchitect the log and slog Integrations (#268) ref: Deprecate public fields on Integrations (#267) ci: Make testfast actually fast (#273) fix: Update surf and unbreak CI (#274) ci: Use smarter cache action (#272) ...
The flusher maintains a queue that is flushed every minute.
Sessions are batched into Envelopes at this point, but in the future
might be pre-aggregated.