Skip to content

Commit

Permalink
Fix duplicate metric error
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed May 28, 2024
1 parent 9c91982 commit 10f80be
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Traits/Google/MetricTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand All @@ -25,4 +31,4 @@ public function addMetrics(string ...$metrics): self

return $this;
}
}
}

0 comments on commit 10f80be

Please sign in to comment.