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

Make severity timing configurable #4

Open
liviakuenzli opened this issue May 17, 2017 · 1 comment
Open

Make severity timing configurable #4

liviakuenzli opened this issue May 17, 2017 · 1 comment
Milestone

Comments

@liviakuenzli
Copy link
Contributor

Sometimes we might want the severity to differ depending on the time of day or maybe the day of week or any other daterelated timing. For a application that is mainly used by customers during working hours it is critical that a certain API works whenever the customer does, but on the weekend it is not as critical.

@ravage84 ravage84 added this to the Future milestone May 17, 2017
@ravage84 ravage84 modified the milestones: Future, 2.2.x Oct 18, 2019
@ravage84
Copy link
Member

I guess, this is more of a documentation issue. I don't think we need to specifically implement this.

Instead of simply setting a literal severity, one can do two things:

  1. Set a given severity depending on the date and/or time of the day in a simple if clause or ternary.
  2. Set a callable, e.g. a closure.

Example for 1:

use \OrcaServices\Heartbeat\Heartbeat\Sensor;

$conditionalSeverity = Sensor::STATUS_NONCRITICAL;
if ($specialDateOrTimeOfDay) {
     $conditionalSeverity = Sensor::STATUS_CRITICAL;
}

$config['App']['Heartbeat'] = [
    'name' => 'My App',
    'layout' => 'heartbeat',
    'Sensors' => [
        'Sensor with conditional Severity' => [
            'enabled' => true,
            'severity' => $conditionalSeverity,
            'class' => Some\Sensor\Class,
        ],
    ],
];

Example for 2:

use \OrcaServices\Heartbeat\Heartbeat\Sensor;

$conditonalSeverity = function() use ($specialDateOrTimeOfDay) {
    if ($specialDateOrTimeOfDay) {
         return Sensor::STATUS_CRITICAL;
    }
    return Sensor::STATUS_NONCRITICAL;
};

$config['App']['Heartbeat'] = [
    'name' => 'My App',
    'layout' => 'heartbeat',
    'Sensors' => [
        'Sensor with conditional Severity' => [
            'enabled' => true,
            'severity' => $conditionalSeverity,
            'class' => Some\Sensor\Class,
        ],
    ],
];

We could put these examples in the configuration documentation.

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

No branches or pull requests

2 participants