Debian Codegraph @

includes/libs/Stats/NullStatsdDataFactory.php

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