3 use Liuggio\StatsdClient\Entity\StatsdData
;
4 use Liuggio\StatsdClient\Entity\StatsdDataInterface
;
10 class NullStatsdDataFactory
implements IBufferingStatsdDataFactory
{
13 * This function creates a 'timing' StatsdData.
15 * @param string|array $key The metric(s) to set.
16 * @param float $time The elapsed time (ms) to log
18 public function timing( $key, $time ) {
22 * This function creates a 'gauge' StatsdData.
24 * @param string|array $key The metric(s) to set.
25 * @param float $value The value for the stats.
27 public function gauge( $key, $value ) {
31 * This function creates a 'set' StatsdData object
32 * A "Set" is a count of unique events.
33 * This data type acts like a counter, but supports counting
34 * of unique occurrences of values between flushes. The backend
35 * receives the number of unique events that happened since
38 * The reference use case involved tracking the number of active
39 * and logged in users by sending the current userId of a user
40 * with each request with a key of "uniques" (or similar).
42 * @param string|array $key The metric(s) to set.
43 * @param float $value The value for the stats.
47 public function set( $key, $value ) {
52 * This function creates a 'increment' StatsdData object.
54 * @param string|array $key The metric(s) to increment.
58 public function increment( $key ) {
63 * This function creates a 'decrement' StatsdData object.
66 * @param string|array $key The metric(s) to decrement.
70 public function decrement( $key ) {
75 * This function creates a 'updateCount' StatsdData object.
77 * @param string|array $key The metric(s) to decrement.
78 * @param int $delta The delta to add to the each metric
82 public function updateCount( $key, $delta ) {
87 * Produce a StatsdDataInterface Object.
89 * @param string $key The key of the metric
90 * @param int $value The amount to increment/decrement each metric by.
91 * @param string $metric The metric type
92 * ("c" for count, "ms" for timing, "g" for gauge, "s" for set)
94 * @return StatsdDataInterface
96 public function produceStatsdData(
99 $metric = StatsdDataInterface
::STATSD_METRIC_COUNT
101 $data = new StatsdData();
102 $data->setKey( $key );
103 $data->setValue( $value );
104 $data->setMetric( $metric );
109 * Check whether this data factory has any data.
112 public function hasData() {
117 * Return data from the factory.
118 * @return StatsdData[]
120 public function getData() {
125 * Set collection enable status.
126 * @param bool $enabled Will collection be enabled?
129 public function setEnabled( $enabled ) {
130 // Nothing to do, null factory is always disabled.