Skip to content

Commit

Permalink
Add more information to lost_bytes telemetry (#1094)
Browse files Browse the repository at this point in the history
* Add more information to lost_bytes telemetry

This commit adds more information to the lost_bytes telemetry, intention
being to make it easier to debug under what conditions bytes are lost.

REF SMPTNG-517

Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>

* add more telemetry to log_file_rotated

Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>

---------

Signed-off-by: Brian L. Troutwine <brian.troutwine@datadoghq.com>
  • Loading branch information
blt authored Nov 6, 2024
1 parent 8c18bb3 commit adf8dd7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lading/src/generator/file_gen/logrotate_fs/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use metrics::counter;
use rand::Rng;
use rustc_hash::FxHashMap;
use std::collections::BTreeSet;
use tracing::info;

/// Time representation of the model
pub(crate) type Tick = u64;
Expand Down Expand Up @@ -661,7 +662,8 @@ impl State {
let (remove_current, next_peer) = match node {
Node::File { file } => {
file.incr_ordinal();
counter!("log_file_rotated").increment(1);
counter!("log_file_rotated", "group_id" => format!("{}", file.group_id))
.increment(1);

let remove_current = file.ordinal() > self.max_rotations;
(remove_current, file.peer)
Expand Down Expand Up @@ -731,8 +733,14 @@ impl State {
for inode in to_remove {
if let Some(Node::File { file }) = self.nodes.remove(&inode) {
let lost_bytes = file.bytes_written.saturating_sub(file.max_offset_observed);
info!("Log file deleted. Total bytes lost: {lost_bytes}. Total bytes written: {bytes_written}. Total bytes read: {bytes_read}. Group ID: {group_id}. Created: {created_tick}.",
group_id = file.group_id,
created_tick = file.created_tick,
bytes_written = file.bytes_written,
bytes_read = file.bytes_read);
counter!("log_file_deleted").increment(1);
counter!("lost_bytes").increment(lost_bytes);
counter!("lost_bytes", "group_id" => format!("{}", file.group_id))
.increment(lost_bytes);
}
}
}
Expand Down

0 comments on commit adf8dd7

Please sign in to comment.