artprima / prometheus-metrics-bundle

Symfony 5/6 Prometheus Metrics Bundle
MIT License
133 stars 29 forks source link

Symfony5 bug in MetricsGeneratorInterface #10

Closed Adrians-G closed 4 years ago

Adrians-G commented 4 years ago

Hi, tried to set this up for Symfony5 and I have problem with these 2 methods from MetricsGeneratorInterface

    // called on the `kernel.request` event
    public function collectRequest(GetResponseEvent $event): void
    {
        $request = $event->getRequest();
        $requestMethod = $request->getMethod();
        $requestRoute = $request->attributes->get('_route');

        // do not track "OPTIONS" requests
        if ('OPTIONS' === $requestMethod) {
            return;
        }

        $this->incRequestsTotal($requestMethod, $requestRoute);
    }

    // called on the `kernel.terminate` event
    public function collectResponse(PostResponseEvent $event): void
    {
        $response = $event->getResponse();
        $request = $event->getRequest();

        $requestMethod = $request->getMethod();
        $requestRoute = $request->attributes->get('_route');

        $this->incResponsesTotal($requestMethod, $requestRoute);
    }

GetResponseEvent is renamed to RequestEvent PostResponseEvent is renamed to TerminateEvent

So it throws an exception.

Reference to docs about changes - https://symfony.com/blog/new-in-symfony-4-3-simpler-event-dispatching

Adrians-G commented 4 years ago

I see that you already added a fix for this in the dev branch. How far is that from releasing tag?

denisvmedia commented 4 years ago

@Adrians-G I've just added a new tag: 1.3.0.