From 0b1f20d0de138295ce4b2da4abf3b413422f1876 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Fri, 23 Oct 2020 16:12:53 -0400 Subject: [PATCH] Improve code documentation --- alerting/config.go | 14 +++++++++++--- alerting/provider/pagerduty/pagerduty.go | 4 +++- metric/metric.go | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/alerting/config.go b/alerting/config.go index ef617e67..d008fa6a 100644 --- a/alerting/config.go +++ b/alerting/config.go @@ -7,9 +7,17 @@ import ( "github.com/TwinProduction/gatus/alerting/provider/twilio" ) +// Config is the configuration for alerting providers type Config struct { - Slack *slack.AlertProvider `yaml:"slack"` + // Slack is the configuration for the slack alerting provider + Slack *slack.AlertProvider `yaml:"slack"` + + // Pagerduty is the configuration for the pagerduty alerting provider PagerDuty *pagerduty.AlertProvider `yaml:"pagerduty"` - Twilio *twilio.AlertProvider `yaml:"twilio"` - Custom *custom.AlertProvider `yaml:"custom"` + + // Twilio is the configuration for the twilio alerting provider + Twilio *twilio.AlertProvider `yaml:"twilio"` + + // Custom is the configuration for the custom alerting provider + Custom *custom.AlertProvider `yaml:"custom"` } diff --git a/alerting/provider/pagerduty/pagerduty.go b/alerting/provider/pagerduty/pagerduty.go index 29e0412a..9780ccd7 100644 --- a/alerting/provider/pagerduty/pagerduty.go +++ b/alerting/provider/pagerduty/pagerduty.go @@ -16,7 +16,9 @@ func (provider *AlertProvider) IsValid() bool { return len(provider.IntegrationKey) == 32 } -// https://developer.pagerduty.com/docs/events-api-v2/trigger-events/ +// ToCustomAlertProvider converts the provider into a custom.AlertProvider +// +// relevant: https://developer.pagerduty.com/docs/events-api-v2/trigger-events/ func (provider *AlertProvider) ToCustomAlertProvider(service *core.Service, alert *core.Alert, result *core.Result, resolved bool) *custom.AlertProvider { var message, eventAction, resolveKey string if resolved { diff --git a/metric/metric.go b/metric/metric.go index 7ebc37b5..db1e90bf 100644 --- a/metric/metric.go +++ b/metric/metric.go @@ -15,6 +15,8 @@ var ( rwLock sync.RWMutex ) +// PublishMetricsForService publishes metrics for the given service and its result. +// These metrics will be exposed at /metrics if the metrics are enabled func PublishMetricsForService(service *core.Service, result *core.Result) { if config.Get().Metrics { rwLock.Lock()