-
Notifications
You must be signed in to change notification settings - Fork 599
Track dropped spans and logs due to full buffer #2357
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
Changes from 3 commits
519555f
6866a90
b626d7f
8aaf156
f1d5142
35614a9
6bf0e73
d2e30cc
eb1f83f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |
| use opentelemetry::logs::Severity; | ||
| use opentelemetry::{otel_debug, otel_error, otel_warn, InstrumentationScope}; | ||
|
|
||
| use std::sync::atomic::AtomicBool; | ||
| use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; | ||
| use std::{cmp::min, env, sync::Mutex}; | ||
| use std::{ | ||
| fmt::{self, Debug, Formatter}, | ||
|
|
@@ -154,6 +154,13 @@ | |
| /// them at a pre-configured interval. | ||
| pub struct BatchLogProcessor<R: RuntimeChannel> { | ||
| message_sender: R::Sender<BatchMessage>, | ||
|
|
||
| // Track dropped logs. We'll log this at shutdown and also emit | ||
| // as a metric. | ||
scottgerring marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| dropped_logs_count: AtomicUsize, | ||
|
|
||
| // Track the maximum queue size that was configured for this processor | ||
| max_queue_size: usize, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. odd that we have to store this here just for logging purposes, but not an issue!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe we can avoid this by moving the logging of dropped logs (otel_warn!) from the shutdown() method to the worker's Shutdown message processing. Also, |
||
| } | ||
|
|
||
| impl<R: RuntimeChannel> Debug for BatchLogProcessor<R> { | ||
|
|
@@ -172,11 +179,13 @@ | |
| ))); | ||
|
|
||
| // TODO - Implement throttling to prevent error flooding when the queue is full or closed. | ||
| if let Err(err) = result { | ||
| otel_error!( | ||
| name: "BatchLogProcessor.Export.Error", | ||
| error = format!("{}", err) | ||
| ); | ||
| if result.is_err() { | ||
cijothomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // Increment dropped logs counter and metric. The first time we have top drop a log, | ||
scottgerring marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // emit a warning. | ||
| if self.dropped_logs_count.fetch_add(1, Ordering::Relaxed) == 0 { | ||
| otel_warn!(name: "BatchLogProcessor.LogDroppingStarted", | ||
| message = "Beginning to drop log messages due to full exporter queue."); | ||
scottgerring marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -192,6 +201,17 @@ | |
| } | ||
|
|
||
| fn shutdown(&self) -> LogResult<()> { | ||
| let dropped_logs = self.dropped_logs_count.load(Ordering::Relaxed); | ||
| let max_queue_size = self.max_queue_size; | ||
| if dropped_logs > 0 { | ||
| otel_warn!( | ||
| name: "BatchLogProcessor.LogsDropped", | ||
| dropped_logs_count = dropped_logs, | ||
| max_queue_size = max_queue_size, | ||
| message = "Logs were dropped due to a full or closed queue. The count represents the total count of lost logs in the lifetime of the BatchLogProcessor. Consider increasing the queue size and/or decrease delay between intervals." | ||
scottgerring marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ); | ||
cijothomas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| let (res_sender, res_receiver) = oneshot::channel(); | ||
| self.message_sender | ||
| .try_send(BatchMessage::Shutdown(res_sender)) | ||
|
|
@@ -215,6 +235,7 @@ | |
| let (message_sender, message_receiver) = | ||
| runtime.batch_message_channel(config.max_queue_size); | ||
| let inner_runtime = runtime.clone(); | ||
| let max_queue_size = config.max_queue_size; | ||
|
|
||
| // Spawn worker process via user-defined spawn function. | ||
| runtime.spawn(Box::pin(async move { | ||
|
|
@@ -296,8 +317,13 @@ | |
| } | ||
| } | ||
| })); | ||
|
|
||
| // Return batch processor with link to worker | ||
| BatchLogProcessor { message_sender } | ||
| BatchLogProcessor { | ||
| message_sender, | ||
| dropped_logs_count: AtomicUsize::new(0), | ||
| max_queue_size, | ||
| } | ||
| } | ||
|
|
||
| /// Create a new batch processor builder | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.