Skip to content

Commit

Permalink
DatadogStatsDClientAdapter converts stats
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmastech committed Jul 20, 2024
1 parent ea7ad03 commit 1707b5a
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions src/Adapters/Datadog/DatadogStatsDClientAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Cosmastech\StatsDClientAdapter\Adapters\Datadog;

use Cosmastech\StatsDClientAdapter\Adapters\Concerns\ConvertsStatTrait;
use Cosmastech\StatsDClientAdapter\Adapters\Concerns\HasDefaultTagsTrait;
use Cosmastech\StatsDClientAdapter\Adapters\Concerns\TagNormalizerAwareTrait;
use Cosmastech\StatsDClientAdapter\Adapters\Concerns\TimeClosureTrait;
Expand All @@ -12,9 +13,11 @@
use Cosmastech\StatsDClientAdapter\Utility\Clock;
use DataDog\DogStatsd;
use Psr\Clock\ClockInterface;
use UnitEnum;

class DatadogStatsDClientAdapter implements StatsDClientAdapter, TagNormalizerAware
{
use ConvertsStatTrait;
use HasDefaultTagsTrait;
use TagNormalizerAwareTrait;
use TimeClosureTrait;
Expand Down Expand Up @@ -44,10 +47,10 @@ public function __construct(
/**
* @inheritDoc
*/
public function timing(string|\UnitEnum $stat, float $durationMs, float $sampleRate = 1.0, array $tags = []): void
public function timing(string|UnitEnum $stat, float $durationMs, float $sampleRate = 1.0, array $tags = []): void
{
$this->datadogClient->timing(
$stat,
$this->convertStat($stat),
$durationMs,
$sampleRate,
$this->normalizeTags($this->mergeWithDefaultTags($tags))
Expand All @@ -57,10 +60,10 @@ public function timing(string|\UnitEnum $stat, float $durationMs, float $sampleR
/**
* @inheritDoc
*/
public function gauge(string|\UnitEnum $stat, float $value, float $sampleRate = 1.0, array $tags = []): void
public function gauge(string|UnitEnum $stat, float $value, float $sampleRate = 1.0, array $tags = []): void
{
$this->datadogClient->gauge(
$stat,
$this->convertStat($stat),
$value,
$sampleRate,
$this->normalizeTags($this->mergeWithDefaultTags($tags))
Expand All @@ -70,10 +73,10 @@ public function gauge(string|\UnitEnum $stat, float $value, float $sampleRate =
/**
* @inheritDoc
*/
public function histogram(string|\UnitEnum $stat, float $value, float $sampleRate = 1.0, array $tags = []): void
public function histogram(string|UnitEnum $stat, float $value, float $sampleRate = 1.0, array $tags = []): void
{
$this->datadogClient->histogram(
$stat,
$this->convertStat($stat),
$value,
$sampleRate,
$this->normalizeTags($this->mergeWithDefaultTags($tags))
Expand All @@ -83,10 +86,10 @@ public function histogram(string|\UnitEnum $stat, float $value, float $sampleRat
/**
* @inheritDoc
*/
public function distribution(string|\UnitEnum $stat, float $value, float $sampleRate = 1.0, array $tags = []): void
public function distribution(string|UnitEnum $stat, float $value, float $sampleRate = 1.0, array $tags = []): void
{
$this->datadogClient->distribution(
$stat,
$this->convertStat($stat),
$value,
$sampleRate,
$this->normalizeTags($this->mergeWithDefaultTags($tags))
Expand All @@ -96,10 +99,10 @@ public function distribution(string|\UnitEnum $stat, float $value, float $sample
/**
* @inheritDoc
*/
public function set(string|\UnitEnum $stat, float|string $value, float $sampleRate = 1.0, array $tags = []): void
public function set(string|UnitEnum $stat, float|string $value, float $sampleRate = 1.0, array $tags = []): void
{
$this->datadogClient->set(
$stat,
$this->convertStat($stat),
$value,
$sampleRate,
$this->normalizeTags($this->mergeWithDefaultTags($tags))
Expand All @@ -109,10 +112,10 @@ public function set(string|\UnitEnum $stat, float|string $value, float $sampleRa
/**
* @inheritDoc
*/
public function increment(array|string|\UnitEnum $stats, float $sampleRate = 1.0, array $tags = [], int $value = 1): void
public function increment(array|string|UnitEnum $stats, float $sampleRate = 1.0, array $tags = [], int $value = 1): void
{
$this->datadogClient->increment(
$stats,
$this->convertStat($stats),
$sampleRate,
$this->normalizeTags($this->mergeWithDefaultTags($tags)),
$value
Expand All @@ -122,10 +125,10 @@ public function increment(array|string|\UnitEnum $stats, float $sampleRate = 1.0
/**
* @inheritDoc
*/
public function decrement(array|string|\UnitEnum $stats, float $sampleRate = 1.0, array $tags = [], int $value = -1): void
public function decrement(array|string|UnitEnum $stats, float $sampleRate = 1.0, array $tags = [], int $value = -1): void
{
$this->datadogClient->decrement(
$stats,
$this->convertStat($stats),
$sampleRate,
$this->normalizeTags($this->mergeWithDefaultTags($tags)),
$value
Expand All @@ -135,10 +138,10 @@ public function decrement(array|string|\UnitEnum $stats, float $sampleRate = 1.0
/**
* @inheritDoc
*/
public function updateStats(array|string|\UnitEnum $stats, int $delta = 1, $sampleRate = 1.0, array $tags = null): void
public function updateStats(array|string|UnitEnum $stats, int $delta = 1, $sampleRate = 1.0, array $tags = null): void
{
$this->datadogClient->updateStats(
$stats,
$this->convertStat($stats),
$delta,
$sampleRate,
$this->normalizeTags($this->mergeWithDefaultTags($tags))
Expand Down

0 comments on commit 1707b5a

Please sign in to comment.