23 use Liuggio\StatsdClient\Entity\StatsdData;
24 use Liuggio\StatsdClient\Entity\StatsdDataInterface;
25 use Liuggio\StatsdClient\Factory\StatsdDataFactory;
39 parent::__construct();
40 $this->prefix = $prefix;
54 $key = preg_replace(
'/[:.]+/',
'.', $key );
55 $key = preg_replace(
'/[^a-z0-9.]+/i',
'_', $key );
56 $key = trim( $key,
'_.' );
57 return str_replace( [
'._',
'_.' ],
'.', $key );
61 $key,
$value = 1, $metric = StatsdDataInterface::STATSD_METRIC_COUNT
63 $entity = $this->produceStatsdDataEntity();
64 if ( $key !==
null ) {
66 $entity->setKey( $key );
69 $entity->setValue(
$value );
71 if ( $metric !==
null ) {
72 $entity->setMetric( $metric );
75 if ( !( $metric === StatsdDataInterface::STATSD_METRIC_COUNT && !
$value ) ) {
76 $this->buffer[] = $entity;