Details
Creating this Ponder entry mostly to document it for others.
I am aware that https://we.phorge.it/herald/transcript/ lists all recent Herald activity, and the for each run (under a URI like https://we.phorge.it/herald/transcript/1234/profile/) shows the costs of each analyzed Herald rule in μs for that very run.
However, given our downstream instance with a lot of Herald rules inevitably decreasing performance, I thought it could make sense to have "global" statistics showing how often each active Herald rule is successfully triggered, in total.
That would allow identifying uncommon Herald rules to consider disabling them, and common Herald rules to check their performance and maybe fine-tune their conditions.
SELECT * FROM herald_transcript WHERE id ="12345" seems to provide a JSON blob with no easy way to parse and sum up.
I thought that SELECT ruleID, COUNT(ruleID) AS runs FROM phabricator_herald.herald_ruleapplied INNER JOIN phabricator_herald.herald_rule ON herald_ruleapplied.ruleID = herald_rule.id WHERE herald_rule.isDisabled != 1 GROUP BY ruleID ORDER BY runs DESC; would do the job for active Herald rules, and SELECT herald_rule.id FROM phabricator_herald.herald_rule WHERE herald_rule.isDisabled != 1 AND herald_rule.id NOT IN (SELECT ruleID FROM phabricator_herald.herald_ruleapplied); would list all Herald rules never ever triggered.
However, that does not seem to be the case (I found Herald rules not listed in the database table but definitely recently triggered), so I'm wondering what's the logic to update/insert into the phabricator_herald.herald_ruleapplied DB table.