23use Liuggio\StatsdClient\Entity\StatsdData;
24use Liuggio\StatsdClient\Entity\StatsdDataInterface;
25use Liuggio\StatsdClient\Factory\StatsdDataFactory;
49 parent::__construct();
65 $key = preg_replace(
'/[:.]+/',
'.', $key );
66 $key = preg_replace(
'/[^a-z0-9.]+/i',
'_', $key );
67 $key = trim( $key,
'_.' );
68 return str_replace( [
'._',
'_.' ],
'.', $key );
72 $key, $value = 1, $metric = StatsdDataInterface::STATSD_METRIC_COUNT
74 $entity = $this->produceStatsdDataEntity();
75 if ( !$this->enabled ) {
78 if ( $key !==
null ) {
80 $entity->setKey( $key );
82 if ( $value !==
null ) {
83 $entity->setValue( $value );
85 if ( $metric !==
null ) {
86 $entity->setMetric( $metric );
89 if ( !( $metric === StatsdDataInterface::STATSD_METRIC_COUNT && !$value ) ) {
90 $this->buffer[] = $entity;
96 return !empty( $this->buffer );
112 return count( $this->buffer );
A factory for application metric data.
hasData()
Check whether this data factory has any buffered data.
bool $enabled
Collection enabled?
produceStatsdData( $key, $value=1, $metric=StatsdDataInterface::STATSD_METRIC_COUNT)
clearData()
Clear all buffered data from the factory.
getDataCount()
Return the number of buffered statsd data entries.
static normalizeMetricKey( $key)
Normalize a metric key for StatsD.
setEnabled( $enabled)
Set collection enable status.
MediaWiki adaptation of StatsdDataFactory that provides buffering functionality.