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

Task Scheduling monitoring? #89

Closed
nekhbet opened this issue Dec 1, 2023 · 3 comments
Closed

Task Scheduling monitoring? #89

nekhbet opened this issue Dec 1, 2023 · 3 comments

Comments

@nekhbet
Copy link

nekhbet commented Dec 1, 2023

This would be a super awesome feature.

@jessarcher
Copy link
Member

Thanks for the suggestion. What sort of metrics would you be thinking? I guess slow scheduled tasks?

Not sure if/when we'll get to this, but in the meantime it's possible to create a custom card and recorder for this. I'll be updating the docs with more instructions next week.

@eusonlito
Copy link

Hi @jessarcher! I would love this feature too!

I have created a Pulse card to monitor the size of the tables in a database, but I don't need to do it on every global check, doing it once every hour would be enough: https://github.com/eusonlito/LaravelPulseDatabaseTablesSize

How do you think I should deal with this? Maybe applying check logic on the last stored record and compare the timestamp with the current time?

Thanks!

@eusonlito
Copy link

Currently I'm using this control:

    /**
     * @param \Laravel\Pulse\Events\SharedBeat $event
     *
     * @return void
     */
    public function record(SharedBeat $event): void
    {
        if ($this->enabled()) {
            $this->set();
        }
    }

    /**
     * @return bool
     */
    protected function enabled(): bool
    {
        return $this->enabledConfig()
            && $this->enabledSchedule();
    }

    /**
     * @return bool
     */
    protected function enabledConfig(): bool
    {
        return $this->config('enabled');
    }

    /**
     * @return bool
     */
    protected function enabledSchedule(): bool
    {
        $timestamp = $this->pulse->values('database-tables-size', ['result'])->value('timestamp');

        if (empty($timestamp)) {
            return true;
        }

        $time = match ($this->config('schedule')) {
            'halfhour' => strtotime('-30 minutes'),
            'hour' => strtotime('-1 hour'),
            'quarterday' => strtotime('-4 hours'),
            'halfday' => strtotime('-12 hours'),
            'day' => strtotime('-1 day'),
            default => 0,
        };

        return $timestamp <= $time;
    }

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

No branches or pull requests

3 participants