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
4ce65778
Commit
4ce65778
authored
Mar 13, 2020
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tweak logging in worker
parent
270ed1e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
11 deletions
+7
-11
ee/app/workers/status_page/publish_incident_worker.rb
ee/app/workers/status_page/publish_incident_worker.rb
+3
-7
ee/spec/workers/status_page/publish_incident_worker_spec.rb
ee/spec/workers/status_page/publish_incident_worker_spec.rb
+4
-4
No files found.
ee/app/workers/status_page/publish_incident_worker.rb
View file @
4ce65778
...
@@ -30,10 +30,7 @@ module StatusPage
...
@@ -30,10 +30,7 @@ module StatusPage
.
new
(
user:
user
,
project:
project
,
issue_id:
issue_id
)
.
new
(
user:
user
,
project:
project
,
issue_id:
issue_id
)
.
execute
.
execute
log_error
(
result
.
message
)
if
result
.
error?
log_info
(
result
.
message
)
if
result
.
error?
rescue
=>
e
log_error
(
e
.
message
)
raise
end
end
def
user
def
user
...
@@ -44,9 +41,8 @@ module StatusPage
...
@@ -44,9 +41,8 @@ module StatusPage
strong_memoize
(
:project
)
{
Project
.
find_by_id
(
project_id
)
}
strong_memoize
(
:project
)
{
Project
.
find_by_id
(
project_id
)
}
end
end
def
log_error
(
message
)
def
log_info
(
message
)
preamble
=
"Failed to publish incident for project_id=
#{
project_id
}
, issue_id=
#{
issue_id
}
"
logger
.
info
(
structured_payload
(
message:
message
))
logger
.
error
(
"
#{
preamble
}
:
#{
message
}
"
)
end
end
end
end
end
end
ee/spec/workers/status_page/publish_incident_worker_spec.rb
View file @
4ce65778
...
@@ -50,9 +50,10 @@ describe StatusPage::PublishIncidentWorker do
...
@@ -50,9 +50,10 @@ describe StatusPage::PublishIncidentWorker do
let
(
:error_message
)
{
'some message'
}
let
(
:error_message
)
{
'some message'
}
let
(
:service_result
)
{
ServiceResponse
.
error
(
message:
error_message
)
}
let
(
:service_result
)
{
ServiceResponse
.
error
(
message:
error_message
)
}
it
'succeeds and logs the error
s
'
do
it
'succeeds and logs the error'
do
expect
(
logger
)
expect
(
logger
)
.
to
receive
(
:error
).
with
(
/
#{
error_message
}
/
)
.
to
receive
(
:info
)
.
with
(
a_hash_including
(
'message'
=>
error_message
))
.
exactly
(
worker_exec_times
).
times
.
exactly
(
worker_exec_times
).
times
subject
subject
...
@@ -64,10 +65,9 @@ describe StatusPage::PublishIncidentWorker do
...
@@ -64,10 +65,9 @@ describe StatusPage::PublishIncidentWorker do
let
(
:error_message
)
{
'some exception'
}
let
(
:error_message
)
{
'some exception'
}
let
(
:exception
)
{
StandardError
.
new
(
error_message
)
}
let
(
:exception
)
{
StandardError
.
new
(
error_message
)
}
it
'
logs and
re-raises exception'
do
it
're-raises exception'
do
allow
(
service
).
to
receive
(
:execute
).
and_raise
(
exception
)
allow
(
service
).
to
receive
(
:execute
).
and_raise
(
exception
)
expect
(
logger
).
to
receive
(
:error
).
with
(
/
#{
error_message
}
/
)
expect
{
subject
}.
to
raise_error
(
exception
)
expect
{
subject
}.
to
raise_error
(
exception
)
end
end
end
end
...
...
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