Skip to content

Commit

Permalink
b64 log; ret if ws fail
Browse files Browse the repository at this point in the history
  • Loading branch information
noisyscanner committed Oct 22, 2024
1 parent 9d1cb7a commit 6f129f5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
13 changes: 10 additions & 3 deletions metrics/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ log = "0.4.16"

reqwest = { version = "0.11", features = ["json"]}

base64 = "0.22.1"
tokio = { version = "1.37", features = ["full"]}
actix-web = "4.0.1"
actix-ws = "0.3.0"
Expand Down
3 changes: 2 additions & 1 deletion metrics/src/logprocessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use log::warn;

use serde::Deserialize;
use serde_json::{from_str, from_value};
use base64::prelude::{Engine as _, BASE64_STANDARD_NO_PAD};
use crate::Telemetry;

use opentelemetry::{
Expand Down Expand Up @@ -220,7 +221,7 @@ pub async fn log_processor(logline: &String, metric_obj: &Telemetry, tracer: &tr
}
Err(e) => {
warn!("Failed to parse log line: {}", e);
warn!("Line was: {}", logline);
warn!("Line was b64: {}", BASE64_STANDARD_NO_PAD.encode(logline));
}
};
}
5 changes: 4 additions & 1 deletion metrics/src/logreceiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ async fn receive_log(
if let Ok(Message::Text(text)) = msg {
let _ = logprocessor::log_processor(&text.trim().to_string(), &metric_obj, &tracer).await;
session.text("{\"success\": true}").await.unwrap();
} else {
// TODO: improve
warn!("Success: false");
session.text("{\"success\": false}").await.unwrap();
}
// TODO: log if failed
}
});

Expand Down

0 comments on commit 6f129f5

Please sign in to comment.