MediaWiki REL1_40
BufferingStatsdDataFactory Class Reference

MediaWiki adaption of StatsdDataFactory that provides buffering and metric prefixing. More...

Inherits StatsdDataFactory, and IBufferingStatsdDataFactory.

Collaboration diagram for BufferingStatsdDataFactory:

Public Member Functions

 __construct ( $prefix)
 
 clearData ()
 Clear all buffered data from the factory.
 
 decrement ( $key)
 
 gauge ( $key, $value)
 
 getData ()
 
 getDataCount ()
 Return the number of buffered statsd data entries.
 
 hasData ()
 Check whether this data factory has any buffered data.
 
 increment ( $key)
 
 produceStatsdData ( $key, $value=1, $metric=StatsdDataInterface::STATSD_METRIC_COUNT)
 
 set ( $key, $value)
 
 setEnabled ( $enabled)
 Set collection enable status.
 
 timing ( $key, $time)
 
 updateCount ( $key, $delta)
 

Protected Attributes

array $buffer = []
 
bool $enabled = true
 

Detailed Description

MediaWiki adaption of StatsdDataFactory that provides buffering and metric prefixing.

The buffering functionality exists as a performance optimisation to reduce network traffic and StatsD processing by maximally utilizing StatsdClient's ability to compress counter increments, and send all data in a few large UDP packets over a single connection.

These buffers are sent from MediaWiki::emitBufferedStatsdData. For web requests, this happens post-send. For command-line scripts, this happens periodically from a database callback (see MWLBFactory::applyGlobalState).

Todo
Evaluate upstream's StatsdService class, which implements similar buffering logic and was released in statsd-php-client 1.0.13, shortly after we implemented this here for statsd-php-client 1.0.12 at the time.
Since
1.25 @method StatsdData produceStatsdDataEntity() We use StatsdData::setKey, which is not in StatsdDataInterface https://gerrit.wikimedia.org/r/643976

Definition at line 47 of file BufferingStatsdDataFactory.php.

Constructor & Destructor Documentation

◆ __construct()

BufferingStatsdDataFactory::__construct ( $prefix)

Definition at line 55 of file BufferingStatsdDataFactory.php.

Member Function Documentation

◆ clearData()

BufferingStatsdDataFactory::clearData ( )

Clear all buffered data from the factory.

Since
1.31

Implements IBufferingStatsdDataFactory.

Definition at line 204 of file BufferingStatsdDataFactory.php.

◆ decrement()

BufferingStatsdDataFactory::decrement ( $key)
Parameters
string$key
Returns
void

Definition at line 117 of file BufferingStatsdDataFactory.php.

◆ gauge()

BufferingStatsdDataFactory::gauge ( $key,
$value )
Parameters
string$key
float | int$value
Returns
void

Definition at line 81 of file BufferingStatsdDataFactory.php.

◆ getData()

BufferingStatsdDataFactory::getData ( )
Since
1.30
Returns
StatsdData[]

Implements IBufferingStatsdDataFactory.

Definition at line 188 of file BufferingStatsdDataFactory.php.

References produceStatsdData().

◆ getDataCount()

BufferingStatsdDataFactory::getDataCount ( )

Return the number of buffered statsd data entries.

Returns
int
Since
1.31

Implements IBufferingStatsdDataFactory.

Definition at line 208 of file BufferingStatsdDataFactory.php.

◆ hasData()

BufferingStatsdDataFactory::hasData ( )

Check whether this data factory has any buffered data.

Returns
bool

Implements IBufferingStatsdDataFactory.

Definition at line 180 of file BufferingStatsdDataFactory.php.

References $buffer.

◆ increment()

BufferingStatsdDataFactory::increment ( $key)
Parameters
string$key
Returns
array

Definition at line 105 of file BufferingStatsdDataFactory.php.

◆ produceStatsdData()

BufferingStatsdDataFactory::produceStatsdData ( $key,
$value = 1,
$metric = StatsdDataInterface::STATSD_METRIC_COUNT )

Definition at line 159 of file BufferingStatsdDataFactory.php.

Referenced by getData().

◆ set()

BufferingStatsdDataFactory::set ( $key,
$value )
Parameters
string$key
float | int$value
Returns
array

Definition at line 93 of file BufferingStatsdDataFactory.php.

◆ setEnabled()

BufferingStatsdDataFactory::setEnabled ( $enabled)

Set collection enable status.

Parameters
bool$enabledWill collection be enabled?
Returns
void

Implements IBufferingStatsdDataFactory.

Definition at line 212 of file BufferingStatsdDataFactory.php.

References $enabled.

◆ timing()

BufferingStatsdDataFactory::timing ( $key,
$time )
Parameters
string$key
float | int$time
Returns
void

Definition at line 69 of file BufferingStatsdDataFactory.php.

◆ updateCount()

BufferingStatsdDataFactory::updateCount ( $key,
$delta )
Parameters
string$key
int$delta
Returns
void

Definition at line 129 of file BufferingStatsdDataFactory.php.

Member Data Documentation

◆ $buffer

array BufferingStatsdDataFactory::$buffer = []
protected

Definition at line 49 of file BufferingStatsdDataFactory.php.

Referenced by hasData().

◆ $enabled

bool BufferingStatsdDataFactory::$enabled = true
protected

Definition at line 51 of file BufferingStatsdDataFactory.php.

Referenced by setEnabled().


The documentation for this class was generated from the following file: