MediaWiki  1.34.0
PrefixingStatsdDataFactoryProxy.php
Go to the documentation of this file.
1 <?php
21 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
22 use Liuggio\StatsdClient\Entity\StatsdDataInterface;
23 
29 class PrefixingStatsdDataFactoryProxy implements StatsdDataFactoryInterface {
30 
34  private $prefix;
35 
39  private $factory;
40 
45  public function __construct(
46  StatsdDataFactoryInterface $factory,
47  $prefix
48  ) {
49  $this->factory = $factory;
50  $this->prefix = rtrim( $prefix, '.' );
51  }
52 
57  private function addPrefixToKey( $key ) {
58  return $this->prefix . '.' . $key;
59  }
60 
61  public function timing( $key, $time ) {
62  return $this->factory->timing( $this->addPrefixToKey( $key ), $time );
63  }
64 
65  public function gauge( $key, $value ) {
66  return $this->factory->gauge( $this->addPrefixToKey( $key ), $value );
67  }
68 
69  public function set( $key, $value ) {
70  return $this->factory->set( $this->addPrefixToKey( $key ), $value );
71  }
72 
73  public function increment( $key ) {
74  return $this->factory->increment( $this->addPrefixToKey( $key ) );
75  }
76 
77  public function decrement( $key ) {
78  return $this->factory->decrement( $this->addPrefixToKey( $key ) );
79  }
80 
81  public function updateCount( $key, $delta ) {
82  return $this->factory->updateCount( $this->addPrefixToKey( $key ), $delta );
83  }
84 
85  public function produceStatsdData(
86  $key,
87  $value = 1,
88  $metric = StatsdDataInterface::STATSD_METRIC_COUNT
89  ) {
90  return $this->factory->produceStatsdData(
91  $this->addPrefixToKey( $key ),
92  $value,
93  $metric
94  );
95  }
96 }
PrefixingStatsdDataFactoryProxy\__construct
__construct(StatsdDataFactoryInterface $factory, $prefix)
Definition: PrefixingStatsdDataFactoryProxy.php:45
PrefixingStatsdDataFactoryProxy\gauge
gauge( $key, $value)
Definition: PrefixingStatsdDataFactoryProxy.php:65
PrefixingStatsdDataFactoryProxy\increment
increment( $key)
Definition: PrefixingStatsdDataFactoryProxy.php:73
PrefixingStatsdDataFactoryProxy\updateCount
updateCount( $key, $delta)
Definition: PrefixingStatsdDataFactoryProxy.php:81
PrefixingStatsdDataFactoryProxy\addPrefixToKey
addPrefixToKey( $key)
Definition: PrefixingStatsdDataFactoryProxy.php:57
PrefixingStatsdDataFactoryProxy\timing
timing( $key, $time)
Definition: PrefixingStatsdDataFactoryProxy.php:61
PrefixingStatsdDataFactoryProxy\decrement
decrement( $key)
Definition: PrefixingStatsdDataFactoryProxy.php:77
PrefixingStatsdDataFactoryProxy
Proxy to prefix metric keys sent to a StatsdDataFactoryInterface.
Definition: PrefixingStatsdDataFactoryProxy.php:29
PrefixingStatsdDataFactoryProxy\produceStatsdData
produceStatsdData( $key, $value=1, $metric=StatsdDataInterface::STATSD_METRIC_COUNT)
Definition: PrefixingStatsdDataFactoryProxy.php:85
PrefixingStatsdDataFactoryProxy\$factory
StatsdDataFactoryInterface $factory
Definition: PrefixingStatsdDataFactoryProxy.php:39
PrefixingStatsdDataFactoryProxy\$prefix
string $prefix
Definition: PrefixingStatsdDataFactoryProxy.php:34