google / exposure-notifications-server

Exposure Notification Reference Server | Covid-19 Exposure Notifications
https://www.google.com/covid19/exposurenotifications/
Apache License 2.0
2.39k stars 306 forks source link

Gracefully shutdown prometheus exporter #1611

Closed sethvargo closed 1 year ago

sethvargo commented 1 year ago

Release Note

Gracefully shutdown the Prometheus metrics exporter when the server shuts down. This only applies if the Prometheus metrics exporter is enabled (it's off by default). This fixes a low probability issue that some metrics may be lost during shutdown.
sethvargo commented 1 year ago

FWIW, this doesn't completely eliminate the possibility of metrics loss, but it reduces it. We're still triggering the shutdown in a goroutine, which doesn't block shutdown.

sethvargo commented 1 year ago

FWIW, this doesn't completely eliminate the possibility of metrics loss, but it reduces it. We're still triggering the shutdown in a goroutine, which doesn't block shutdown.

I lied - I moved it inline so this will catch all cases.