Commit graph

9 commits

Author SHA1 Message Date
Cole White
738bc85591 Stats: combine testSendGaugeMetric into testSendMetrics
* Removes testSendGaugeMetric
* Ensure we're checking for calls to timing, gauge, and updateCount
* Tune expectations to exactly how many times we expect the calls

Bug: T370636
Change-Id: I73f05b1876e3afbf0995d5605cb17fa5dc6146d2
2024-07-23 13:56:35 +00:00
Derick Alangi
08004ec3b2 Stats: copyToStatsdAt() should not treat gauges as counters
In I15d6f100a31fbb98ad (13f556ab3a), we used `updateCount()`
on Gauges when defining the `set()` method for `copyToStatsdAt()`
instead of calling `gauge()`.

The side effect of this is that StatsLib will treat all guages as
counters instead of proper gauge values. This caused an issue with
the `blameStartupRegistry.php` script migration to prometheus format
to break in the way it sends its gauge data to Graphite.

Credits to @Krinkle for the debugging session where we found out that
this was the issue in the library.

Bug: T370636
Co-Authored-by: Krinkle <krinkle@fastmail.com>
Change-Id: I34cf3ce193b354ae732c1d3b0fd3b851d00aeaf0
2024-07-22 19:56:53 +00:00
Daimona Eaytoy
605d12b9b3 Update tests for PHPUnit 9.6 (part 1)
- Avoid defining abstract test classes (ending in "Test")
- Avoid withConsecutive()
- Avoid getMockClass()

Bug: T342110
Change-Id: I131e0d85bd14e75aaebd6f212b2e64a45d4c73a2
2024-01-16 23:36:15 +01:00
Cole White
14236dfe3d stats: add metric stats.statslib.buffered
Records the number of samples of all metrics in the buffered statslib
cache. Necessitates adding getSampleCount() to BaseMetric and wiring
access through each metric type.

Moved StatsFactory->flush() to execute before
emitBufferedStatsdData().  This is so the metric generated by
copyToStatsdAt() is sent with the rest of the statsd metrics.

Updated tests.

This metric will be used to track the migration progress towards
statslib.

Bug: T350638
Change-Id: I070f3e30a9b8cd0b0ab44f345207e6f25e602fbb
2024-01-15 08:47:00 +00:00
Amir Sarabadani
f5abfb8d58 Bump codesniffer to 42.0.0
Most noisily, this enables MediaWiki.Arrays.OneSpaceInlineArray.

Change-Id: I8ab11399c67ce7e3ab1b6249b591452774393428
2023-09-27 15:06:32 -04:00
Cole White
bb864c4885 Stats: make component optional
* Add withComponent() to configure StatsFactory components.
 * Throw exception on setting static labels without component.
 * Clean up ServiceWiring and MediaWikiServices.
 * Rename withLabel to setLabel.
 * Rename withSampleRate to setSampleRate.
 * Rename withStaticLabel to addStaticLabel.
 * Update tests.

Bug: T240685
Change-Id: I6c99a532431f00bd140f44cb2d5eba2a9d83ca57
2023-09-04 18:00:49 +01:00
Cole White
13f556ab3a Stats: add copy to statsd feature
Enables copying a metric to statsd at the specified namespace.

Bug: T240685
Change-Id: I15d6f100a31fbb98ad89568a2024e926cb47f937
2023-03-06 18:40:36 +00:00
Cole White
b3d20f8873 Stats: simplify metrics configuration, enforce builder pattern
BREAKING INTERFACE CHANGE

 * getMetric() (and all subtypes) now only require a $name.
 * Labels are added dynamically and order enforced by BaseMetric labelKeys.
 * Metric component is now defined in the service instance.
 * Remove InvalidLabelsException.
 * Make addLabelKey() private.
 * Removed unused functions.
 * NullMetric to return $this - support builder pattern.
 * Update tests.

Bug: T240685
Change-Id: Id8cb62ec74907cb54dc39b6a228a230eed0c957d
2023-03-02 23:09:41 +00:00
Cole White
fa92ab43e9 Metrics: rename Metrics lib to Stats
Bug: T240685
Change-Id: Ie43d894b6b4030a88e397495d40886ccb6e69835
2023-02-24 23:01:32 +00:00
Renamed from tests/phpunit/unit/includes/libs/Metrics/MetricsEmitterTest.php (Browse further)