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
b9590f39
Commit
b9590f39
authored
Oct 23, 2020
by
Mehmet Emin INAC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send SQL queries to Sentry for ActiveRecord::StatementInvalid errors
parent
0043e4dc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
lib/gitlab/error_tracking.rb
lib/gitlab/error_tracking.rb
+7
-0
spec/lib/gitlab/error_tracking_spec.rb
spec/lib/gitlab/error_tracking_spec.rb
+15
-0
No files found.
lib/gitlab/error_tracking.rb
View file @
b9590f39
...
@@ -123,6 +123,7 @@ module Gitlab
...
@@ -123,6 +123,7 @@ module Gitlab
end
end
extra
=
sanitize_request_parameters
(
extra
)
extra
=
sanitize_request_parameters
(
extra
)
inject_sql_query_into_extra
(
exception
,
extra
)
if
sentry
&&
Raven
.
configuration
.
server
if
sentry
&&
Raven
.
configuration
.
server
Raven
.
capture_exception
(
exception
,
tags:
default_tags
,
extra:
extra
)
Raven
.
capture_exception
(
exception
,
tags:
default_tags
,
extra:
extra
)
...
@@ -149,6 +150,12 @@ module Gitlab
...
@@ -149,6 +150,12 @@ module Gitlab
filter
.
filter
(
parameters
)
filter
.
filter
(
parameters
)
end
end
def
inject_sql_query_into_extra
(
exception
,
extra
)
return
unless
exception
.
is_a?
(
ActiveRecord
::
StatementInvalid
)
extra
[
:sql
]
=
exception
.
sql
end
def
sentry_dsn
def
sentry_dsn
return
unless
Rails
.
env
.
production?
||
Rails
.
env
.
development?
return
unless
Rails
.
env
.
production?
||
Rails
.
env
.
development?
return
unless
Gitlab
.
config
.
sentry
.
enabled
return
unless
Gitlab
.
config
.
sentry
.
enabled
...
...
spec/lib/gitlab/error_tracking_spec.rb
View file @
b9590f39
...
@@ -287,5 +287,20 @@ RSpec.describe Gitlab::ErrorTracking do
...
@@ -287,5 +287,20 @@ RSpec.describe Gitlab::ErrorTracking do
expect
(
sentry_event
.
dig
(
'extra'
,
'sidekiq'
,
'args'
)).
to
eq
([
'[FILTERED]'
,
1
,
2
])
expect
(
sentry_event
.
dig
(
'extra'
,
'sidekiq'
,
'args'
)).
to
eq
([
'[FILTERED]'
,
1
,
2
])
end
end
end
end
context
'when the error is kind of an `ActiveRecord::StatementInvalid`'
do
let
(
:exception
)
{
ActiveRecord
::
StatementInvalid
.
new
(
sql: :foo
)
}
before
do
allow
(
Raven
).
to
receive
(
:capture_exception
)
end
it
'injects the sql query into extra'
do
described_class
.
track_exception
(
exception
)
expect
(
Raven
).
to
have_received
(
:capture_exception
)
.
with
(
exception
,
a_hash_including
(
extra:
a_hash_including
(
sql: :foo
)))
end
end
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