Skip to content

Commit

Permalink
require prometheus client libs in mail_fetcher
Browse files Browse the repository at this point in the history
This is job is currently erroring in all environments, albeit after it's
already done all the important work.

    {"@timestamp":"2024-09-16T13:05:05.605Z","message":"Finished running MailFetcher in production mode - 2024-09-16 13:05:05 UTC","level":"INFO","tags":["rails"]}
		script/mail_fetcher:58:in `<main>': uninitialized constant Prometheus::Client::Push (NameError)
		Prometheus::Client::Push.new(

Note the "Finished running MailFetcher in production mode" log before the error
- the script has still done everything it needs to, it just hasn't sent the
metrics, which fortunately is on the very last line of the script.

This looks like the same mistake I made when doing metrics for publishing-api:

    alphagov/publishing-api@3037457

We need to explicitly require the push library to use it. I'm not 100% sure if
we really need the other two imports (client and registry), but publishing-api
has them, so we may as well be consistent. Can't hurt, surely.
  • Loading branch information
richardTowers committed Sep 16, 2024
1 parent 7c3f0ce commit ac1d7fb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions script/mail_fetcher
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Publisher::Application.mail_fetcher_config.configure

require "fact_check_email_handler"

require "prometheus/client"
require "prometheus/client/push"
require "prometheus/client/registry"

require "redis"
require "redis-lock"

Expand Down

0 comments on commit ac1d7fb

Please sign in to comment.