NullStatsdDataFactory.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. use Liuggio\StatsdClient\Entity\StatsdData;
  3. use Liuggio\StatsdClient\Entity\StatsdDataInterface;
  4. /**
  5. * @author Addshore
  6. * @since 1.27
  7. */
  8. class NullStatsdDataFactory implements IBufferingStatsdDataFactory {
  9. /**
  10. * This function creates a 'timing' StatsdData.
  11. *
  12. * @param string|array $key The metric(s) to set.
  13. * @param float $time The elapsed time (ms) to log
  14. */
  15. public function timing( $key, $time ) {
  16. }
  17. /**
  18. * This function creates a 'gauge' StatsdData.
  19. *
  20. * @param string|array $key The metric(s) to set.
  21. * @param float $value The value for the stats.
  22. */
  23. public function gauge( $key, $value ) {
  24. }
  25. /**
  26. * This function creates a 'set' StatsdData object
  27. * A "Set" is a count of unique events.
  28. * This data type acts like a counter, but supports counting
  29. * of unique occurrences of values between flushes. The backend
  30. * receives the number of unique events that happened since
  31. * the last flush.
  32. *
  33. * The reference use case involved tracking the number of active
  34. * and logged in users by sending the current userId of a user
  35. * with each request with a key of "uniques" (or similar).
  36. *
  37. * @param string|array $key The metric(s) to set.
  38. * @param float $value The value for the stats.
  39. *
  40. * @return array
  41. */
  42. public function set( $key, $value ) {
  43. return [];
  44. }
  45. /**
  46. * This function creates a 'increment' StatsdData object.
  47. *
  48. * @param string|array $key The metric(s) to increment.
  49. *
  50. * @return array
  51. */
  52. public function increment( $key ) {
  53. return [];
  54. }
  55. /**
  56. * This function creates a 'decrement' StatsdData object.
  57. *
  58. *
  59. * @param string|array $key The metric(s) to decrement.
  60. *
  61. * @return mixed
  62. */
  63. public function decrement( $key ) {
  64. return [];
  65. }
  66. /**
  67. * This function creates a 'updateCount' StatsdData object.
  68. *
  69. * @param string|array $key The metric(s) to decrement.
  70. * @param int $delta The delta to add to the each metric
  71. *
  72. * @return mixed
  73. */
  74. public function updateCount( $key, $delta ) {
  75. return [];
  76. }
  77. /**
  78. * Produce a StatsdDataInterface Object.
  79. *
  80. * @param string $key The key of the metric
  81. * @param int $value The amount to increment/decrement each metric by.
  82. * @param string $metric The metric type
  83. * ("c" for count, "ms" for timing, "g" for gauge, "s" for set)
  84. *
  85. * @return StatsdDataInterface
  86. */
  87. public function produceStatsdData(
  88. $key,
  89. $value = 1,
  90. $metric = StatsdDataInterface::STATSD_METRIC_COUNT
  91. ) {
  92. $data = new StatsdData();
  93. $data->setKey( $key );
  94. $data->setValue( $value );
  95. $data->setMetric( $metric );
  96. return $data;
  97. }
  98. public function hasData() {
  99. return false;
  100. }
  101. public function getData() {
  102. return [];
  103. }
  104. public function clearData() {
  105. // Nothing to do, always empty
  106. }
  107. public function getDataCount() {
  108. return 0;
  109. }
  110. public function setEnabled( $enabled ) {
  111. // Nothing to do, null factory is always disabled.
  112. }
  113. }