File: NullStatsdDataFactory.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (132 lines) | stat: -rw-r--r-- 3,055 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php

namespace Wikimedia\Stats;

use Liuggio\StatsdClient\Entity\StatsdData;
use Liuggio\StatsdClient\Entity\StatsdDataInterface;

/**
 * @author Addshore
 * @since 1.27
 */
class NullStatsdDataFactory implements IBufferingStatsdDataFactory {

	/**
	 * This function creates a 'timing' StatsdData.
	 *
	 * @param string|array $key The metric(s) to set.
	 * @param float $time The elapsed time (ms) to log
	 */
	public function timing( $key, $time ) {
	}

	/**
	 * This function creates a 'gauge' StatsdData.
	 *
	 * @param string|array $key The metric(s) to set.
	 * @param float $value The value for the stats.
	 */
	public function gauge( $key, $value ) {
	}

	/**
	 * This function creates a 'set' StatsdData object
	 * A "Set" is a count of unique events.
	 * This data type acts like a counter, but supports counting
	 * of unique occurrences of values between flushes. The backend
	 * receives the number of unique events that happened since
	 * the last flush.
	 *
	 * The reference use case involved tracking the number of active
	 * and logged in users by sending the current userId of a user
	 * with each request with a key of "uniques" (or similar).
	 *
	 * @param string|array $key The metric(s) to set.
	 * @param float $value The value for the stats.
	 *
	 * @return array
	 */
	public function set( $key, $value ) {
		return [];
	}

	/**
	 * This function creates a 'increment' StatsdData object.
	 *
	 * @param string|array $key The metric(s) to increment.
	 *
	 * @return array
	 */
	public function increment( $key ) {
		return [];
	}

	/**
	 * This function creates a 'decrement' StatsdData object.
	 *
	 *
	 * @param string|array $key The metric(s) to decrement.
	 *
	 * @return mixed
	 */
	public function decrement( $key ) {
		return [];
	}

	/**
	 * This function creates a 'updateCount' StatsdData object.
	 *
	 * @param string|array $key The metric(s) to decrement.
	 * @param int $delta The delta to add to the each metric
	 *
	 * @return mixed
	 */
	public function updateCount( $key, $delta ) {
		return [];
	}

	/**
	 * Produce a StatsdDataInterface Object.
	 *
	 * @param string $key The key of the metric
	 * @param int $value The amount to increment/decrement each metric by.
	 * @param string $metric The metric type
	 *                      ("c" for count, "ms" for timing, "g" for gauge, "s" for set)
	 *
	 * @return StatsdDataInterface
	 */
	public function produceStatsdData(
		$key,
		$value = 1,
		$metric = StatsdDataInterface::STATSD_METRIC_COUNT
	) {
		$data = new StatsdData();
		$data->setKey( $key );
		$data->setValue( $value );
		$data->setMetric( $metric );
		return $data;
	}

	public function hasData() {
		return false;
	}

	public function getData() {
		return [];
	}

	public function clearData() {
		// Nothing to do, always empty
	}

	public function getDataCount() {
		return 0;
	}

	public function setEnabled( $enabled ) {
		// Nothing to do, null factory is always disabled.
	}
}

/** @deprecated class alias since 1.43 */
class_alias( NullStatsdDataFactory::class, 'NullStatsdDataFactory' );