Add a prometheus metric for emails sent (#31333)
# Context In order to be able to alert operators to Metabase instances sending excessive amounts of emails, we need to measure the number of emails sent. # Notes To break a dependency cycle [^1] `connection-pool-info` was moved from `metabase.troubleshooting` to `metabase.analytics.prometheus` and `GET "/diagnostic_info/connection_pool_info"` in `metabase.api.util` was adjusted accordingly. [^1]: metabase.analytics.prometheus -> metabase.troubleshooting -> metabase.analytics.stats -> metabase.email -> metabase.analytics.prometheus, and longer variations. # Acceptance test * On a Metabase instance with `MB_PROMETHEUS_SERVER_PORT` set, check `localhost:<port>/metrics` and find the number of successfully sent emails (e.g. when inviting users) in the `metabase_email_messages_total` sample and the number of failures in the `metabase_email_message_errors_total` sample, both without any labels. Closes: https://github.com/metabase/metabase/issues/30241
Showing
- src/metabase/analytics/prometheus.clj 32 additions, 8 deletionssrc/metabase/analytics/prometheus.clj
- src/metabase/api/util.clj 3 additions, 2 deletionssrc/metabase/api/util.clj
- src/metabase/email.clj 24 additions, 17 deletionssrc/metabase/email.clj
- src/metabase/troubleshooting.clj 1 addition, 16 deletionssrc/metabase/troubleshooting.clj
- test/metabase/analytics/prometheus_test.clj 34 additions, 8 deletionstest/metabase/analytics/prometheus_test.clj
- test/metabase/email_test.clj 23 additions, 0 deletionstest/metabase/email_test.clj
Please register or sign in to comment