fractalzombie /
frzb-metrics-power
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /** |
||
| 6 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
| 7 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||
| 8 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||
| 9 | * |
||
| 10 | * Copyright (c) 2024 Mykhailo Shtanko [email protected] |
||
| 11 | * |
||
| 12 | * For the full copyright and license information, please view the LICENSE.MD |
||
| 13 | * file that was distributed with this source code. |
||
| 14 | */ |
||
| 15 | |||
| 16 | namespace FRZB\Component\MetricsPower\OptionsResolver\Resolver; |
||
| 17 | |||
| 18 | use FRZB\Component\DependencyInjection\Attribute\AsService; |
||
| 19 | use FRZB\Component\DependencyInjection\Attribute\AsTagged; |
||
| 20 | use FRZB\Component\MetricsPower\Attribute\PrometheusOptions; |
||
|
0 ignored issues
–
show
|
|||
| 21 | use FRZB\Component\MetricsPower\Exception\MetricsRegistrationException; |
||
| 22 | use FRZB\Component\MetricsPower\Helper\CounterHelper; |
||
| 23 | use Prometheus\Exception\MetricsRegistrationException as BaseMetricsRegistrationException; |
||
| 24 | use Prometheus\Exception\StorageException; |
||
| 25 | use Prometheus\RegistryInterface; |
||
| 26 | use Symfony\Component\DependencyInjection\Attribute\Autowire; |
||
| 27 | use Symfony\Component\Messenger\Event\AbstractWorkerMessageEvent; |
||
| 28 | use Symfony\Component\Messenger\Event\SendMessageToTransportsEvent; |
||
| 29 | use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent; |
||
| 30 | use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent; |
||
| 31 | use Symfony\Component\Messenger\Event\WorkerMessageReceivedEvent; |
||
| 32 | use Symfony\Component\Messenger\Event\WorkerMessageRetriedEvent; |
||
| 33 | |||
| 34 | #[AsService, AsTagged(OptionsResolverInterface::class)] |
||
| 35 | class PrometheusOptionsResolver implements OptionsResolverInterface |
||
| 36 | { |
||
| 37 | public function __construct( |
||
| 38 | #[Autowire(env: 'PROMETHEUS_NAMESPACE')] |
||
| 39 | private readonly string $namespace, |
||
| 40 | private readonly RegistryInterface $registry, |
||
| 41 | ) {} |
||
| 42 | |||
| 43 | /** @throws MetricsRegistrationException */ |
||
| 44 | public function resolve(AbstractWorkerMessageEvent|SendMessageToTransportsEvent $event, PrometheusOptions $options): void |
||
| 45 | { |
||
| 46 | $postfix = match ($event::class) { |
||
| 47 | WorkerMessageFailedEvent::class => 'failed', |
||
| 48 | WorkerMessageHandledEvent::class => 'handled', |
||
| 49 | WorkerMessageReceivedEvent::class => 'received', |
||
| 50 | WorkerMessageRetriedEvent::class => 'retried', |
||
| 51 | SendMessageToTransportsEvent::class => 'sent', |
||
| 52 | }; |
||
| 53 | |||
| 54 | try { |
||
| 55 | $this->registry |
||
| 56 | ->getOrRegisterCounter($this->namespace, CounterHelper::makeName($options, postfix: $postfix), $options->help, $options->labels) |
||
| 57 | ->inc($options->values); |
||
| 58 | } catch (BaseMetricsRegistrationException $e) { |
||
| 59 | throw MetricsRegistrationException::fromThrowable($e); |
||
| 60 | } catch (StorageException $e) {} |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
| 61 | } |
||
| 62 | |||
| 63 | public static function getType(): string |
||
| 64 | { |
||
| 65 | return PrometheusOptions::class; |
||
| 66 | } |
||
| 67 | } |
||
| 68 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths