Page MenuHomePhabricator

Thank you email metrics causing occasional prometheus parsing errors due to lack of value
Closed, ResolvedPublic

Description

We are occasionally seeing errors like this in the system logs for prometheus processing:

civi1002 prometheus-node-exporter[1002]: ts=2025-12-01T19:05:15.702Z caller=textfile.go:227 level=error collector=textfile msg="failed to collect textfile data" file=thank_you_emails_sent.prom err="failed to parse textfile data from \"/var/spool/prometheus/thank_you_emails_sent.prom\": text format parsing error in line 1: expected float as value, got \"DAF_thank_you_emails\""

This indicates that a prom file wasn't processed since it could not be parsed. It appears that there are cases where the DAF_thank_you_emails metric is being sent to the prom file with no value. This causes the entire file to not be read and any valid metrics in the file won't be recorded.

It appears that the generation of the metric is at https://gerrit.wikimedia.org/r/plugins/gitiles/wikimedia/fundraising/crm/+/refs/heads/master/ext/wmf-thankyou/Civi/Api4/Action/ThankYou/BatchSend.php#174

That ends up calling reportMetrics (https://gerrit.wikimedia.org/r/plugins/gitiles/wikimedia/fundraising/crm/+/refs/heads/master/ext/wmf-civicrm/Civi/WMFStatistic/PrometheusReporter.php#37) which does the actual writing to a file.

It might make sense to do one of the following:

  • exclude the metric from the collection list if it has no value (either in BatchSend or in reportMetrics)
  • assign a value of zero to a metric if it has no value when collecting the metric (BatchSend)
  • have reportMetrics assign a value of zero any metrics that don't have corresponding value (could cause issues for any metrics that aren't just floats)

I'm not sure if the best answer here, but those are the immediate suggestions I have.

Event Timeline

XenoRyet triaged this task as Medium priority.Jan 5 2026, 9:10 PM

Weird, the only way I see it adding entries to that array is with increment():
https://gerrit.wikimedia.org/r/plugins/gitiles/wikimedia/fundraising/crm/+/refs/heads/master/ext/wmf-thankyou/Civi/Api4/Action/ThankYou/BatchSend.php#289

And that should initialize it to zero before adding...

Change #1227828 had a related patch set uploaded (by Ejegg; author: Ejegg):

[wikimedia/fundraising/crm@master] Ensure reported TY email count is always an int

https://gerrit.wikimedia.org/r/1227828

Change #1227828 merged by jenkins-bot:

[wikimedia/fundraising/crm@master] Ensure reported TY email count is always an int

https://gerrit.wikimedia.org/r/1227828

Damilare set Final Story Points to 2.