clarify proxy log messages (#520)

This commit is contained in:
bmc-msft
2021-02-08 17:39:26 -05:00
committed by GitHub
parent 8c9f65c0be
commit 5114332ea0
7 changed files with 67 additions and 16 deletions

View File

@ -3,7 +3,7 @@
use crate::proxy;
use anyhow::Result;
use onefuzz_telemetry::{set_appinsights_clients, EventData};
use onefuzz_telemetry::{set_appinsights_clients, EventData, Role};
use reqwest_retry::SendRetry;
use serde::{Deserialize, Serialize};
use std::{fs::File, io::BufReader, path::PathBuf};
@ -78,6 +78,7 @@ impl Config {
onefuzz_telemetry::set_property(EventData::Region(data.region.to_owned()));
onefuzz_telemetry::set_property(EventData::Version(env!("ONEFUZZ_VERSION").to_string()));
onefuzz_telemetry::set_property(EventData::InstanceId(data.instance_id));
onefuzz_telemetry::set_property(EventData::Role(Role::Proxy));
Ok(Self {
config_path,
@ -129,6 +130,7 @@ impl Config {
}
pub async fn notify(&self) -> Result<()> {
info!("notifying service of proxy update");
let client = QueueClient::new(self.data.notification.clone());
client

View File

@ -26,7 +26,7 @@ use tokio::{
const MINIMUM_NOTIFY_INTERVAL: Duration = Duration::from_secs(120);
const POLL_INTERVAL: Duration = Duration::from_secs(5);
async fn run(mut proxy_config: Config) -> Result<()> {
async fn run_loop(mut proxy_config: Config) -> Result<()> {
let mut last_notified = Instant::now();
loop {
info!("checking updates");
@ -41,6 +41,15 @@ async fn run(mut proxy_config: Config) -> Result<()> {
}
}
async fn run(proxy_config: Config) -> Result<()> {
let result = run_loop(proxy_config).await;
if let Err(err) = &result {
error!("run loop failed: {}", err);
}
onefuzz_telemetry::try_flush_and_close();
result
}
fn main() -> Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();