3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
20 namespace Wikimedia\Stats\Metrics
;
22 use Psr\Log\LoggerInterface
;
23 use Wikimedia\Stats\Sample
;
31 interface MetricInterface
{
33 * @param BaseMetricInterface $baseMetric
34 * @param LoggerInterface $logger
36 public function __construct( BaseMetricInterface
$baseMetric, LoggerInterface
$logger );
39 public function getName(): string;
42 public function getComponent(): string;
45 public function getSampleRate(): float;
48 public function getTypeIndicator(): string;
51 * Returns subset of samples corresponding to sample rate setting.
55 public function getSamples(): array;
58 * Sets sample rate on a new metric instance.
60 * @param float $sampleRate
61 * @return CounterMetric|GaugeMetric|TimingMetric|NullMetric
63 public function setSampleRate( float $sampleRate );
66 * Returns the list of defined label keys.
70 public function getLabelKeys(): array;
73 * Adds a label $key with $value.
76 * @param string $value
77 * @return CounterMetric|GaugeMetric|TimingMetric|NullMetric
79 public function setLabel( string $key, string $value );
82 * Copies metric operation to StatsD at provided namespace.
84 * @param string $statsdNamespace
85 * @return CounterMetric|GaugeMetric|TimingMetric|NullMetric
87 public function copyToStatsdAt( string $statsdNamespace );
90 * Returns metric with cleared labels.
92 * @return CounterMetric|GaugeMetric|TimingMetric|NullMetric
94 public function fresh();