MediaWiki REL1_39
PrefixingStatsdDataFactoryProxy.php
Go to the documentation of this file.
1<?php
21use Liuggio\StatsdClient\Entity\StatsdDataInterface;
22use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
23
29class 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}
Proxy to prefix metric keys sent to a StatsdDataFactoryInterface.
__construct(StatsdDataFactoryInterface $factory, $prefix)
produceStatsdData( $key, $value=1, $metric=StatsdDataInterface::STATSD_METRIC_COUNT)