From 2e11c8f0eacf8d0e44435875ca4d58dd9e4231e6 Mon Sep 17 00:00:00 2001 From: Christopher Maier Date: Tue, 14 May 2019 18:04:17 -0400 Subject: [PATCH] [PR Feedback] Rename health_check duration field to execution More self-describing this way. Signed-off-by: Christopher Maier --- components/sup/protocols/event.proto | 3 +-- components/sup/src/event.rs | 6 ++++-- components/sup/src/manager/service/mod.rs | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/components/sup/protocols/event.proto b/components/sup/protocols/event.proto index 5b5a375389..1b2e9ecf9a 100644 --- a/components/sup/protocols/event.proto +++ b/components/sup/protocols/event.proto @@ -73,9 +73,8 @@ message ServiceStoppedEvent { message HealthCheckEvent { EventMetadata event_metadata = 1; ServiceMetadata service_metadata = 2; - // The result of the health check execution HealthCheck result = 3; // If the service has a health check hook script, how long it took // to execute. - google.protobuf.Duration duration = 4; + google.protobuf.Duration execution = 4; } diff --git a/components/sup/src/event.rs b/components/sup/src/event.rs index ce14eb3b41..ddc9bf6c81 100644 --- a/components/sup/src/event.rs +++ b/components/sup/src/event.rs @@ -182,13 +182,15 @@ pub fn service_stopped(service: &Service) { } } -pub fn health_check(service: &Service, check_result: HealthCheck, duration: Option) { +/// `execution` will be `Some` if the service had a hook to run, and +/// records how long it took that hook to execute completely. +pub fn health_check(service: &Service, check_result: HealthCheck, execution: Option) { if stream_initialized() { let check_result: types::HealthCheck = check_result.into(); publish(HealthCheckEvent { service_metadata: Some(service.to_service_metadata()), event_metadata: None, result: i32::from(check_result), - duration: duration.map(Into::into), }); + execution: execution.map(Into::into), }); } } diff --git a/components/sup/src/manager/service/mod.rs b/components/sup/src/manager/service/mod.rs index 290852a679..343f557942 100644 --- a/components/sup/src/manager/service/mod.rs +++ b/components/sup/src/manager/service/mod.rs @@ -936,14 +936,14 @@ impl Service { // Additionally, we'll only send the time with the health // check event if there's actually a hook that runs. We'll // default to there not being a hook, though. - let mut event_duration = None; + let mut execution_duration = None; let check_result = if let Some(ref hook) = self.hooks.health_check { let event_start = Instant::now(); let result = hook.run(&self.service_group, &self.pkg, self.svc_encrypted_password.as_ref()); - event_duration = Some(event_start.elapsed()); + execution_duration = Some(event_start.elapsed()); result } else { match self.supervisor.status() { @@ -966,7 +966,7 @@ impl Service { self.schedule_special_health_check(); } self.health_check = check_result; - event::health_check(&self, check_result, event_duration); + event::health_check(&self, check_result, execution_duration); self.cache_health_check(check_result); }