Merge "Move section ID fallbacks into headers themselves"
[lhc/web/wiklou.git] / includes / libs / stats / NullStatsdDataFactory.php
1 <?php
2
3 use Liuggio\StatsdClient\Entity\StatsdData;
4 use Liuggio\StatsdClient\Entity\StatsdDataInterface;
5 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
6
7 /**
8 * @author Addshore
9 * @since 1.27
10 */
11 class NullStatsdDataFactory implements IBufferingStatsdDataFactory {
12
13 /**
14 * This function creates a 'timing' StatsdData.
15 *
16 * @param string|array $key The metric(s) to set.
17 * @param float $time The elapsed time (ms) to log
18 */
19 public function timing( $key, $time ) {
20 }
21
22 /**
23 * This function creates a 'gauge' StatsdData.
24 *
25 * @param string|array $key The metric(s) to set.
26 * @param float $value The value for the stats.
27 */
28 public function gauge( $key, $value ) {
29 }
30
31 /**
32 * This function creates a 'set' StatsdData object
33 * A "Set" is a count of unique events.
34 * This data type acts like a counter, but supports counting
35 * of unique occurrences of values between flushes. The backend
36 * receives the number of unique events that happened since
37 * the last flush.
38 *
39 * The reference use case involved tracking the number of active
40 * and logged in users by sending the current userId of a user
41 * with each request with a key of "uniques" (or similar).
42 *
43 * @param string|array $key The metric(s) to set.
44 * @param float $value The value for the stats.
45 *
46 * @return array
47 */
48 public function set( $key, $value ) {
49 return [];
50 }
51
52 /**
53 * This function creates a 'increment' StatsdData object.
54 *
55 * @param string|array $key The metric(s) to increment.
56 *
57 * @return array
58 */
59 public function increment( $key ) {
60 return [];
61 }
62
63 /**
64 * This function creates a 'decrement' StatsdData object.
65 *
66 *
67 * @param string|array $key The metric(s) to decrement.
68 *
69 * @return mixed
70 */
71 public function decrement( $key ) {
72 return [];
73 }
74
75 /**
76 * This function creates a 'updateCount' StatsdData object.
77 *
78 * @param string|array $key The metric(s) to decrement.
79 * @param int $delta The delta to add to the each metric
80 *
81 * @return mixed
82 */
83 public function updateCount( $key, $delta ) {
84 return [];
85 }
86
87 /**
88 * Produce a StatsdDataInterface Object.
89 *
90 * @param string $key The key of the metric
91 * @param int $value The amount to increment/decrement each metric by.
92 * @param string $metric The metric type
93 * ("c" for count, "ms" for timing, "g" for gauge, "s" for set)
94 *
95 * @return StatsdDataInterface
96 */
97 public function produceStatsdData(
98 $key,
99 $value = 1,
100 $metric = StatsdDataInterface::STATSD_METRIC_COUNT
101 ) {
102 $data = new StatsdData();
103 $data->setKey( $key );
104 $data->setValue( $value );
105 $data->setMetric( $metric );
106 return $data;
107 }
108
109 /**
110 * Check whether this data factory has any data.
111 * @return bool
112 */
113 public function hasData() {
114 return false;
115 }
116
117 /**
118 * Return data from the factory.
119 * @return StatsdData[]
120 */
121 public function getData() {
122 return [];
123 }
124
125 /**
126 * Set collection enable status.
127 * @param bool $enabled Will collection be enabled?
128 * @return void
129 */
130 public function setEnabled( $enabled ) {
131 // Nothing to do, null factory is always disabled.
132 }
133 }