diff --git a/src/Traits/Google/MetricTrait.php b/src/Traits/Google/MetricTrait.php index 64dc23f..1995f3e 100644 --- a/src/Traits/Google/MetricTrait.php +++ b/src/Traits/Google/MetricTrait.php @@ -10,6 +10,12 @@ trait MetricTrait public function addMetric(string $name): self { + foreach ($this->metrics as $metric) { + if ($metric->getName() === $name) { + return $this; + } + } + $this->metrics[] = new Metric([ 'name' => $name, ]); @@ -25,4 +31,4 @@ public function addMetrics(string ...$metrics): self return $this; } -} +} \ No newline at end of file