Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
6eef6957
Commit
6eef6957
authored
Jul 17, 2019
by
Peter Leitzen
Committed by
Sean McGivern
Jul 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show threshold in incident title for gitlab alerts
Rename `#email_subject` to `#full_title`
parent
d0d318ff
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
52 additions
and
11 deletions
+52
-11
ee/app/mailers/ee/emails/projects.rb
ee/app/mailers/ee/emails/projects.rb
+1
-1
ee/app/presenters/projects/prometheus/alert_presenter.rb
ee/app/presenters/projects/prometheus/alert_presenter.rb
+2
-2
ee/app/services/incident_management/create_issue_service.rb
ee/app/services/incident_management/create_issue_service.rb
+1
-1
ee/changelogs/unreleased/pl-full-title-incident-issues.yml
ee/changelogs/unreleased/pl-full-title-incident-issues.yml
+5
-0
ee/spec/mailers/ee/emails/projects_spec.rb
ee/spec/mailers/ee/emails/projects_spec.rb
+1
-1
ee/spec/presenters/projects/prometheus/alert_presenter_spec.rb
...ec/presenters/projects/prometheus/alert_presenter_spec.rb
+18
-6
ee/spec/services/incident_management/create_issue_service_spec.rb
...services/incident_management/create_issue_service_spec.rb
+24
-0
No files found.
ee/app/mailers/ee/emails/projects.rb
View file @
6eef6957
...
...
@@ -26,7 +26,7 @@ module EE
.
present
return
unless
@alert
.
valid?
subject_text
=
"Alert:
#{
@alert
.
email_subject
}
"
subject_text
=
"Alert:
#{
@alert
.
full_title
}
"
mail
(
to:
recipient
(
user_id
,
@project
.
group
),
subject:
subject
(
subject_text
))
end
end
...
...
ee/app/presenters/projects/prometheus/alert_presenter.rb
View file @
6eef6957
...
...
@@ -3,8 +3,8 @@
module
Projects
module
Prometheus
class
AlertPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
def
email_subject
[
environment_name
,
alert_title
].
compact
.
join
(
' '
)
def
full_title
[
environment_name
,
alert_title
].
compact
.
join
(
'
:
'
)
end
def
project_full_path
...
...
ee/app/services/incident_management/create_issue_service.rb
View file @
6eef6957
...
...
@@ -29,7 +29,7 @@ module IncidentManagement
end
def
issue_title
alert
.
title
alert
.
full_
title
end
def
issue_description
...
...
ee/changelogs/unreleased/pl-full-title-incident-issues.yml
0 → 100644
View file @
6eef6957
---
title
:
Show threshold in incident title for gitlab alerts
merge_request
:
14688
author
:
type
:
changed
ee/spec/mailers/ee/emails/projects_spec.rb
View file @
6eef6957
...
...
@@ -46,7 +46,7 @@ describe EE::Emails::Projects do
it_behaves_like
'a user cannot unsubscribe through footer link'
it
'has expected subject'
do
is_expected
.
to
have_subject
(
"
#{
project
.
name
}
| Alert:
#{
environment
.
name
}
#{
title
}
for 5 minutes"
)
is_expected
.
to
have_subject
(
"
#{
project
.
name
}
| Alert:
#{
environment
.
name
}
:
#{
title
}
for 5 minutes"
)
end
it
'has expected content'
do
...
...
ee/spec/presenters/projects/prometheus/alert_presenter_spec.rb
View file @
6eef6957
...
...
@@ -75,16 +75,16 @@ describe Projects::Prometheus::AlertPresenter do
create
(
:alerting_alert
,
project:
project
,
metric_id:
metric_id
)
end
describe
'#
email_subject
'
do
describe
'#
full_title
'
do
let
(
:query_title
)
do
"
#{
gitlab_alert
.
title
}
#{
gitlab_alert
.
computed_operator
}
#{
gitlab_alert
.
threshold
}
for 5 minutes"
end
let
(
:expected_subject
)
do
"
#{
alert
.
environment
.
name
}
#{
query_title
}
"
"
#{
alert
.
environment
.
name
}
:
#{
query_title
}
"
end
subject
{
presenter
.
email_subject
}
subject
{
presenter
.
full_title
}
it
{
is_expected
.
to
eq
(
expected_subject
)
}
end
...
...
@@ -114,11 +114,23 @@ describe Projects::Prometheus::AlertPresenter do
end
context
'without gitlab alert'
do
describe
'#
email_subject
'
do
subject
{
presenter
.
email_subject
}
describe
'#
full_title
'
do
subject
{
presenter
.
full_title
}
context
'with title'
do
let
(
:title
)
{
'some title'
}
before
do
expect
(
alert
).
to
receive
(
:title
).
and_return
(
title
)
end
it
{
is_expected
.
to
eq
(
title
)
}
end
context
'without title'
do
it
{
is_expected
.
to
eq
(
''
)
}
end
end
describe
'#metric_query'
do
subject
{
presenter
.
metric_query
}
...
...
ee/spec/services/incident_management/create_issue_service_spec.rb
View file @
6eef6957
...
...
@@ -101,6 +101,30 @@ describe IncidentManagement::CreateIssueService do
end
end
context
'with gitlab alert'
do
let
(
:gitlab_alert
)
{
create
(
:prometheus_alert
,
project:
project
)
}
before
do
alert_payload
[
'labels'
]
=
{
'gitlab_alert_id'
=>
gitlab_alert
.
prometheus_metric_id
.
to_s
}
end
it
'creates an issue'
do
query_title
=
"
#{
gitlab_alert
.
title
}
#{
gitlab_alert
.
computed_operator
}
#{
gitlab_alert
.
threshold
}
"
expect
(
subject
).
to
include
(
status: :success
)
expect
(
issue
.
author
).
to
eq
(
User
.
alert_bot
)
expect
(
issue
.
title
).
to
eq
(
alert_presenter
.
full_title
)
expect
(
issue
.
title
).
to
include
(
gitlab_alert
.
environment
.
name
)
expect
(
issue
.
title
).
to
include
(
query_title
)
expect
(
issue
.
title
).
to
include
(
'for 5 minutes'
)
expect
(
issue
.
description
).
to
include
(
alert_presenter
.
issue_summary_markdown
)
expect
(
issue
.
description
).
not_to
include
(
summary_separator
)
end
end
describe
'with invalid alert payload'
do
shared_examples
'invalid alert'
do
it
'does not create an issue'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment