Skip to content

Commit

Permalink
both are full runs so do time per file
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcichra committed Dec 25, 2023
1 parent 90b6aa0 commit 58315f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ use walkdir::WalkDir;
pub mod kubeclient;
pub mod prometheus;

enum RunType {
Full,
Quick,
}

#[derive(Parser, Debug, Clone)]
#[clap(author, version, about, long_about = None)]
struct Args {
Expand Down Expand Up @@ -76,7 +71,7 @@ async fn main() -> Result<()> {
let discovery = Discovery::new(client.clone()).run().await.unwrap();
loop {
info!("starting full run");
match reconcile(&args, &full_path_clone, &client, &discovery, RunType::Full).await {
match reconcile(&args, &full_path_clone, &client, &discovery).await {
Err(e) => {
info!("reconcile error: {:?}", e);
}
Expand All @@ -98,7 +93,7 @@ async fn main() -> Result<()> {
let current_git_link = tokio::fs::read_link(&args.path).await.unwrap();
if last_git_link != current_git_link {
info!("starting quick run");
match reconcile(&args, &full_path, &client, &discovery, RunType::Quick).await {
match reconcile(&args, &full_path, &client, &discovery).await {
Err(e) => {
info!("reconcile error: {:?}", e);
}
Expand All @@ -125,9 +120,7 @@ async fn reconcile(
full_path: &str,
client: &Client,
discovery: &Discovery,
run_type: RunType,
) -> Result<()> {
info!("full path: {}", full_path);
let walker = WalkDir::new(full_path).sort_by_file_name().into_iter();
for entry in walker {
let entry = entry.context("could not unwrap entry")?;
Expand All @@ -142,13 +135,9 @@ async fn reconcile(
kubeclient::apply(client.to_owned(), &discovery, path_str, &args.user_agent).await;
let elapsed = now.elapsed();
let success = &res.is_ok().to_string();
let run_type_string = match run_type {
RunType::Full => "FullRun",
RunType::Quick => "QuickRun",
};

RUN_LATENCY
.with_label_values(&[success, run_type_string])
.with_label_values(&[success, path_str])
.set(elapsed.as_secs_f64());
FILE_APPLY_COUNT
.with_label_values(&[success, path_str])
Expand Down
2 changes: 1 addition & 1 deletion src/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ lazy_static! {
pub static ref RUN_LATENCY: GaugeVec = register_gauge_vec!(
"run_latency_seconds",
"Latency for completed apply runs",
&["success","run_type"]
&["success","file"]
)
.unwrap();
}
Expand Down

0 comments on commit 58315f5

Please sign in to comment.