MediaWiki  1.32.5
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
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
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
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$time
see documentation in includes Linker php for Linker::makeImageLink & $time
Definition: hooks.txt:1841
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
$value
$value
Definition: styleTest.css.php:49
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