Skip to content
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

Add telemetry to logrotate_fs #1083

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lading/src/generator/file_gen/logrotate_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use fuser::{
ReplyDirectory, ReplyEntry, Request,
};
use lading_payload::block;
use metrics::counter;
use nix::libc::{self, ENOENT};
use rand::{rngs::SmallRng, SeedableRng};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -250,6 +251,8 @@ impl Filesystem for LogrotateFS {
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

counter!("fs_lookup").increment(1);

let name_str = name.to_str().unwrap_or("");
if let Some(ino) = state.lookup(tick, parent as usize, name_str) {
if let Some(attr) = getattr_helper(&mut state, self.start_time_system, tick, ino) {
Expand All @@ -270,6 +273,8 @@ impl Filesystem for LogrotateFS {
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

counter!("fs_getattr").increment(1);

if let Some(attr) = getattr_helper(&mut state, self.start_time_system, tick, ino as usize) {
reply.attr(&TTL, &attr);
} else {
Expand All @@ -293,6 +298,8 @@ impl Filesystem for LogrotateFS {
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

counter!("fs_read").increment(1);

// Get the FileHandle from fh
let file_handle = {
let open_files = self.open_files.lock().expect("lock poisoned");
Expand Down Expand Up @@ -329,6 +336,8 @@ impl Filesystem for LogrotateFS {
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

counter!("fs_release").increment(1);

// Remove the FileHandle from the mapping
let file_handle = {
let mut open_files = self.open_files.lock().expect("lock poisoned");
Expand All @@ -350,6 +359,8 @@ impl Filesystem for LogrotateFS {
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

counter!("fs_readdir").increment(1);

let root_inode = state.root_inode();
let mut entry_offset = 0;

Expand Down Expand Up @@ -410,6 +421,8 @@ impl Filesystem for LogrotateFS {
let mut state = self.state.lock().expect("lock poisoned");
state.advance_time(tick);

counter!("fs_open").increment(1);

if let Some(file_handle) = state.open_file(tick, ino as usize) {
let fh = file_handle.id();
{
Expand Down
2 changes: 2 additions & 0 deletions lading/src/generator/file_gen/logrotate_fs/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,7 @@ impl State {
let (remove_current, next_peer) = match node {
Node::File { file } => {
file.incr_ordinal();
counter!("log_file_rotated").increment(1);

let remove_current = file.ordinal() > self.max_rotations;
(remove_current, file.peer)
Expand Down Expand Up @@ -712,6 +713,7 @@ 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);
counter!("log_file_deleted").increment(1);
counter!("lost_bytes").increment(lost_bytes);
}
}
Expand Down
Loading