Page MenuHomePhabricator

Statsv support for timer metrics
Closed, ResolvedPublic

Description

In T355837: Add Prometheus support to statsd.js via mw.track(), we added support for sending counter metrics to Prometheus by statsv.

Timers that cannot be migrated with the current statsv code:

Should we allow use of timers in statsv?

Event Timeline

There are a couple ways to implement this feature.

The more complicated way would be to add a field that defines a histogram when calling mw.track(). This will take longer to implement and is more difficult to get right. Some benefits are:

  • Histogram buckets are defined in the code and centrally managed there.
  • Can measure more than just time
  • Unit can be anything

The easier way is to configure statsd-exporter to cast all native timers as histograms internally. This can be completed faster and has less code overall. Some cons are:

  • Limited to units of time and must be in milliseconds (recalculated to seconds by statsd-exporter)
  • All histogram buckets must be defined in the statsd-exporter config and are uniform across all timers

The solutions are not mutually-exclusive. Implementing both is possible if we have an interface that can pass discernible parameters.

(Note that something like this will also be required for histograms T348796: MediaWiki: Define new metric type - Histogram. E.g. for tracking payload sizes in bytes.)

Change #1117606 had a related patch set uploaded (by Krinkle; author: Krinkle):

[performance/statsv@master] statsv: Enable intake of dogstatsd timer messages

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

Change #1117649 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/extensions/WikimediaEvents@master] statsd: Minor refactor before enabling "timing" dogstatsd messages

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

Change #1117650 had a related patch set uploaded (by Krinkle; author: Krinkle):

[mediawiki/extensions/WikimediaEvents@master] statsd: Add subscribing for timing messages via dogstatsd

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

Change #1117649 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] statsd: Minor refactor before enabling "timing" dogstatsd messages

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

Change #1117606 merged by jenkins-bot:

[performance/statsv@master] statsv: Enable intake of dogstatsd timer messages

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

Change #1117650 merged by jenkins-bot:

[mediawiki/extensions/WikimediaEvents@master] statsd: Add subscribing for timing messages via dogstatsd

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

Mentioned in SAL (#wikimedia-operations) [2025-02-11T16:08:25Z] <krinkle@deploy2002> Started deploy [statsv/statsv@7b87958]: T383953: Enable intake of dogstatsd timer messages

Mentioned in SAL (#wikimedia-operations) [2025-02-11T16:08:34Z] <krinkle@deploy2002> Finished deploy [statsv/statsv@7b87958]: T383953: Enable intake of dogstatsd timer messages (duration: 00m 08s)