Merge "Remove perf tracking code that was moved to WikimediaEvents in Ib300af5c"
[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
6 /**
7 * @author Addshore
8 * @since 1.27
9 */
10 class NullStatsdDataFactory implements IBufferingStatsdDataFactory {
11
12 /**
13 * This function creates a 'timing' StatsdData.
14 *
15 * @param string|array $key The metric(s) to set.
16 * @param float $time The elapsed time (ms) to log
17 */
18 public function timing( $key, $time ) {
19 }
20
21 /**
22 * This function creates a 'gauge' StatsdData.
23 *
24 * @param string|array $key The metric(s) to set.
25 * @param float $value The value for the stats.
26 */
27 public function gauge( $key, $value ) {
28 }
29
30 /**
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
36 * the last flush.
37 *
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).
41 *
42 * @param string|array $key The metric(s) to set.
43 * @param float $value The value for the stats.
44 *
45 * @return array
46 */
47 public function set( $key, $value ) {
48 return [];
49 }
50
51 /**
52 * This function creates a 'increment' StatsdData object.
53 *
54 * @param string|array $key The metric(s) to increment.
55 *
56 * @return array
57 */
58 public function increment( $key ) {
59 return [];
60 }
61
62 /**
63 * This function creates a 'decrement' StatsdData object.
64 *
65 *
66 * @param string|array $key The metric(s) to decrement.
67 *
68 * @return mixed
69 */
70 public function decrement( $key ) {
71 return [];
72 }
73
74 /**
75 * This function creates a 'updateCount' StatsdData object.
76 *
77 * @param string|array $key The metric(s) to decrement.
78 * @param int $delta The delta to add to the each metric
79 *
80 * @return mixed
81 */
82 public function updateCount( $key, $delta ) {
83 return [];
84 }
85
86 /**
87 * Produce a StatsdDataInterface Object.
88 *
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)
93 *
94 * @return StatsdDataInterface
95 */
96 public function produceStatsdData(
97 $key,
98 $value = 1,
99 $metric = StatsdDataInterface::STATSD_METRIC_COUNT
100 ) {
101 $data = new StatsdData();
102 $data->setKey( $key );
103 $data->setValue( $value );
104 $data->setMetric( $metric );
105 return $data;
106 }
107
108 /**
109 * Check whether this data factory has any data.
110 * @return bool
111 */
112 public function hasData() {
113 return false;
114 }
115
116 /**
117 * Return data from the factory.
118 * @return StatsdData[]
119 */
120 public function getData() {
121 return [];
122 }
123
124 /**
125 * Set collection enable status.
126 * @param bool $enabled Will collection be enabled?
127 * @return void
128 */
129 public function setEnabled( $enabled ) {
130 // Nothing to do, null factory is always disabled.
131 }
132 }