Commit graph

5 commits

Author SHA1 Message Date
Cole White
784598add8 Metrics: move metric implementations to subdirectory
Bug: T240685
Change-Id: I38e8f9fac12542909364f06e0484cc1355796673
2022-11-09 19:53:32 -01:00
Cole White
dd70f21c68 Metrics: expand Sample instance parameters
* Eliminates use of associative array
 * Renames $labels to $labelValues
 * Renames Sample()->getLabels() to getLabelValues()

Bug: T240685
Change-Id: Ic97afd06a98a874bd006946eb8f82e8e2b457e63
2022-11-09 18:08:18 -01:00
Cole White
4a2935a765 Metrics: rename extension to component
Bug: T240685
Change-Id: Ia5ddfddf81685446ab7da3f0b5c415c8989afb7f
2022-11-09 17:41:06 -01:00
Timo Tijhof
f603b00abf Metrics: Add test coverage for getRenderedSamples() and send()
Also various other code clean ups:

* Fix warning during PHPUnit coverage run for invalid @coverage target:

> 1) Wikimedia\Tests\Metrics\MetricTest::testValidateLabels
> Trying to @cover not existing class "\Wikimedia\Metrics\Metric".

* Move "expectException" lines to right above the expected failure
  instead of at the start of the method, which aligns with how this
  is typically done in PHPUnit tests.

* Remove TestCase constructor overrides. This is not supported by
  upstream. We generally use setUp() or setUpBeforeClass() for this.

  In this case, remove it entirely in favour of NullLogger without
  any re-use between test methods.

* Change github.com URL to permalink.

* Favour early returns for error handling to separate input validation
  from storing in-object which makes it harder to separate what is and
  isn't valid at any particular point. This is mostly for consistency
  with other MW code, but also happens to make the code simpler in
  this case.

Bug: T240685
Change-Id: I36368cc0aadff7e24fe55dec2eda1365efd779af
2021-10-23 03:13:40 +00:00
Cole White
69d63cdbfe Metrics: Implement statsd-exporter compatible Metrics interface
1. Standardizes metrics interface in a way that supports both statsd
     and a statsd-exporter compatible format (dogstatsd)
  2. Brings metrics formatting in-house
  3. Adds phpunit tests

Bug: T240685
Bug: T205870
Change-Id: I264097c10d83bef291d68bffefa7fb9eb8dc87bb
2021-09-29 15:27:23 -06:00