Skip to content

Commit

Permalink
Optimized code.
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo committed Jan 4, 2021
1 parent 9806f4e commit 7b97b42
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Adapter/Prometheus/MetricFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private function getNamespace(): string
private function guardConfig()
{
if ($this->config->get("metric.metric.{$this->name}.mode") == Constants::SCRAPE_MODE
&& $this->config->get('metric.use_standalone_process') == false) {
&& $this->config->get('metric.use_standalone_process', true) == false) {
throw new RuntimeException(
"Prometheus in scrape mode must be used in conjunction with standalone process. \n Set metric.use_standalone_process to true to avoid this error."
);
Expand Down
2 changes: 1 addition & 1 deletion src/MetricFactoryPicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __invoke(ContainerInterface $container)
}

$config = $container->get(ConfigInterface::class);
$useStandaloneProcess = $config->get('metric.use_standalone_process');
$useStandaloneProcess = $config->get('metric.use_standalone_process', true);

// misconfiguration.
if ($useStandaloneProcess && ! static::$isCommand && empty(ProcessCollector::all())) {
Expand Down
2 changes: 1 addition & 1 deletion src/Process/MetricProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MetricProcess extends AbstractProcess
public function isEnable($server): bool
{
$config = $this->container->get(ConfigInterface::class);
return $server instanceof Server && $config->get('metric.use_standalone_process') ?? false;
return $server instanceof Server && $config->get('metric.use_standalone_process', true);
}

public function handle(): void
Expand Down

0 comments on commit 7b97b42

Please sign in to comment.