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
bfe41752
Commit
bfe41752
authored
Aug 19, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
b013eede
a749fcbe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
lib/gitlab/sentry.rb
lib/gitlab/sentry.rb
+16
-1
spec/lib/gitlab/sentry_spec.rb
spec/lib/gitlab/sentry_spec.rb
+27
-2
No files found.
lib/gitlab/sentry.rb
View file @
bfe41752
...
...
@@ -39,9 +39,14 @@ module Gitlab
# development and test. If you need development and test to behave
# just the same as production you can use this instead of
# track_exception.
#
# If the exception implements the method `sentry_extra_data` and that method
# returns a Hash, then the return value of that method will be merged into
# `extra`. Exceptions can use this mechanism to provide structured data
# to sentry in addition to their message and back-trace.
def
self
.
track_acceptable_exception
(
exception
,
issue_url:
nil
,
extra:
{})
if
enabled?
extra
[
:issue_url
]
=
issue_url
if
issue_url
extra
=
build_extra_data
(
exception
,
issue_url
,
extra
)
context
# Make sure we've set everything we know in the context
Raven
.
capture_exception
(
exception
,
tags:
default_tags
,
extra:
extra
)
...
...
@@ -58,5 +63,15 @@ module Gitlab
locale:
I18n
.
locale
}
end
def
self
.
build_extra_data
(
exception
,
issue_url
,
extra
)
exception
.
try
(
:sentry_extra_data
)
&
.
tap
do
|
data
|
extra
.
merge!
(
data
)
if
data
.
is_a?
(
Hash
)
end
extra
.
merge
({
issue_url:
issue_url
}.
compact
)
end
private_class_method
:build_extra_data
end
end
spec/lib/gitlab/sentry_spec.rb
View file @
bfe41752
...
...
@@ -65,6 +65,7 @@ describe Gitlab::Sentry do
context
'.track_acceptable_exception'
do
let
(
:exception
)
{
RuntimeError
.
new
(
'boom'
)
}
let
(
:issue_url
)
{
'http://gitlab.com/gitlab-org/gitlab-ce/issues/1'
}
before
do
allow
(
described_class
).
to
receive
(
:enabled?
).
and_return
(
true
)
...
...
@@ -74,7 +75,7 @@ describe Gitlab::Sentry do
it
'calls Raven.capture_exception'
do
expected_extras
=
{
some_other_info:
'info'
,
issue_url:
'http://gitlab.com/gitlab-org/gitlab-ce/issues/1'
issue_url:
issue_url
}
expected_tags
=
{
...
...
@@ -88,9 +89,33 @@ describe Gitlab::Sentry do
described_class
.
track_acceptable_exception
(
exception
,
issue_url:
'http://gitlab.com/gitlab-org/gitlab-ce/issues/1'
,
issue_url:
issue_url
,
extra:
{
some_other_info:
'info'
}
)
end
context
'the exception implements :sentry_extra_data'
do
let
(
:extra_info
)
{
{
event:
'explosion'
,
size: :massive
}
}
let
(
:exception
)
{
double
(
message:
'bang!'
,
sentry_extra_data:
extra_info
)
}
it
'includes the extra data from the exception in the tracking information'
do
expect
(
Raven
).
to
receive
(
:capture_exception
)
.
with
(
exception
,
a_hash_including
(
extra:
a_hash_including
(
extra_info
)))
described_class
.
track_acceptable_exception
(
exception
)
end
end
context
'the exception implements :sentry_extra_data, which returns nil'
do
let
(
:exception
)
{
double
(
message:
'bang!'
,
sentry_extra_data:
nil
)
}
it
'just includes the other extra info'
do
extra_info
=
{
issue_url:
issue_url
}
expect
(
Raven
).
to
receive
(
:capture_exception
)
.
with
(
exception
,
a_hash_including
(
extra:
a_hash_including
(
extra_info
)))
described_class
.
track_acceptable_exception
(
exception
,
extra_info
)
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