Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add check for LiipMonitoring-Bundle (WIP) #61

Open
wants to merge 3 commits into
base: 1.x
Choose a base branch
from

Conversation

Chris53897
Copy link
Contributor

i try to add checks for LiipMonitoring-Bundle
#11

But i am a bit stucked here.

I followed the example from here https://github.com/kbond/LiipMonitorBundle/tree/feat/ohdear#custom-checks
and took this Check as example https://github.com/kbond/LiipMonitorBundle/blob/feat/ohdear/src/Check/Symfony/SymfonyVersionCheck.php

I thought i could activated it like this.

liip_monitor:
    checks:
        symfony_worker_running: true

And see it with php bin/console monitor:list

But i will get an error, that symfony_worker_running is not registered unter checks.

@kbond Maybe you can give me a little push to the right direction?

composer.json Outdated Show resolved Hide resolved
@kbond
Copy link
Member

kbond commented Feb 18, 2024

Ah yes, this is a bit tricky and we'll have to make a decision on "where the config should live".

Option 1 - Config lives in liip_monitor: For this, we'd need a way to bundles (like this one), to announce to LiipMonitorBundle that it has a configurable check. I do something similar in ZenstruckBackupBundle but it isn't extensible (the extra config options are hard-coded). What we need is sort of a pre-compile container that has the liip_monitor check config factories tagged. I'm not sure this is possible - we might have to use composer.json config - in LiipMonitorBundle's extension, look for all installed packages that have a specific key in their composer.json. This will probably get complex...

Option 2 - Config lives in this bundle: For this, we'd add a liip_monitor key to this bundle's config that's only available when LiipMonitorBundle is enabled. You can then have WorkerRunningCheck implement Liip\Monitor\DependencyInjection\ConfigurableCheck but we'd have to add the config manually to this bundle.

Option 1 seems ideal but 2 seems easiest.

Co-authored-by: Kevin Bond <[email protected]>
@Chris53897
Copy link
Contributor Author

Thanks for the info.
I will have a deeper look, as soon i have some free time.

@Chris53897
Copy link
Contributor Author

If someone is interested in a quick solution in userland code.
I added a check via https://github.com/ohdearapp/health-check-results

use Zenstruck\Messenger\Monitor\Twig\ViewHelper;

public function __construct(private readonly ViewHelper $viewHelper)
    {}

 ...
        $amountWorkers = $this->viewHelper->workers->count();

        if($amountWorkers == 0)
        {
            $checkResult = new CheckResult(
                name: 'SymfonyMessengerWorker',
                label: 'Running SymfonyMessengerWorker',
                notificationMessage: 'There are '.$amountWorkers.' workers running',
                shortSummary: $amountWorkers.' running',
                status: CheckResult::STATUS_FAILED,
                meta: ['workers' => $amountWorkers]
            );

            $checkResults->addCheckResult($checkResult);
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants