brainzlab 0.1.2 → 0.1.3

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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +6 -21
  3. data/README.md +16 -2
  4. data/lib/brainzlab/beacon/client.rb +38 -40
  5. data/lib/brainzlab/beacon/provisioner.rb +1 -1
  6. data/lib/brainzlab/beacon.rb +15 -15
  7. data/lib/brainzlab/configuration.rb +92 -90
  8. data/lib/brainzlab/context.rb +2 -3
  9. data/lib/brainzlab/cortex/client.rb +29 -31
  10. data/lib/brainzlab/cortex/provisioner.rb +1 -1
  11. data/lib/brainzlab/cortex.rb +7 -11
  12. data/lib/brainzlab/dendrite/client.rb +42 -44
  13. data/lib/brainzlab/dendrite/provisioner.rb +1 -1
  14. data/lib/brainzlab/dendrite.rb +4 -4
  15. data/lib/brainzlab/devtools/data/collector.rb +22 -22
  16. data/lib/brainzlab/devtools/middleware/asset_server.rb +14 -14
  17. data/lib/brainzlab/devtools/middleware/database_handler.rb +52 -55
  18. data/lib/brainzlab/devtools/middleware/debug_panel.rb +19 -19
  19. data/lib/brainzlab/devtools/middleware/error_page.rb +45 -44
  20. data/lib/brainzlab/devtools/renderers/debug_panel_renderer.rb +39 -35
  21. data/lib/brainzlab/devtools/renderers/error_page_renderer.rb +13 -9
  22. data/lib/brainzlab/devtools.rb +11 -11
  23. data/lib/brainzlab/flux/buffer.rb +3 -3
  24. data/lib/brainzlab/flux/client.rb +14 -16
  25. data/lib/brainzlab/flux/provisioner.rb +13 -13
  26. data/lib/brainzlab/flux.rb +8 -8
  27. data/lib/brainzlab/instrumentation/action_mailer.rb +14 -13
  28. data/lib/brainzlab/instrumentation/active_record.rb +13 -15
  29. data/lib/brainzlab/instrumentation/aws.rb +43 -39
  30. data/lib/brainzlab/instrumentation/dalli.rb +20 -20
  31. data/lib/brainzlab/instrumentation/delayed_job.rb +27 -29
  32. data/lib/brainzlab/instrumentation/elasticsearch.rb +23 -24
  33. data/lib/brainzlab/instrumentation/excon.rb +27 -27
  34. data/lib/brainzlab/instrumentation/faraday.rb +3 -4
  35. data/lib/brainzlab/instrumentation/good_job.rb +28 -28
  36. data/lib/brainzlab/instrumentation/grape.rb +24 -24
  37. data/lib/brainzlab/instrumentation/graphql.rb +24 -23
  38. data/lib/brainzlab/instrumentation/httparty.rb +13 -14
  39. data/lib/brainzlab/instrumentation/mongodb.rb +7 -7
  40. data/lib/brainzlab/instrumentation/net_http.rb +6 -6
  41. data/lib/brainzlab/instrumentation/redis.rb +14 -21
  42. data/lib/brainzlab/instrumentation/resque.rb +23 -24
  43. data/lib/brainzlab/instrumentation/sidekiq.rb +29 -28
  44. data/lib/brainzlab/instrumentation/solid_queue.rb +37 -41
  45. data/lib/brainzlab/instrumentation/stripe.rb +36 -37
  46. data/lib/brainzlab/instrumentation/typhoeus.rb +19 -17
  47. data/lib/brainzlab/instrumentation.rb +20 -20
  48. data/lib/brainzlab/nerve/client.rb +38 -40
  49. data/lib/brainzlab/nerve/provisioner.rb +1 -1
  50. data/lib/brainzlab/nerve.rb +6 -6
  51. data/lib/brainzlab/pulse/client.rb +15 -11
  52. data/lib/brainzlab/pulse/instrumentation.rb +61 -57
  53. data/lib/brainzlab/pulse/propagation.rb +28 -28
  54. data/lib/brainzlab/pulse/provisioner.rb +12 -12
  55. data/lib/brainzlab/pulse/tracer.rb +3 -3
  56. data/lib/brainzlab/pulse.rb +13 -13
  57. data/lib/brainzlab/rails/log_formatter.rb +127 -121
  58. data/lib/brainzlab/rails/log_subscriber.rb +70 -76
  59. data/lib/brainzlab/rails/railtie.rb +66 -89
  60. data/lib/brainzlab/recall/buffer.rb +1 -1
  61. data/lib/brainzlab/recall/client.rb +14 -10
  62. data/lib/brainzlab/recall/logger.rb +16 -18
  63. data/lib/brainzlab/recall/provisioner.rb +16 -16
  64. data/lib/brainzlab/recall.rb +11 -13
  65. data/lib/brainzlab/reflex/breadcrumbs.rb +2 -2
  66. data/lib/brainzlab/reflex/client.rb +14 -10
  67. data/lib/brainzlab/reflex/provisioner.rb +12 -12
  68. data/lib/brainzlab/reflex.rb +29 -29
  69. data/lib/brainzlab/sentinel/client.rb +40 -42
  70. data/lib/brainzlab/sentinel/provisioner.rb +1 -1
  71. data/lib/brainzlab/sentinel.rb +5 -5
  72. data/lib/brainzlab/signal/client.rb +12 -14
  73. data/lib/brainzlab/signal/provisioner.rb +12 -12
  74. data/lib/brainzlab/signal.rb +7 -7
  75. data/lib/brainzlab/synapse/client.rb +42 -44
  76. data/lib/brainzlab/synapse/provisioner.rb +1 -1
  77. data/lib/brainzlab/synapse.rb +6 -6
  78. data/lib/brainzlab/utilities/circuit_breaker.rb +37 -41
  79. data/lib/brainzlab/utilities/health_check.rb +53 -55
  80. data/lib/brainzlab/utilities/log_formatter.rb +38 -40
  81. data/lib/brainzlab/utilities/rate_limiter.rb +5 -5
  82. data/lib/brainzlab/utilities.rb +4 -4
  83. data/lib/brainzlab/vault/cache.rb +1 -1
  84. data/lib/brainzlab/vault/client.rb +39 -41
  85. data/lib/brainzlab/vault/provisioner.rb +1 -1
  86. data/lib/brainzlab/vault.rb +19 -25
  87. data/lib/brainzlab/version.rb +1 -1
  88. data/lib/brainzlab/vision/client.rb +20 -20
  89. data/lib/brainzlab/vision/provisioner.rb +21 -21
  90. data/lib/brainzlab/vision.rb +17 -19
  91. data/lib/brainzlab-sdk.rb +1 -1
  92. data/lib/brainzlab.rb +22 -24
  93. data/lib/generators/brainzlab/install/install_generator.rb +29 -27
  94. metadata +1 -1
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "net/http"
4
- require "uri"
5
- require "json"
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
6
 
7
7
  module BrainzLab
8
8
  module Recall
@@ -18,14 +18,14 @@ module BrainzLab
18
18
  def send_log(log_entry)
19
19
  return unless @config.recall_enabled && @config.valid?
20
20
 
21
- post("/api/v1/log", log_entry)
21
+ post('/api/v1/log', log_entry)
22
22
  end
23
23
 
24
24
  def send_batch(log_entries)
25
25
  return unless @config.recall_enabled && @config.valid?
26
26
  return if log_entries.empty?
27
27
 
28
- post("/api/v1/logs", { logs: log_entries })
28
+ post('/api/v1/logs', { logs: log_entries })
29
29
  end
30
30
 
31
31
  private
@@ -33,9 +33,9 @@ module BrainzLab
33
33
  def post(path, body)
34
34
  uri = URI.join(@config.recall_url, path)
35
35
  request = Net::HTTP::Post.new(uri)
36
- request["Content-Type"] = "application/json"
37
- request["Authorization"] = "Bearer #{@config.secret_key}"
38
- request["User-Agent"] = "brainzlab-sdk-ruby/#{BrainzLab::VERSION}"
36
+ request['Content-Type'] = 'application/json'
37
+ request['Authorization'] = "Bearer #{@config.secret_key}"
38
+ request['User-Agent'] = "brainzlab-sdk-ruby/#{BrainzLab::VERSION}"
39
39
  request.body = JSON.generate(body)
40
40
 
41
41
  execute_with_retry(uri, request)
@@ -48,7 +48,7 @@ module BrainzLab
48
48
  retries = 0
49
49
  begin
50
50
  http = Net::HTTP.new(uri.host, uri.port)
51
- http.use_ssl = uri.scheme == "https"
51
+ http.use_ssl = uri.scheme == 'https'
52
52
  http.open_timeout = 5
53
53
  http.read_timeout = 10
54
54
 
@@ -56,7 +56,11 @@ module BrainzLab
56
56
 
57
57
  case response.code.to_i
58
58
  when 200..299
59
- JSON.parse(response.body) rescue {}
59
+ begin
60
+ JSON.parse(response.body)
61
+ rescue StandardError
62
+ {}
63
+ end
60
64
  when 429, 500..599
61
65
  raise RetryableError, "Server error: #{response.code}"
62
66
  else
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "logger"
3
+ require 'logger'
4
4
 
5
5
  module BrainzLab
6
6
  module Recall
@@ -12,16 +12,14 @@ module BrainzLab
12
12
  @service_name = service_name
13
13
  @broadcast_to = broadcast_to
14
14
  @level = ::Logger::DEBUG
15
- @formatter = proc { |severity, _time, _progname, msg| msg }
15
+ @formatter = proc { |_severity, _time, _progname, msg| msg }
16
16
  end
17
17
 
18
- def add(severity, message = nil, progname = nil, &block)
18
+ def add(severity, message = nil, progname = nil)
19
19
  severity ||= ::Logger::UNKNOWN
20
20
 
21
21
  # Handle block-based messages
22
- if message.nil? && block_given?
23
- message = yield
24
- end
22
+ message = yield if message.nil? && block_given?
25
23
 
26
24
  # Handle progname as message (standard Logger behavior)
27
25
  if message.nil?
@@ -52,28 +50,28 @@ module BrainzLab
52
50
  true
53
51
  end
54
52
 
55
- def debug(message = nil, &block)
56
- add(::Logger::DEBUG, message, &block)
53
+ def debug(message = nil, &)
54
+ add(::Logger::DEBUG, message, &)
57
55
  end
58
56
 
59
- def info(message = nil, &block)
60
- add(::Logger::INFO, message, &block)
57
+ def info(message = nil, &)
58
+ add(::Logger::INFO, message, &)
61
59
  end
62
60
 
63
- def warn(message = nil, &block)
64
- add(::Logger::WARN, message, &block)
61
+ def warn(message = nil, &)
62
+ add(::Logger::WARN, message, &)
65
63
  end
66
64
 
67
- def error(message = nil, &block)
68
- add(::Logger::ERROR, message, &block)
65
+ def error(message = nil, &)
66
+ add(::Logger::ERROR, message, &)
69
67
  end
70
68
 
71
- def fatal(message = nil, &block)
72
- add(::Logger::FATAL, message, &block)
69
+ def fatal(message = nil, &)
70
+ add(::Logger::FATAL, message, &)
73
71
  end
74
72
 
75
- def unknown(message = nil, &block)
76
- add(::Logger::UNKNOWN, message, &block)
73
+ def unknown(message = nil, &)
74
+ add(::Logger::UNKNOWN, message, &)
77
75
  end
78
76
 
79
77
  # Rails compatibility methods
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "net/http"
4
- require "uri"
5
- require "json"
6
- require "fileutils"
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
+ require 'fileutils'
7
7
 
8
8
  module BrainzLab
9
9
  module Recall
10
10
  class Provisioner
11
- CACHE_DIR = ENV.fetch("BRAINZLAB_CACHE_DIR") { File.join(Dir.home, ".brainzlab") }
11
+ CACHE_DIR = ENV.fetch('BRAINZLAB_CACHE_DIR') { File.join(Dir.home, '.brainzlab') }
12
12
 
13
13
  def initialize(config)
14
14
  @config = config
@@ -38,19 +38,19 @@ module BrainzLab
38
38
 
39
39
  def should_provision?
40
40
  if @config.debug
41
- log_debug("Checking provision conditions:")
41
+ log_debug('Checking provision conditions:')
42
42
  log_debug(" recall_auto_provision: #{@config.recall_auto_provision}")
43
43
  log_debug(" app_name: '#{@config.app_name}'")
44
- log_debug(" secret_key set: #{@config.secret_key.to_s.strip.length > 0}")
45
- log_debug(" recall_master_key set: #{@config.recall_master_key.to_s.strip.length > 0}")
44
+ log_debug(" secret_key set: #{@config.secret_key.to_s.strip.length.positive?}")
45
+ log_debug(" recall_master_key set: #{@config.recall_master_key.to_s.strip.length.positive?}")
46
46
  end
47
47
 
48
48
  return false unless @config.recall_auto_provision
49
- return false unless @config.app_name.to_s.strip.length > 0
50
- return false if @config.secret_key.to_s.strip.length > 0
51
- return false unless @config.recall_master_key.to_s.strip.length > 0
49
+ return false unless @config.app_name.to_s.strip.length.positive?
50
+ return false if @config.secret_key.to_s.strip.length.positive?
51
+ return false unless @config.recall_master_key.to_s.strip.length.positive?
52
52
 
53
- log_debug("Will provision Recall project") if @config.debug
53
+ log_debug('Will provision Recall project') if @config.debug
54
54
  true
55
55
  end
56
56
 
@@ -65,9 +65,9 @@ module BrainzLab
65
65
  def provision_project
66
66
  uri = URI.parse("#{@config.recall_url}/api/v1/projects/provision")
67
67
  request = Net::HTTP::Post.new(uri)
68
- request["Content-Type"] = "application/json"
69
- request["X-Master-Key"] = @config.recall_master_key
70
- request["User-Agent"] = "brainzlab-sdk-ruby/#{BrainzLab::VERSION}"
68
+ request['Content-Type'] = 'application/json'
69
+ request['X-Master-Key'] = @config.recall_master_key
70
+ request['User-Agent'] = "brainzlab-sdk-ruby/#{BrainzLab::VERSION}"
71
71
  request.body = JSON.generate({ name: @config.app_name })
72
72
 
73
73
  response = execute(uri, request)
@@ -114,7 +114,7 @@ module BrainzLab
114
114
 
115
115
  def execute(uri, request)
116
116
  http = Net::HTTP.new(uri.host, uri.port)
117
- http.use_ssl = uri.scheme == "https"
117
+ http.use_ssl = uri.scheme == 'https'
118
118
  http.open_timeout = 5
119
119
  http.read_timeout = 10
120
120
  http.request(request)
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "recall/client"
4
- require_relative "recall/buffer"
5
- require_relative "recall/logger"
6
- require_relative "recall/provisioner"
3
+ require_relative 'recall/client'
4
+ require_relative 'recall/buffer'
5
+ require_relative 'recall/logger'
6
+ require_relative 'recall/provisioner'
7
7
 
8
8
  module BrainzLab
9
9
  module Recall
@@ -44,9 +44,7 @@ module BrainzLab
44
44
 
45
45
  def ensure_provisioned!
46
46
  config = BrainzLab.configuration
47
- if config.debug
48
- puts "[BrainzLab::Debug] Recall.ensure_provisioned! called, @provisioned=#{@provisioned}"
49
- end
47
+ puts "[BrainzLab::Debug] Recall.ensure_provisioned! called, @provisioned=#{@provisioned}" if config.debug
50
48
 
51
49
  return if @provisioned
52
50
 
@@ -63,7 +61,7 @@ module BrainzLab
63
61
  result = yield
64
62
  duration_ms = ((Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000).round(1)
65
63
 
66
- info("#{label} (#{duration_ms}ms)", **data.merge(duration_ms: duration_ms))
64
+ info("#{label} (#{duration_ms}ms)", **data, duration_ms: duration_ms)
67
65
  result
68
66
  end
69
67
 
@@ -131,11 +129,11 @@ module BrainzLab
131
129
  case obj
132
130
  when Hash
133
131
  obj.each_with_object({}) do |(key, value), result|
134
- if should_scrub?(key, fields)
135
- result[key] = "[FILTERED]"
136
- else
137
- result[key] = deep_scrub(value, fields)
138
- end
132
+ result[key] = if should_scrub?(key, fields)
133
+ '[FILTERED]'
134
+ else
135
+ deep_scrub(value, fields)
136
+ end
139
137
  end
140
138
  when Array
141
139
  obj.map { |item| deep_scrub(item, fields) }
@@ -10,7 +10,7 @@ module BrainzLab
10
10
  @mutex = Mutex.new
11
11
  end
12
12
 
13
- def add(message:, category: "default", level: :info, data: nil)
13
+ def add(message:, category: 'default', level: :info, data: nil)
14
14
  crumb = {
15
15
  timestamp: Time.now.utc.iso8601(3),
16
16
  message: message.to_s,
@@ -43,7 +43,7 @@ module BrainzLab
43
43
  Context.current.breadcrumbs
44
44
  end
45
45
 
46
- def add_breadcrumb(message, category: "default", level: :info, data: nil)
46
+ def add_breadcrumb(message, category: 'default', level: :info, data: nil)
47
47
  breadcrumbs.add(message: message, category: category, level: level, data: data)
48
48
  end
49
49
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "net/http"
4
- require "uri"
5
- require "json"
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
6
 
7
7
  module BrainzLab
8
8
  module Reflex
@@ -17,14 +17,14 @@ module BrainzLab
17
17
  def send_error(payload)
18
18
  return unless @config.reflex_enabled && @config.reflex_valid?
19
19
 
20
- post("/api/v1/errors", payload)
20
+ post('/api/v1/errors', payload)
21
21
  end
22
22
 
23
23
  def send_batch(payloads)
24
24
  return unless @config.reflex_enabled && @config.reflex_valid?
25
25
  return if payloads.empty?
26
26
 
27
- post("/api/v1/errors/batch", { errors: payloads })
27
+ post('/api/v1/errors/batch', { errors: payloads })
28
28
  end
29
29
 
30
30
  private
@@ -32,9 +32,9 @@ module BrainzLab
32
32
  def post(path, body)
33
33
  uri = URI.join(@config.reflex_url, path)
34
34
  request = Net::HTTP::Post.new(uri)
35
- request["Content-Type"] = "application/json"
36
- request["Authorization"] = "Bearer #{@config.reflex_auth_key}"
37
- request["User-Agent"] = "brainzlab-sdk-ruby/#{BrainzLab::VERSION}"
35
+ request['Content-Type'] = 'application/json'
36
+ request['Authorization'] = "Bearer #{@config.reflex_auth_key}"
37
+ request['User-Agent'] = "brainzlab-sdk-ruby/#{BrainzLab::VERSION}"
38
38
  request.body = JSON.generate(body)
39
39
 
40
40
  execute_with_retry(uri, request)
@@ -47,7 +47,7 @@ module BrainzLab
47
47
  retries = 0
48
48
  begin
49
49
  http = Net::HTTP.new(uri.host, uri.port)
50
- http.use_ssl = uri.scheme == "https"
50
+ http.use_ssl = uri.scheme == 'https'
51
51
  http.open_timeout = 5
52
52
  http.read_timeout = 10
53
53
 
@@ -55,7 +55,11 @@ module BrainzLab
55
55
 
56
56
  case response.code.to_i
57
57
  when 200..299
58
- JSON.parse(response.body) rescue {}
58
+ begin
59
+ JSON.parse(response.body)
60
+ rescue StandardError
61
+ {}
62
+ end
59
63
  when 429, 500..599
60
64
  raise RetryableError, "Server error: #{response.code}"
61
65
  else
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "net/http"
4
- require "uri"
5
- require "json"
6
- require "fileutils"
3
+ require 'net/http'
4
+ require 'uri'
5
+ require 'json'
6
+ require 'fileutils'
7
7
 
8
8
  module BrainzLab
9
9
  module Reflex
10
10
  class Provisioner
11
- CACHE_DIR = ENV.fetch("BRAINZLAB_CACHE_DIR") { File.join(Dir.home, ".brainzlab") }
11
+ CACHE_DIR = ENV.fetch('BRAINZLAB_CACHE_DIR') { File.join(Dir.home, '.brainzlab') }
12
12
 
13
13
  def initialize(config)
14
14
  @config = config
@@ -38,10 +38,10 @@ module BrainzLab
38
38
 
39
39
  def should_provision?
40
40
  return false unless @config.reflex_auto_provision
41
- return false unless @config.app_name.to_s.strip.length > 0
41
+ return false unless @config.app_name.to_s.strip.length.positive?
42
42
  # Only skip if reflex_api_key is already set (not secret_key, which may be for Recall)
43
- return false if @config.reflex_api_key.to_s.strip.length > 0
44
- return false unless @config.reflex_master_key.to_s.strip.length > 0
43
+ return false if @config.reflex_api_key.to_s.strip.length.positive?
44
+ return false unless @config.reflex_master_key.to_s.strip.length.positive?
45
45
 
46
46
  true
47
47
  end
@@ -49,9 +49,9 @@ module BrainzLab
49
49
  def provision_project
50
50
  uri = URI.parse("#{@config.reflex_url}/api/v1/projects/provision")
51
51
  request = Net::HTTP::Post.new(uri)
52
- request["Content-Type"] = "application/json"
53
- request["X-Master-Key"] = @config.reflex_master_key
54
- request["User-Agent"] = "brainzlab-sdk-ruby/#{BrainzLab::VERSION}"
52
+ request['Content-Type'] = 'application/json'
53
+ request['X-Master-Key'] = @config.reflex_master_key
54
+ request['User-Agent'] = "brainzlab-sdk-ruby/#{BrainzLab::VERSION}"
55
55
  request.body = JSON.generate({ name: @config.app_name })
56
56
 
57
57
  response = execute(uri, request)
@@ -100,7 +100,7 @@ module BrainzLab
100
100
 
101
101
  def execute(uri, request)
102
102
  http = Net::HTTP.new(uri.host, uri.port)
103
- http.use_ssl = uri.scheme == "https"
103
+ http.use_ssl = uri.scheme == 'https'
104
104
  http.open_timeout = 5
105
105
  http.read_timeout = 10
106
106
  http.request(request)
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "reflex/client"
4
- require_relative "reflex/breadcrumbs"
5
- require_relative "reflex/provisioner"
3
+ require_relative 'reflex/client'
4
+ require_relative 'reflex/breadcrumbs'
5
+ require_relative 'reflex/provisioner'
6
6
 
7
7
  module BrainzLab
8
8
  module Reflex
@@ -158,7 +158,7 @@ module BrainzLab
158
158
 
159
159
  payload = {
160
160
  timestamp: Time.now.utc.iso8601(3),
161
- error_class: "Message",
161
+ error_class: 'Message',
162
162
  message: message.to_s,
163
163
  level: level.to_s,
164
164
 
@@ -247,17 +247,17 @@ module BrainzLab
247
247
  # - "path/to/file.rb:42" (no method)
248
248
  if line =~ /\A(.+):(\d+):in [`']([^']+)'?\z/
249
249
  {
250
- file: $1,
251
- line: $2.to_i,
252
- function: $3,
253
- in_app: in_app_frame?($1)
250
+ file: ::Regexp.last_match(1),
251
+ line: ::Regexp.last_match(2).to_i,
252
+ function: ::Regexp.last_match(3),
253
+ in_app: in_app_frame?(::Regexp.last_match(1))
254
254
  }
255
255
  elsif line =~ /\A(.+):(\d+)\z/
256
256
  {
257
- file: $1,
258
- line: $2.to_i,
257
+ file: ::Regexp.last_match(1),
258
+ line: ::Regexp.last_match(2).to_i,
259
259
  function: nil,
260
- in_app: in_app_frame?($1)
260
+ in_app: in_app_frame?(::Regexp.last_match(1))
261
261
  }
262
262
  else
263
263
  # Still store file for display even if format is unexpected
@@ -267,14 +267,14 @@ module BrainzLab
267
267
 
268
268
  def in_app_frame?(path)
269
269
  return false if path.nil?
270
- return false if path.include?("vendor/")
271
- return false if path.include?("/gems/")
272
- return false if path.include?("/ruby/")
270
+ return false if path.include?('vendor/')
271
+ return false if path.include?('/gems/')
272
+ return false if path.include?('/ruby/')
273
273
 
274
274
  # Match both relative and absolute paths containing app/ or lib/
275
- path.start_with?("app/", "lib/", "./app/", "./lib/") ||
276
- path.include?("/app/") ||
277
- path.include?("/lib/")
275
+ path.start_with?('app/', 'lib/', './app/', './lib/') ||
276
+ path.include?('/app/') ||
277
+ path.include?('/lib/')
278
278
  end
279
279
 
280
280
  def filter_params(params)
@@ -288,11 +288,11 @@ module BrainzLab
288
288
  case obj
289
289
  when Hash
290
290
  obj.each_with_object({}) do |(key, value), result|
291
- if should_filter?(key, fields)
292
- result[key] = "[FILTERED]"
293
- else
294
- result[key] = deep_filter(value, fields)
295
- end
291
+ result[key] = if should_filter?(key, fields)
292
+ '[FILTERED]'
293
+ else
294
+ deep_filter(value, fields)
295
+ end
296
296
  end
297
297
  when Array
298
298
  obj.map { |item| deep_filter(item, fields) }
@@ -363,12 +363,12 @@ module BrainzLab
363
363
 
364
364
  def in_app_line?(line)
365
365
  return false if line.nil?
366
- return false if line.include?("vendor/")
367
- return false if line.include?("/gems/")
366
+ return false if line.include?('vendor/')
367
+ return false if line.include?('/gems/')
368
368
 
369
- line.start_with?("app/", "lib/", "./app/", "./lib/") ||
370
- line.include?("/app/") ||
371
- line.include?("/lib/")
369
+ line.start_with?('app/', 'lib/', './app/', './lib/') ||
370
+ line.include?('/app/') ||
371
+ line.include?('/lib/')
372
372
  end
373
373
 
374
374
  def normalize_frame_for_fingerprint(frame)
@@ -377,9 +377,9 @@ module BrainzLab
377
377
  # Extract file and method, normalize out line numbers
378
378
  # "app/models/user.rb:42:in `save'" -> "app/models/user.rb:in `save'"
379
379
  if frame =~ /\A(.+):\d+:in `(.+)'\z/
380
- "#{$1}:in `#{$2}'"
380
+ "#{::Regexp.last_match(1)}:in `#{::Regexp.last_match(2)}'"
381
381
  elsif frame =~ /\A(.+):\d+\z/
382
- $1
382
+ ::Regexp.last_match(1)
383
383
  else
384
384
  frame
385
385
  end