sentry-rails 6.1.2 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd85a162258fc33137da34d2f08bf5ce0feb0286213a0da47aa697f82e44396c
4
- data.tar.gz: a5a14058e287ea961a28d1ca19d96fa954460148fe7366f323ba00663e5b2144
3
+ metadata.gz: b63ec61238dbea2a3fee7cebbdcf72d1810dc50fe4863502ecdbc66b8da7b31e
4
+ data.tar.gz: 165e2974b74f63c062db1587c1852c151a5b350a15df13c408cea97476d6c10f
5
5
  SHA512:
6
- metadata.gz: 6caef5a92e27daf55c92d2dc1b3e713b40be00645a3fdecd07b731acda5f7824266b766bb8614d90f1995a3a642c28f6f449487def3e72cf25bf2e33937aaab3
7
- data.tar.gz: 3894faa286057a1cb21f6eec1affa796e6e22cea3f1e1ff2ecfc04b306873067a61c5d87fd9beab69cf21045a7b3c60f5e30319c95fd1db1e3adc6f323fec33b
6
+ metadata.gz: ec0d90eb1b44f1dfb45bb369586cb8ee22da1a79604679ec12f475e1916eefe646a34c1ab97de386a43e7a27c3e3999c684d61038571ad88c6e0dca667f23f45
7
+ data.tar.gz: fa67c7c00d3d9f71efd13fecb195ea945538f6535464e704115d5e1a8bf7f6c3cf65c3423369270809a6d49cb99ce4b7ab700cca0885756da673f39f99fac166
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/log_subscriber"
4
+ require "sentry/utils/logging_helper"
4
5
 
5
6
  module Sentry
6
7
  module Rails
@@ -27,6 +28,8 @@ module Sentry
27
28
  # end
28
29
  # end
29
30
  class LogSubscriber < ActiveSupport::LogSubscriber
31
+ include Sentry::LoggingHelper
32
+
30
33
  ORIGIN = "auto.log.rails.log_subscriber"
31
34
 
32
35
  class << self
@@ -24,6 +24,7 @@ module Sentry
24
24
  include ParameterFilter
25
25
 
26
26
  EXCLUDED_NAMES = ["SCHEMA", "TRANSACTION"].freeze
27
+ EMPTY_ARRAY = [].freeze
27
28
 
28
29
  # Handle sql.active_record events
29
30
  #
@@ -40,8 +41,6 @@ module Sentry
40
41
  cached = event.payload.fetch(:cached, false)
41
42
  connection_id = event.payload[:connection_id]
42
43
 
43
- db_config = extract_db_config(event.payload)
44
-
45
44
  attributes = {
46
45
  sql: sql,
47
46
  duration_ms: duration_ms(event),
@@ -53,18 +52,18 @@ module Sentry
53
52
  if Sentry.configuration.send_default_pii && (binds && !binds.empty?)
54
53
  type_casted_binds = type_casted_binds(event)
55
54
 
56
- binds.each_with_index do |bind, index|
57
- key = bind.respond_to?(:name) ? bind.name : index.to_s
58
- value = type_casted_binds[index].to_s
55
+ type_casted_binds.each_with_index do |value, index|
56
+ bind = binds[index]
57
+ name = bind.respond_to?(:name) ? bind.name : index.to_s
59
58
 
60
- attributes["db.query.parameter.#{key}"] = value
59
+ attributes["db.query.parameter.#{name}"] = value.to_s
61
60
  end
62
61
  end
63
62
 
64
63
  attributes[:statement_name] = statement_name if statement_name && statement_name != "SQL"
65
64
  attributes[:connection_id] = connection_id if connection_id
66
65
 
67
- add_db_config_attributes(attributes, db_config)
66
+ maybe_add_db_config_attributes(attributes, event.payload)
68
67
 
69
68
  message = build_log_message(statement_name)
70
69
 
@@ -73,6 +72,8 @@ module Sentry
73
72
  level: :info,
74
73
  attributes: attributes
75
74
  )
75
+ rescue => e
76
+ log_debug("[#{self.class}] failed to log sql event: #{e.message}")
76
77
  end
77
78
 
78
79
  def type_casted_binds(event)
@@ -97,15 +98,9 @@ module Sentry
97
98
  end
98
99
  end
99
100
 
100
- def extract_db_config(payload)
101
- connection = payload[:connection]
102
-
103
- return unless connection
104
-
105
- extract_db_config_from_connection(connection)
106
- end
101
+ def maybe_add_db_config_attributes(attributes, payload)
102
+ db_config = extract_db_config(payload)
107
103
 
108
- def add_db_config_attributes(attributes, db_config)
109
104
  return unless db_config
110
105
 
111
106
  attributes[:db_system] = db_config[:adapter] if db_config[:adapter]
@@ -125,6 +120,14 @@ module Sentry
125
120
  attributes[:server_socket_address] = db_config[:socket] if db_config[:socket]
126
121
  end
127
122
 
123
+ def extract_db_config(payload)
124
+ connection = payload[:connection]
125
+
126
+ return unless connection
127
+
128
+ extract_db_config_from_connection(connection)
129
+ end
130
+
128
131
  if ::Rails.version.to_f >= 6.1
129
132
  def extract_db_config_from_connection(connection)
130
133
  if connection.pool.respond_to?(:db_config)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sentry
4
4
  module Rails
5
- VERSION = "6.1.2"
5
+ VERSION = "6.2.0"
6
6
  end
7
7
  end
data/sentry-rails.gemspec CHANGED
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  spec.add_dependency "railties", ">= 5.2.0"
34
- spec.add_dependency "sentry-ruby", "~> 6.1.2"
34
+ spec.add_dependency "sentry-ruby", "~> 6.2.0"
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.1.2
4
+ version: 6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 6.1.2
32
+ version: 6.2.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 6.1.2
39
+ version: 6.2.0
40
40
  description: A gem that provides Rails integration for the Sentry error logger
41
41
  email: accounts@sentry.io
42
42
  executables: []
@@ -89,15 +89,15 @@ files:
89
89
  - lib/sentry/rails/tracing/active_support_subscriber.rb
90
90
  - lib/sentry/rails/version.rb
91
91
  - sentry-rails.gemspec
92
- homepage: https://github.com/getsentry/sentry-ruby/tree/6.1.2/sentry-rails
92
+ homepage: https://github.com/getsentry/sentry-ruby/tree/6.2.0/sentry-rails
93
93
  licenses:
94
94
  - MIT
95
95
  metadata:
96
- homepage_uri: https://github.com/getsentry/sentry-ruby/tree/6.1.2/sentry-rails
97
- source_code_uri: https://github.com/getsentry/sentry-ruby/tree/6.1.2/sentry-rails
98
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/6.1.2/CHANGELOG.md
96
+ homepage_uri: https://github.com/getsentry/sentry-ruby/tree/6.2.0/sentry-rails
97
+ source_code_uri: https://github.com/getsentry/sentry-ruby/tree/6.2.0/sentry-rails
98
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/6.2.0/CHANGELOG.md
99
99
  bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
100
- documentation_uri: http://www.rubydoc.info/gems/sentry-rails/6.1.2
100
+ documentation_uri: http://www.rubydoc.info/gems/sentry-rails/6.2.0
101
101
  rdoc_options: []
102
102
  require_paths:
103
103
  - lib