Skip to content

Commit 1de58b1

Browse files
authored
Use StrCache instead of Str in special cases. (#5866)
1 parent ba3ce0d commit 1de58b1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Adapter/InfluxDB/MetricFactory.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use Hyperf\Metric\Contract\GaugeInterface;
2323
use Hyperf\Metric\Contract\HistogramInterface;
2424
use Hyperf\Metric\Contract\MetricFactoryInterface;
25-
use Hyperf\Stringable\Str;
25+
use Hyperf\Stringable\StrCache;
2626
use InfluxDB\Client;
2727
use InfluxDB\Database;
2828
use InfluxDB\Database\RetentionPolicy;
@@ -129,6 +129,6 @@ protected function createPoint(Sample $sample): Point
129129
private function getNamespace(): string
130130
{
131131
$name = $this->config->get("metric.metric.{$this->name}.namespace");
132-
return preg_replace('#[^a-zA-Z0-9:_]#', '_', Str::snake($name));
132+
return preg_replace('#[^a-zA-Z0-9:_]#', '_', StrCache::snake($name));
133133
}
134134
}

src/Adapter/Prometheus/MetricFactory.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Hyperf\Metric\Exception\RuntimeException;
3131
use Hyperf\Metric\MetricFactoryPicker;
3232
use Hyperf\Stringable\Str;
33+
use Hyperf\Stringable\StrCache;
3334
use Hyperf\Support\Network;
3435
use Prometheus\CollectorRegistry;
3536
use Prometheus\Exception\MetricsRegistrationException;
@@ -171,7 +172,7 @@ protected function customHandle(): void
171172
private function getNamespace(): string
172173
{
173174
$name = $this->config->get("metric.metric.{$this->name}.namespace");
174-
return preg_replace('#[^a-zA-Z0-9:_]#', '_', Str::snake($name));
175+
return preg_replace('#[^a-zA-Z0-9:_]#', '_', StrCache::snake($name));
175176
}
176177

177178
private function getUri(string $address, string $job): string

0 commit comments

Comments
 (0)