-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactor application health monitoring #82
Conversation
Application health is needed for two distinct reasons: 1. Sending alerts to a monitoring webhook for setup errors. Relatedly, sending heartbeat messages to the webhook when healthy. 2. The HTTP health probe. Needed so that the orchestration environment (kubernetes or whatever) can kill the pod when unhealthy Several Snowplow apps each implement their own logic of when to toggle the health probe and when to send an alert. This PR consolidates that logic into one place. After this PR, the application code just needs to call methods on the AppHealth class. This lib then manages webhook events and health probe, based on the current status of the AppHealth.
4b3a25f
to
b29df23
Compare
modules/runtime-common/src/main/scala/com/snowplowanalytics/snowplow/runtime/AppHealth.scala
Show resolved
Hide resolved
modules/runtime-common/src/main/scala/com/snowplowanalytics/snowplow/runtime/AppHealth.scala
Show resolved
Hide resolved
|
||
private[runtime] sealed trait SetupStatus[+Alert] | ||
private[runtime] object SetupStatus { | ||
case object AwaitingHealth extends SetupStatus[Nothing] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only affects what is printed in logs, right? In health probe it still means 503 unhealthy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- When we first transition to
Healthy
then we send aheartbeat
event to the webhook - When we first transition to
Unhealthy
then we send aalert
event to the webhook
Therefore we need a type which is neither Healthy
nor Unhealthy
so we detect the transition. Hence AwaitingHealth
.
modules/runtime-common/src/main/scala/com/snowplowanalytics/snowplow/runtime/HealthProbe.scala
Outdated
Show resolved
Hide resolved
modules/runtime-common/src/main/scala/com/snowplowanalytics/snowplow/runtime/Webhook.scala
Show resolved
Hide resolved
modules/runtime-common/src/main/scala/com/snowplowanalytics/snowplow/runtime/Webhook.scala
Show resolved
Hide resolved
2011180
to
f261713
Compare
4b492d9
to
0e72774
Compare
1135ccf
to
8d43c85
Compare
8d43c85
to
a139a53
Compare
Application health is needed for two distinct reasons:
Several Snowplow apps each implement their own logic of when to toggle the health probe and when to send an alert. This PR consolidates that logic into one place.
After this PR, the application code just needs to call methods on the AppHealth class. This lib then manages webhook events and health probe, based on the current status of the AppHealth.