Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
Update appinsights-rs to released version
Browse files Browse the repository at this point in the history
  • Loading branch information
Porges authored Jun 27, 2022
1 parent d61fe48 commit e3452dd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
11 changes: 8 additions & 3 deletions src/agent/Cargo.lock

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

2 changes: 1 addition & 1 deletion src/agent/onefuzz-agent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ fn run(opt: RunOpt) -> Result<()> {
}
}

telemetry::try_flush_and_close();
rt.block_on(telemetry::try_flush_and_close());

result
}
Expand Down
2 changes: 1 addition & 1 deletion src/agent/onefuzz-task/src/managed/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub async fn run(args: &clap::ArgMatches<'_>) -> Result<()> {
error!("error running task: {:?}", err);
}

onefuzz_telemetry::try_flush_and_close();
onefuzz_telemetry::try_flush_and_close().await;

// wait for the task logger to finish
if let Some(task_logger) = task_logger {
Expand Down
6 changes: 1 addition & 5 deletions src/agent/onefuzz-telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ z3 = ["z3-sys"]
intel_instructions = ["iced-x86"]

[dependencies]
# appinsights-rs haas included optional support for rustls since 2020-10, but
# not the feature has not been released yet. This is the pinned to the most
# recent git hash as of 2021-06-30. Once released, this should be reverted to
# use released versions
appinsights = { git = "https://github.com/dmolokanov/appinsights-rs", rev = "0af6ec83bad1c050160f5258ab08e9834596ce20", features=["rustls"], default-features = false }
appinsights = { version = "0.2.1", features = ["rustls"], default-features = false }
log = "0.4"
uuid = { version = "0.8", features = ["serde", "v4"] }
serde = { version = "1.0", features = ["derive"] }
Expand Down
10 changes: 5 additions & 5 deletions src/agent/onefuzz-telemetry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl fmt::Display for InstanceTelemetryKey {
}
}

pub type TelemetryClient = appinsights::TelemetryClient<appinsights::InMemoryChannel>;
pub type TelemetryClient = appinsights::TelemetryClient;
pub enum ClientType {
Instance,
Microsoft,
Expand Down Expand Up @@ -475,17 +475,17 @@ pub fn set_appinsights_clients(
global::set_clients(instance_client, microsoft_client);
}

/// Try to submit any pending telemetry with a blocking call.
/// Try to submit any pending telemetry.
///
/// Meant for a final attempt at flushing pending items before an abnormal exit.
/// After calling this function, any existing telemetry client will be dropped,
/// and subsequent telemetry submission will be a silent no-op.
pub fn try_flush_and_close() {
pub async fn try_flush_and_close() {
let clients = global::take_clients();

for client in clients {
client.flush_channel();
client.close_channel();
// close_channel performs an implicit flush
client.close_channel().await;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/proxy-manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async fn run(proxy_config: Config) -> Result<()> {
if let Err(err) = &result {
error!("run loop failed: {:?}", err);
}
onefuzz_telemetry::try_flush_and_close();
onefuzz_telemetry::try_flush_and_close().await;
result
}

Expand Down

0 comments on commit e3452dd

Please sign in to comment.