IBufferingStatsdDataFactory::set and ::increment are documented to
return an array
Found by phan strict checks
Change-Id: I13ac98615d4ff1bf86cb08790739f5a94ef21017
This simplification effort is the result of a (failed) attempt to
micro-optimize this method. I submit it, despite it not being any
faster or slower, because I noticed that the simpler code actually
resulted in behaviours that I consider "less surprising".
* The method previously (I believe, unintentionally) treated all
colons as segment separators. It now only treats double-colon (::)
as segment separator.
Thus "foo.bar:baz" became "foo.bar.baz", now "foo.bar_baz".
* Leading and trailing underscores are no longer removed from
segments. This makes the former-presence of invalid characters
more obvious to consumers and seems helpful.
This also fixed two bugs:
- In some cases, a segment could become the empty string, which is
invalid for Graphite as each segment must be a directory name.
- In some cases, segments could dissappear entirely, thus changing
the hierarchy specified by the producer in ways they probably
didn't expect.
* Avoid use of empty().
Change-Id: I8601faf1fe45124370a92d43e854608e623c1214
Avoid the time cost of normalizeMetricKey (and other effects of
produceStatsdData, such as holding on to StatsdData during the request),
by deferring it until we are about to send the data to the StatsD server.
As of this commit, the sending of data still happens pre-send which
means this change does not remove its delay from the HTTP response time.
But, it does have two other effects:
* It makes the cost of calling $stats->timing() and ->increment()
much lower, which helps reduce the time attributed to calling
`WANObjectCache->getWithSetCallback`.
* It prepares the code for moving this to post-send in a future patch.
* It moves the scattered cost to a centralised place in the flame graph.
WMF's flame graphs are configued to crop the top of flames that are
smaller than 1px. This is important for making the flame graphs render
in a reasonable amount of time, but means that functions that have
many unique paths to them hidden from view. Centralising this will
make it easier to quantify how much time is spent here, which will
be of use even after it becomes post-send, since we have flame graphs
for post-send as well.
Also:
* Improve documentation.
* Add tests for normalizeMetricKey().
Bug: T288702
Change-Id: I1c57104590e48222b3e972589d49891b71afaee7
The parent abstract produceStatsdData() is documented to return
StatsdDataInterface, but that does not provide the setKey function
This patch makes phan with taint happy
Change-Id: I7fb2a79f0523fb1bf7a0778ac0380544229aa04b
Follows-up 7fdc3d09a3. Also document the getData method.
This method seems unused from a quick glance at Code Search, but
there's a lot of false positives from Monolog instances.
To play safe, rather than removing, add hard-deprecation for
a few days just in case we find another hit.
Change-Id: I8aab93744e66c1a583c67f0bbac27a45250a8fbb
This helps to avoid OOMs from buffer build-ups in the statsd
factory object. This piggy-backs on to the same checks used
for deferred update runs. In addition, the output() method
checks if the data size is getting large and emits if needed.
Bug: T181385
Change-Id: I598be98a5770f8358975815e51380c4b8f63a79e
Follows-up I2874175647e (7fdc3d09a3).
* Avoid "MediaWiki" in class names. If unavoidable, always camelcase.
* Use a more descriptive name, matching the implementing the class ("Buffering").
* Use "I" prefix for consistency with other MediaWiki-provided interfaces.
(Avoid "Interface" suffix, which is foreign to MediaWiki and is only used
in the StatsdClient namespace, which this interface is not in).
Bug: T166354
Change-Id: I06de59122625f9c23e7c1a1bfa69a7ddabbf379e
The following changes are added:
- Created MediawikiStatsdDataFactory interface
- Added hasData() method to see if there are any data to send
- Added getData() method to fetch data
- Made service infrastructure use MediawikiStatsdDataFactory interface
- Made wfLogProfilingData() use MediawikiStatsdDataFactory interface
- Added capability to enable/disable buffering collector
Bug: T166354
Change-Id: I2874175647e987996a9a399829b3319674471aaa