diff options
author | Sean McGivern <sean@gitlab.com> | 2019-06-10 11:01:17 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-06-10 11:01:17 +0300 |
commit | 25420de654b5581ccf6254be769a5e031446eced (patch) | |
tree | becb49e413fd0dc51df483d1d1dd120dea969eb0 | |
parent | b7ebcbc06d492a1b3f28424e475f0f13efb114e6 (diff) | |
parent | 8346da6527ab4b9233605565a022ef9f05d3f4c9 (diff) |
Merge branch 'sh-add-backtrace-to-sql-queries' into 'master'
Add backtraces to Peek performance bar for SQL calls
See merge request gitlab-org/gitlab-ce!29394
-rw-r--r-- | changelogs/unreleased/sh-add-backtrace-to-sql-queries.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/performance_bar/peek_query_tracker.rb | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/changelogs/unreleased/sh-add-backtrace-to-sql-queries.yml b/changelogs/unreleased/sh-add-backtrace-to-sql-queries.yml new file mode 100644 index 00000000000..d4ca027d1b9 --- /dev/null +++ b/changelogs/unreleased/sh-add-backtrace-to-sql-queries.yml @@ -0,0 +1,5 @@ +--- +title: Add backtraces to Peek performance bar for SQL calls +merge_request: +author: +type: added diff --git a/lib/gitlab/performance_bar/peek_query_tracker.rb b/lib/gitlab/performance_bar/peek_query_tracker.rb index 16c16aa0265..3a27e26eaba 100644 --- a/lib/gitlab/performance_bar/peek_query_tracker.rb +++ b/lib/gitlab/performance_bar/peek_query_tracker.rb @@ -27,15 +27,16 @@ module Gitlab subscribe('sql.active_record') do |_, start, finish, _, data| if Gitlab::SafeRequestStore.store[:peek_enabled] unless data[:cached] - track_query(data[:sql].strip, data[:binds], start, finish) + backtrace = Gitlab::Profiler.clean_backtrace(caller) + track_query(data[:sql].strip, data[:binds], backtrace, start, finish) end end end end - def track_query(raw_query, bindings, start, finish) + def track_query(raw_query, bindings, backtrace, start, finish) duration = (finish - start) * 1000.0 - query_info = { duration: duration.round(3), sql: raw_query } + query_info = { duration: duration.round(3), sql: raw_query, backtrace: backtrace } PEEK_DB_CLIENT.query_details << query_info end |