Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-15 15:09:30 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-15 15:09:30 +0300
commit33212c8ff1f99cdb896e8fc6f6450882287e0de5 (patch)
treeb29afde4eaf9623cda57ef6520db363d2db8492e /app/presenters/alert_management
parent03c73563048c1f808a4a3fb302f0dcbba37f5f76 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/presenters/alert_management')
-rw-r--r--app/presenters/alert_management/alert_presenter.rb36
-rw-r--r--app/presenters/alert_management/prometheus_alert_presenter.rb23
2 files changed, 14 insertions, 45 deletions
diff --git a/app/presenters/alert_management/alert_presenter.rb b/app/presenters/alert_management/alert_presenter.rb
index 8017bc3e0cd..231e90163be 100644
--- a/app/presenters/alert_management/alert_presenter.rb
+++ b/app/presenters/alert_management/alert_presenter.rb
@@ -6,7 +6,10 @@ module AlertManagement
include IncidentManagement::Settings
include ActionView::Helpers::UrlHelper
- MARKDOWN_LINE_BREAK = " \n".freeze
+ MARKDOWN_LINE_BREAK = " \n"
+ HORIZONTAL_LINE = "\n\n---\n\n"
+
+ delegate :metrics_dashboard_url, :runbook, to: :parsed_payload
def initialize(alert, _attributes = {})
super
@@ -16,28 +19,17 @@ module AlertManagement
end
def issue_description
- horizontal_line = "\n\n---\n\n"
-
[
issue_summary_markdown,
alert_markdown,
incident_management_setting.issue_template_content
- ].compact.join(horizontal_line)
+ ].compact.join(HORIZONTAL_LINE)
end
def start_time
started_at&.strftime('%d %B %Y, %-l:%M%p (%Z)')
end
- def issue_summary_markdown
- <<~MARKDOWN.chomp
- #{metadata_list}
- #{alert_details}#{metric_embed_for_alert}
- MARKDOWN
- end
-
- def metrics_dashboard_url; end
-
def details_url
details_project_alert_management_url(project, alert.iid)
end
@@ -49,15 +41,15 @@ module AlertManagement
private
attr_reader :alert, :project
+ delegate :alert_markdown, :full_query, to: :parsed_payload
- def alerting_alert
- strong_memoize(:alerting_alert) do
- Gitlab::Alerting::Alert.new(project: project, payload: alert.payload).present
- end
+ def issue_summary_markdown
+ <<~MARKDOWN.chomp
+ #{metadata_list}
+ #{alert_details}#{metric_embed_for_alert}
+ MARKDOWN
end
- def alert_markdown; end
-
def metadata_list
metadata = []
@@ -90,9 +82,9 @@ module AlertManagement
.join(MARKDOWN_LINE_BREAK)
end
- def metric_embed_for_alert; end
-
- def full_query; end
+ def metric_embed_for_alert
+ "\n[](#{metrics_dashboard_url})" if metrics_dashboard_url
+ end
def list_item(key, value)
"**#{key}:** #{value}".strip
diff --git a/app/presenters/alert_management/prometheus_alert_presenter.rb b/app/presenters/alert_management/prometheus_alert_presenter.rb
deleted file mode 100644
index 0e939a65d42..00000000000
--- a/app/presenters/alert_management/prometheus_alert_presenter.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# frozen_string_literal: true
-
-module AlertManagement
- class PrometheusAlertPresenter < AlertManagement::AlertPresenter
- def metrics_dashboard_url
- alerting_alert.metrics_dashboard_url
- end
-
- private
-
- def alert_markdown
- alerting_alert.alert_markdown
- end
-
- def metric_embed_for_alert
- alerting_alert.metric_embed_for_alert
- end
-
- def full_query
- alerting_alert.full_query
- end
- end
-end