From 6c046fdcb595d9c37c15e0c242efa04e5411c604 Mon Sep 17 00:00:00 2001 From: cyve Date: Thu, 11 May 2023 17:05:34 +0200 Subject: [PATCH] fix: typo in healthcheck --- docs/health/adding-a-healthcheck.md | 6 +++--- readme.md | 2 +- src/DependencyInjection/Extension.php | 6 +++--- src/DependencyInjection/routes/health.php | 2 +- src/Health/Controller/Endpoint.php | 14 +++++++------- ...checkInterface.php => HealthcheckInterface.php} | 11 +++++++++-- 6 files changed, 24 insertions(+), 17 deletions(-) rename src/Health/{HealtcheckInterface.php => HealthcheckInterface.php} (80%) diff --git a/docs/health/adding-a-healthcheck.md b/docs/health/adding-a-healthcheck.md index 99638f3..cbb5659 100644 --- a/docs/health/adding-a-healthcheck.md +++ b/docs/health/adding-a-healthcheck.md @@ -3,10 +3,10 @@ ```php namespace App\Health; -use Instrumentation\Health\HealtcheckInterface; +use Instrumentation\Health\HealthcheckInterface; use Symfony\Component\HttpFoundation\RequestStack; -class DummyHealthcheck implements HealtcheckInterface +class DummyHealthcheck implements HealthcheckInterface { public function __construct(private RequestStack $requestStack) { @@ -28,7 +28,7 @@ class DummyHealthcheck implements HealtcheckInterface return $header; } - return HealtcheckInterface::HEALTHY; + return HealthcheckInterface::HEALTHY; } public function getStatusMessage(): ?string diff --git a/readme.md b/readme.md index b47a9c5..90f3e23 100644 --- a/readme.md +++ b/readme.md @@ -23,7 +23,7 @@ #### Health - A simple endpoint to expose application health (default: `/_healthz`) -- Autoconfigurable healthcheck interface to add healtchecks to be made for global application health +- Autoconfigurable healthcheck interface to add healthchecks to be made for global application health ### Installation and configuration diff --git a/src/DependencyInjection/Extension.php b/src/DependencyInjection/Extension.php index 551f004..379372c 100644 --- a/src/DependencyInjection/Extension.php +++ b/src/DependencyInjection/Extension.php @@ -9,7 +9,7 @@ namespace Instrumentation\DependencyInjection; -use Instrumentation\Health\HealtcheckInterface; +use Instrumentation\Health\HealthcheckInterface; use Instrumentation\Metrics\MetricProviderInterface; use Instrumentation\Metrics\RegistryInterface; use Instrumentation\Metrics\Storage\HostnamePrefixedRedisFactory; @@ -197,9 +197,9 @@ protected function loadHealth(array $config, ContainerBuilder $container): void $loader->load('health.php'); $this->addPathToBlacklist($config['path'], $container); - $container->setParameter('app.path.healtcheck', $config['path']); + $container->setParameter('app.path.healthcheck', $config['path']); - $container->registerForAutoconfiguration(HealtcheckInterface::class)->addTag('app.healthcheck'); + $container->registerForAutoconfiguration(HealthcheckInterface::class)->addTag('app.healthcheck'); } /** diff --git a/src/DependencyInjection/routes/health.php b/src/DependencyInjection/routes/health.php index 5352723..e351323 100644 --- a/src/DependencyInjection/routes/health.php +++ b/src/DependencyInjection/routes/health.php @@ -11,7 +11,7 @@ use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; return function (RoutingConfigurator $routes) { - $routes->add('_healthz', '%app.path.healtcheck%') + $routes->add('_healthz', '%app.path.healthcheck%') ->controller(Endpoint::class) ->methods(['GET']); }; diff --git a/src/Health/Controller/Endpoint.php b/src/Health/Controller/Endpoint.php index e0d97c6..3f14e77 100644 --- a/src/Health/Controller/Endpoint.php +++ b/src/Health/Controller/Endpoint.php @@ -9,7 +9,7 @@ namespace Instrumentation\Health\Controller; -use Instrumentation\Health\HealtcheckInterface; +use Instrumentation\Health\HealthcheckInterface; use Instrumentation\Metrics\MetricProviderInterface; use Instrumentation\Metrics\RegistryInterface; use OpenTelemetry\SDK\Resource\ResourceInfo; @@ -29,7 +29,7 @@ public static function getProvidedMetrics(): array } /** - * @param iterable $checks + * @param iterable $checks */ public function __construct(private ResourceInfo $resourceInfo, private iterable $checks, private RegistryInterface|null $registry = null, private Profiler|null $profiler = null) { @@ -47,7 +47,7 @@ public function __invoke(): JsonResponse $hasDegraded = false; foreach ($this->checks as $check) { - if (HealtcheckInterface::HEALTHY != $check->getStatus()) { + if (HealthcheckInterface::HEALTHY != $check->getStatus()) { $hasDegraded = true; if ($check->isCritical()) { $hasDegradedCritical = true; @@ -63,14 +63,14 @@ public function __invoke(): JsonResponse ]; } - $status = HealtcheckInterface::HEALTHY; + $status = HealthcheckInterface::HEALTHY; $statusInt = 2; if ($hasDegraded) { - $status = HealtcheckInterface::DEGRADED; + $status = HealthcheckInterface::DEGRADED; $statusInt = 1; } if ($hasDegradedCritical) { - $status = HealtcheckInterface::UNHEALTHY; + $status = HealthcheckInterface::UNHEALTHY; $statusInt = 0; } @@ -80,6 +80,6 @@ public function __invoke(): JsonResponse $this->registry->getGauge('app_health')->set($statusInt); } - return new JsonResponse($results, HealtcheckInterface::UNHEALTHY === $status ? 500 : 200); + return new JsonResponse($results, HealthcheckInterface::UNHEALTHY === $status ? 500 : 200); } } diff --git a/src/Health/HealtcheckInterface.php b/src/Health/HealthcheckInterface.php similarity index 80% rename from src/Health/HealtcheckInterface.php rename to src/Health/HealthcheckInterface.php index 4cf365f..61e1371 100644 --- a/src/Health/HealtcheckInterface.php +++ b/src/Health/HealthcheckInterface.php @@ -9,7 +9,14 @@ namespace Instrumentation\Health; -interface HealtcheckInterface +/** + * @deprecated + */ +interface HealtcheckInterface extends HealthcheckInterface +{ +} + +interface HealthcheckInterface { public const HEALTHY = 'healthy'; public const DEGRADED = 'degraded'; @@ -27,7 +34,7 @@ public function getDescription(): string|null; public function getStatusMessage(): string|null; /** - * @return string One of the HealtcheckInterface constants + * @return string One of the HealthcheckInterface constants */ public function getStatus(): string;