omniaretail / nimator

Light-weight adhoc framework for creating monitoring apps with c-sharp based system-checks.
MIT License
10 stars 9 forks source link

Make OpsGenie Heartbeat optional #15

Open jeroenheijmans opened 8 years ago

jeroenheijmans commented 8 years ago

Suppose these settings for a notifier:

{
  "$type": "Nimator.Settings.OpsGenieSettings, Nimator",
  "Threshold": "Error",
  "ApiKey": "correct-api-key-here",
  "TeamName": "ops_team",
  "HeartbeatName":  "nimator"  
}

If you have a default trial account with OpsGenie, this will generate this kind of error:

Nimator.NotificationException: One or more notifiers could not notify. ---> Nimator.NotificationCommunicationException: Notification failed with '400 BadRequest' for Url https://api.opsgenie.com/v1/json/heartbeat/send ---> System.Net.WebException: The remote server returned an error: (400) Bad Request.

It does so because by default there is no heartbeat avaible. (If you create a heartbeat of the correct name things will work, obviously.)

Removing the HeartbeatName from the settings entirely, or setting it to an empty string will cause an ArgumentException in the OpsGenieNotifier constructor. However, it would be quite reasonable to have no heartbeat configured in case you don't want to use them.

Long story short: please make HeartbeatName optional, and don't try to push heartbeat notifications if it IsNullOrWhitespace.