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

Wait for telemetry client to finish so the metrics are flushed. #862

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 4 additions & 11 deletions data-pipeline/src/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,15 +169,18 @@ impl TelemetryClient {
self.handle.abort();
}
}

/// Shutdowns the telemetry client.
pub async fn shutdown(&self) {
pub async fn shutdown(self) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


what would happen in case of start-shutdown-start?

we should add a test here for above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case the compiler will complain because the TelemetryClient is consumed by the shutdown method so there is no way to start again the client.

if let Err(_e) = self
.worker
.send_msg(TelemetryActions::Lifecycle(LifecycleAction::Stop))
.await
{
self.handle.abort();
}

let _ = self.handle.await;
}
}

Expand Down Expand Up @@ -264,7 +267,6 @@ mod tests {
client.start().await;
let _ = client.send(&data);
client.shutdown().await;
let _ = client.handle.await;
telemetry_srv.assert_hits_async(1).await;
}

Expand Down Expand Up @@ -304,7 +306,6 @@ mod tests {
client.start().await;
let _ = client.send(&data);
client.shutdown().await;
let _ = client.handle.await;
telemetry_srv.assert_hits_async(1).await;
}

Expand Down Expand Up @@ -344,7 +345,6 @@ mod tests {
client.start().await;
let _ = client.send(&data);
client.shutdown().await;
let _ = client.handle.await;
telemetry_srv.assert_hits_async(1).await;
}

Expand Down Expand Up @@ -384,7 +384,6 @@ mod tests {
client.start().await;
let _ = client.send(&data);
client.shutdown().await;
let _ = client.handle.await;
telemetry_srv.assert_hits_async(1).await;
}

Expand Down Expand Up @@ -424,7 +423,6 @@ mod tests {
client.start().await;
let _ = client.send(&data);
client.shutdown().await;
let _ = client.handle.await;
telemetry_srv.assert_hits_async(1).await;
}

Expand Down Expand Up @@ -464,7 +462,6 @@ mod tests {
client.start().await;
let _ = client.send(&data);
client.shutdown().await;
let _ = client.handle.await;
telemetry_srv.assert_hits_async(1).await;
}

Expand Down Expand Up @@ -504,7 +501,6 @@ mod tests {
client.start().await;
let _ = client.send(&data);
client.shutdown().await;
let _ = client.handle.await;
telemetry_srv.assert_hits_async(1).await;
}

Expand Down Expand Up @@ -544,7 +540,6 @@ mod tests {
client.start().await;
let _ = client.send(&data);
client.shutdown().await;
let _ = client.handle.await;
telemetry_srv.assert_hits_async(1).await;
}

Expand Down Expand Up @@ -577,8 +572,6 @@ mod tests {

client.start().await;
client.shutdown().await;
let _ = client.handle.await;

// Check for 2 hits: app-started and app-closing.
telemetry_srv.assert_hits_async(2).await;
}
Expand Down
Loading