LiipMonitorBundle icon indicating copy to clipboard operation
LiipMonitorBundle copied to clipboard

No route found - Using app with autoconfigure:true

Open igordeveloper opened this issue 3 years ago • 10 comments

Hi guys.

I'm using the configuration autoconfigure:true in my app, and the 'liip_monitor.check''check is being tagged automatically. When I' run the Health check page the check works fine, but, when i try repeat a individual custom check in the button GO the app receives the error below with route not found.

No route found for "POST http://localhost:8000/monitor/health/run/App/Diagnostics/Check/CustomCheck" (from "http://localhost:8000/monitor/health/")

My configurations:

config/services.yaml

services:
    # default configuration for services in *this* file
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

config/packages/monitor.yaml

liip_monitor:
    default_group: default
    enable_controller: true
config/routes/monitor.yaml
_monitor:
    resource: "@LiipMonitorBundle/Resources/config/routing.xml"
    prefix: /monitor/health

Custom check class

<?php

declare(strict_types=1);

namespace App\Diagnostics\Check;

use Laminas\Diagnostics\Check\CheckInterface;
use Laminas\Diagnostics\Result\Failure;
use Laminas\Diagnostics\Result\Success;

class CustomCheck implements CheckInterface
{

igordeveloper avatar Jul 26 '22 21:07 igordeveloper

Could you please help me if i'm missing some configuration?

Thank you.

igordeveloper avatar Aug 02 '22 15:08 igordeveloper

Hi @igordeveloper, sorry for the delay - I've been on vacation.

Yes, you'll need to add an alias as it's trying to match the route on the class name.

kbond avatar Aug 03 '22 11:08 kbond

Hi @igordeveloper, sorry for the delay - I've been on vacation.

Yes, you'll need to add an alias as it's trying to match the route on the class name.

Hi @kbond , no worries.

I add a alias as below, and now i have 2 entries 'Custom check' http://localhost:8000/monitor/health

    monitor.check.custom:
        class: App\Diagnostics\Check\CustomCheck
        arguments:
            - [ xhprof, apc, memcache ]
        tags:
            - { name: liip_monitor.check, alias: custom}

One of them gives an error because the route is created with 'monitor.check.mercure' and the another works.

Is there any other way to fix this, besides inserting autoconfigure: false for this service? Because my app's _defaults is set to true.

Thank you again!

igordeveloper avatar Aug 03 '22 13:08 igordeveloper

Is there any other way to fix this, besides inserting autoconfigure: false for this service

I don't think so. Some work needs to be done with how checks are auto-configured.

kbond avatar Aug 03 '22 13:08 kbond

Is there any other way to fix this, besides inserting autoconfigure: false for this service

I don't think so. Some work needs to be done with how checks are auto-configured.

Sorry, needs to be done in my configuration or bundle side?

igordeveloper avatar Aug 03 '22 13:08 igordeveloper

Right now, you'll need to add autoconfigure: false to your config to avoid 2 instances being registered:

    monitor.check.custom:
        class: App\Diagnostics\Check\CustomCheck
        autoconfigure: false
        arguments:
            - [ xhprof, apc, memcache ]
        tags:
            - { name: liip_monitor.check, alias: custom}

The bundle needs some work to avoid needing this.

kbond avatar Aug 03 '22 13:08 kbond

Right now, you'll need to add autoconfigure: false to your config to avoid 2 instances being registered:

    monitor.check.custom:
        class: App\Diagnostics\Check\CustomCheck
        autoconfigure: false
        arguments:
            - [ xhprof, apc, memcache ]
        tags:
            - { name: liip_monitor.check, alias: custom}

The bundle needs some work to avoid needing this.

ok, perfect.

thank you for the help, right now, i'll use with autoconfigure:false .

igordeveloper avatar Aug 03 '22 18:08 igordeveloper

Hi @kbond .

do you have a estimate for this work in the bundle? Can i help with a pull request suggest for this? thanks.

igordeveloper avatar Aug 10 '22 12:08 igordeveloper

I'm not immediately seeing a great path to a solution. The following is true:

  1. It's valid for a check to have multiple liip_monitor.check tags (to add to multiple groups).
  2. Some amount of users (myself included) don't care about the alias. We just want CheckInterface's auto added to the default group (and we don't use the api).

Of course, I'm open to ideas but autoconfigure: false feels like the simplest solution to me.

kbond avatar Aug 10 '22 12:08 kbond

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Oct 12 '22 09:10 stale[bot]

This issue has been automatically closed. Feel free to re-open if it is still relevant.

stale[bot] avatar Oct 22 '22 18:10 stale[bot]