lhs 19.9.0 → 19.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ae06289222aa01014699262ca1538093d7388f5e6a4fa689c3351d2fd6cf1d7
4
- data.tar.gz: f0308f117f2f2dc44d0e0ada944c74ed0819b91198756fcedfeecebf472b0da9
3
+ metadata.gz: 57094afc8763a8fe1aab390ad385ac4ddee8c2abd59dd8b8651cd83c07826fef
4
+ data.tar.gz: 2b06402e0aceb84e5d21aefeb15321610a6b13ada2959b6286434d8725578b13
5
5
  SHA512:
6
- metadata.gz: 4778c1456b9f0aea0308f7a505d27641aa6a0bb1dc18170724c80542d182df8f5198f2e1a5de6db749722e22a59d1c1ea701934f8f89f365c05a4cc00af061c3
7
- data.tar.gz: c64c7dece11ba95192669df9ea91d33a40262156eeac930efdfd8e432a4bfc51add6350746c937203309d67012499d15880c5b5b694ac66740556b9798dd8be6
6
+ metadata.gz: ae00456701d8fa85fdf0e3f8d3d14eb58d87f1c87719b5ac2916959ebd449853f7a061a239fda5debc45faa0d34bb265f3cf429b584eba63cf2969a38b3c3ebe
7
+ data.tar.gz: 0b142fc761ccda98c5524bd0810ca0147fd9a5d4ec923b4986cdc3698bce8f1881b240c8c3113d9f09d1c57ca92925848d29690d0da5fde0a099a7757b3e81a0
data/README.md CHANGED
@@ -119,6 +119,7 @@ record.review # "Lunch was great
119
119
  * [Record setters](#record-setters)
120
120
  * [Record getters](#record-getters)
121
121
  * [Include linked resources (hyperlinks and hypermedia)](#include-linked-resources-hyperlinks-and-hypermedia)
122
+ * [Generate links from parameters](#generate-links-from-parameters)
122
123
  * [Ensure the whole linked collection is included: includes_all](#ensure-the-whole-linked-collection-is-included-includes_all)
123
124
  * [Include the first linked page or single item is included: include](#include-the-first-linked-page-or-single-item-is-included-include)
124
125
  * [Include various levels of linked data](#include-various-levels-of-linked-data)
@@ -136,6 +137,7 @@ record.review # "Lunch was great
136
137
  * [Disable request cycle cache](#disable-request-cycle-cache)
137
138
  * [Option Blocks](#option-blocks)
138
139
  * [Request tracing](#request-tracing)
140
+ * [Extended Rollbar Logging](#extended-rollbar-logging)
139
141
  * [Testing with LHS](#testing-with-lhs)
140
142
  * [Test helper for request cycle cache](#test-helper-for-request-cycle-cache)
141
143
  * [Test query chains](#test-query-chains)
@@ -2443,6 +2445,26 @@ code.places
2443
2445
  }
2444
2446
  ```
2445
2447
 
2448
+ ## Extended Rollbar Logging
2449
+
2450
+ In order to log all requests/responses prior to an exception reported by Rollbar in addition to the exception itself, use the `LHS::ExtendedRollbar` interceptor in combination with the rollbar processor/handler:
2451
+
2452
+ ```ruby
2453
+ # config/initializers/lhc.rb
2454
+
2455
+ LHC.configure do |config|
2456
+ config.interceptors = [LHS::ExtendedRollbar]
2457
+ end
2458
+ ```
2459
+
2460
+ ```ruby
2461
+ # config/initializers/rollbar.rb
2462
+
2463
+ Rollbar.configure do |config|
2464
+ config.before_process << LHS::Interceptors::ExtendedRollbar::Handler.init
2465
+ end
2466
+ ```
2467
+
2446
2468
  ## Testing with LHS
2447
2469
 
2448
2470
  **Best practice in regards of testing applications using LHS, is to let LHS fetch your records, actually perform HTTP requests and [WebMock](https://github.com/bblimke/webmock) to stub/mock those http requests/responses.**
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.add_development_dependency 'pry'
32
32
  s.add_development_dependency 'pry-byebug'
33
33
  s.add_development_dependency 'rails', '>= 4.2.11'
34
+ s.add_development_dependency 'rollbar'
34
35
  s.add_development_dependency 'rspec-rails', '>= 3.7.0'
35
36
  s.add_development_dependency 'rubocop', '~> 0.57.1'
36
37
  s.add_development_dependency 'rubocop-rspec', '~> 1.26.0'
data/lib/lhs.rb CHANGED
@@ -15,10 +15,28 @@ module LHS
15
15
  'lhs/config'
16
16
  autoload :Data,
17
17
  'lhs/data'
18
+ autoload :ExtendedRollbar,
19
+ 'lhs/interceptors/extended_rollbar/interceptor'
18
20
  autoload :Endpoint,
19
21
  'lhs/endpoint'
20
22
  autoload :Inspect,
21
23
  'lhs/concerns/inspect'
24
+ module Interceptors
25
+ module RequestCycleCache
26
+ autoload :ThreadRegistry,
27
+ 'lhs/interceptors/request_cycle_cache/thread_registry'
28
+ autoload :Interceptor,
29
+ 'lhs/interceptors/request_cycle_cache/interceptor'
30
+ end
31
+ module ExtendedRollbar
32
+ autoload :ThreadRegistry,
33
+ 'lhs/interceptors/extended_rollbar/thread_registry'
34
+ autoload :Interceptor,
35
+ 'lhs/interceptors/extended_rollbar/interceptor'
36
+ autoload :Handler,
37
+ 'lhs/interceptors/extended_rollbar/handler'
38
+ end
39
+ end
22
40
  autoload :IsHref,
23
41
  'lhs/concerns/is_href'
24
42
  autoload :Item,
@@ -8,7 +8,7 @@ module LHS
8
8
 
9
9
  class CurrentOptionBlock
10
10
  # Using ActiveSupports PerThreadRegistry to be able to support Active Support v4.
11
- # Will switch to thread_mattr_accessor (which comes with Activesupport) when we dropping support for Active Support v5.
11
+ # Will switch to thread_mattr_accessor (which comes with Activesupport) when we dropping support for Active Support v4.
12
12
  extend ActiveSupport::PerThreadRegistry
13
13
  attr_accessor :options
14
14
  end
@@ -509,16 +509,16 @@ class LHS::Record
509
509
  options
510
510
  end
511
511
 
512
- # Injects options into request, that enable the LHS::Record::RequestCycleCache::Interceptor
512
+ # Injects options into request, that enable the request cycle cache interceptor
513
513
  def inject_request_cycle_cache!(options)
514
514
  return unless LHS.config.request_cycle_cache_enabled
515
515
  interceptors = options[:interceptors] || LHC.config.interceptors
516
516
  if interceptors.include?(LHC::Caching)
517
- # Ensure LHS::RequestCycleCache interceptor is prepend
518
- interceptors = interceptors.unshift(LHS::Record::RequestCycleCache::Interceptor)
517
+ # Ensure interceptor is prepend
518
+ interceptors = interceptors.unshift(LHS::Interceptors::RequestCycleCache::Interceptor)
519
519
  options[:interceptors] = interceptors
520
520
  else
521
- warn("[WARNING] Can't enable LHS::RequestCycleCache as LHC::Caching interceptor is not enabled/configured (see https://github.com/local-ch/lhc/blob/master/docs/interceptors/caching.md#caching-interceptor)!")
521
+ warn("[WARNING] Can't enable request cycle cache as LHC::Caching interceptor is not enabled/configured (see https://github.com/local-ch/lhc/blob/master/docs/interceptors/caching.md#caching-interceptor)!")
522
522
  end
523
523
  end
524
524
 
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LHS
4
+ module Interceptors
5
+ module ExtendedRollbar
6
+ class Handler
7
+
8
+ def self.init
9
+ proc do |options|
10
+ # as handlers cant influence what actually is reported to rollbar
11
+ # this just makes sure that Rollbar is already loaded when this class is loaded,
12
+ # so that we can extend rollbar loging
13
+ end
14
+ end
15
+
16
+ module ExtendedLogging
17
+ def log(level, *args)
18
+ args[2] = {} if args[2].nil?
19
+ args[2][:lhs] = LHS::Interceptors::ExtendedRollbar::ThreadRegistry.log.map do |entry|
20
+ {
21
+ request: entry[:request].options,
22
+ response: {
23
+ code: entry[:response].code,
24
+ body: entry[:response].body
25
+ }
26
+ }
27
+ end.to_json
28
+ super
29
+ end
30
+ end
31
+
32
+ module ::Rollbar
33
+ class Notifier
34
+ prepend LHS::Interceptors::ExtendedRollbar::Handler::ExtendedLogging
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+
5
+ module LHS
6
+ module Interceptors
7
+ module ExtendedRollbar
8
+ extend ActiveSupport::Concern
9
+
10
+ class Interceptor < LHC::Interceptor
11
+ def after_response
12
+ return unless LHS::Interceptors::ExtendedRollbar::ThreadRegistry.log
13
+ LHS::Interceptors::ExtendedRollbar::ThreadRegistry.log.push(request: request, response: response)
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ const_set('ExtendedRollbar', LHS::Interceptors::ExtendedRollbar::Interceptor)
20
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+
5
+ module LHS
6
+ module Interceptors
7
+ module ExtendedRollbar
8
+ extend ActiveSupport::Concern
9
+
10
+ class ThreadRegistry
11
+ # Using ActiveSupports PerThreadRegistry to be able to support Active Support v4.
12
+ # Will switch to thread_mattr_accessor (which comes with Activesupport) when we dropping support for Active Support v4.
13
+ extend ActiveSupport::PerThreadRegistry
14
+ attr_accessor :log
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+
5
+ module LHS
6
+ module Interceptors
7
+ module RequestCycleCache
8
+ extend ActiveSupport::Concern
9
+
10
+ class Interceptor < LHC::Interceptor
11
+
12
+ VERSION = 1
13
+ CACHED_METHODS = [:get].freeze
14
+
15
+ def before_request
16
+ request.options = {
17
+ cache: {
18
+ expires_in: 5.minutes,
19
+ race_condition_ttl: 5.seconds,
20
+ key: cache_key_for(request),
21
+ methods: CACHED_METHODS,
22
+ use: LHS.config.request_cycle_cache
23
+ }
24
+ }.merge(request.options)
25
+ end
26
+
27
+ private
28
+
29
+ def cache_key_for(request)
30
+ [
31
+ "LHS_REQUEST_CYCLE_CACHE(v#{VERSION})",
32
+ request.method.upcase,
33
+ [request.url, request.params.presence].compact.join('?'),
34
+ "REQUEST=#{LHS::Interceptors::RequestCycleCache::ThreadRegistry.request_id}",
35
+ "HEADERS=#{request.headers.hash}"
36
+ ].join(' ')
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support'
4
+
5
+ module LHS
6
+ module Interceptors
7
+ module RequestCycleCache
8
+ extend ActiveSupport::Concern
9
+ class ThreadRegistry
10
+ # Using ActiveSupports PerThreadRegistry to be able to support Active Support v4.
11
+ # Will switch to thread_mattr_accessor (which comes with Activesupport) when we dropping support for Active Support v4.
12
+ extend ActiveSupport::PerThreadRegistry
13
+ attr_accessor :request_id
14
+ end
15
+ end
16
+ end
17
+ end
@@ -8,6 +8,7 @@ module LHS
8
8
  def initialize
9
9
  prepare_lhs_request_cycle_cache
10
10
  reset_option_blocks
11
+ reset_extended_rollbar_request_logs
11
12
  super
12
13
  end
13
14
 
@@ -15,12 +16,18 @@ module LHS
15
16
 
16
17
  def prepare_lhs_request_cycle_cache
17
18
  return unless LHS.config.request_cycle_cache_enabled
18
- LHS::Record::RequestCycleCache::RequestCycleThreadRegistry.request_id = [Time.now.to_f, request.object_id].join('#')
19
+ LHS::Interceptors::RequestCycleCache::ThreadRegistry.request_id = [Time.now.to_f, request.object_id].join('#')
19
20
  end
20
21
 
21
22
  def reset_option_blocks
22
23
  LHS::OptionBlocks::CurrentOptionBlock.options = nil
23
24
  end
25
+
26
+ def reset_extended_rollbar_request_logs
27
+ return unless defined?(::Rollbar)
28
+ return unless LHC.config.interceptors.include?(LHS::Interceptors::ExtendedRollbar::Interceptor)
29
+ LHS::Interceptors::ExtendedRollbar::ThreadRegistry.log = []
30
+ end
24
31
  end
25
32
  end
26
33
  end
@@ -48,13 +48,6 @@ class LHS::Record
48
48
  autoload :AttributeAssignment,
49
49
  'lhs/concerns/record/attribute_assignment'
50
50
 
51
- module RequestCycleCache
52
- autoload :RequestCycleThreadRegistry,
53
- 'lhs/concerns/record/request_cycle_cache/request_cycle_thread_registry'
54
- autoload :Interceptor,
55
- 'lhs/concerns/record/request_cycle_cache/interceptor'
56
- end
57
-
58
51
  include Batch
59
52
  include Chainable
60
53
  include Configuration
@@ -77,7 +70,6 @@ class LHS::Record
77
70
  include Provider
78
71
  include Request
79
72
  include Relations
80
- include RequestCycleCache
81
73
  include Scope
82
74
  include Tracing
83
75
  include AttributeAssignment
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHS
4
- VERSION = '19.9.0'
4
+ VERSION = '19.10.0'
5
5
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ExtendedRollbarController < ApplicationController
4
+
5
+ def extended_rollbar
6
+ Record.where(color: 'blue').fetch
7
+ Record.where(color: 'red').fetch
8
+ raise "Let's see if rollbar logs information about what kind of requests where made around here!"
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ if defined?(Rollbar)
4
+ Rollbar.configure do |config|
5
+ config.access_token = '12345'
6
+ config.enabled = true
7
+ config.before_process << LHS::Interceptors::ExtendedRollbar::Handler.init
8
+ end
9
+ end
@@ -16,4 +16,7 @@ Rails.application.routes.draw do
16
16
  # Option Blocks
17
17
  get 'option_blocks/first' => 'option_blocks#first'
18
18
  get 'option_blocks/second' => 'option_blocks#second'
19
+
20
+ # Extended Rollbar
21
+ get 'extended_rollbar' => 'extended_rollbar#extended_rollbar'
19
22
  end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails_helper'
4
+
5
+ describe 'Extended Rollbar', type: :request do
6
+ let!(:records_request_1) do
7
+ stub_request(:get, "http://datastore/v2/records?color=blue").to_return(body: ['blue'].to_json)
8
+ end
9
+
10
+ let!(:records_request_2) do
11
+ stub_request(:get, "http://datastore/v2/records?color=red").to_return(body: ['red'].to_json)
12
+ end
13
+
14
+ let!(:rollbar_request) do
15
+ stub_request(:post, "https://api.rollbar.com/api/1/item/")
16
+ .with do |request|
17
+ json = JSON.parse request.body
18
+ message = "Let's see if rollbar logs information about what kind of requests where made around here!"
19
+ extra = {
20
+ lhs: [
21
+ {
22
+ request: {
23
+ params: { color: 'blue' },
24
+ url: 'http://datastore/v2/records',
25
+ headers: {
26
+ 'Content-Type' => 'application/json; charset=utf-8',
27
+ 'Accept' => 'application/json,application/vnd.api+json',
28
+ 'Accept-Charset' => 'utf-8'
29
+ }
30
+ },
31
+ response: { code: 200, body: '["blue"]' }
32
+ }, {
33
+ request: {
34
+ params: { color: 'red' },
35
+ url: 'http://datastore/v2/records',
36
+ headers: {
37
+ 'Content-Type' => 'application/json; charset=utf-8',
38
+ 'Accept' => 'application/json,application/vnd.api+json',
39
+ 'Accept-Charset' => 'utf-8'
40
+ }
41
+ },
42
+ response: { code: 200, body: '["red"]' }
43
+ }
44
+ ].to_json
45
+ }
46
+ json['access_token'] == '12345' &&
47
+ json['data']['level'] == 'error' &&
48
+ json['data']['body']['trace']['exception']['message'] == message &&
49
+ json['data']['body']['trace']['extra'].to_json == extra.to_json
50
+ end
51
+ .to_return(status: 200)
52
+ end
53
+
54
+ before do
55
+ LHC.configure do |config|
56
+ config.interceptors = [LHS::ExtendedRollbar]
57
+ end
58
+ end
59
+
60
+ it 'extends default rollbar logging by adding information about the requests made during a request/response cycle',
61
+ dummy_models: true, extended_rollbar: true do
62
+ get '/extended_rollbar'
63
+ expect(records_request_1).to have_been_requested
64
+ expect(records_request_2).to have_been_requested
65
+ expect(rollbar_request).to have_been_requested
66
+ end
67
+ end
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  ENV["RAILS_ENV"] ||= 'test'
4
+ ENV['DUMMYAPP_PATH'] = "spec/dummy"
4
5
 
6
+ require 'rails/rollbar_runner'
5
7
  require 'spec_helper'
6
8
  require File.expand_path("../dummy/config/environment", __FILE__)
7
9
  require 'rspec/rails'
@@ -37,7 +37,7 @@ describe 'Request Cycle Cache', type: :request do
37
37
  expect(lambda do
38
38
  get '/request_cycle_cache/no_caching_interceptor'
39
39
  end).to output(
40
- %r{\[WARNING\] Can't enable LHS::RequestCycleCache as LHC::Caching interceptor is not enabled/configured \(see https://github.com/local-ch/lhc/blob/master/docs/interceptors/caching.md#caching-interceptor\)!}
40
+ %r{\[WARNING\] Can't enable request cycle cache as LHC::Caching interceptor is not enabled/configured \(see https://github.com/local-ch/lhc/blob/master/docs/interceptors/caching.md#caching-interceptor\)!}
41
41
  ).to_stderr
42
42
  expect(request).to have_been_made.times(2)
43
43
  end
@@ -52,11 +52,11 @@ describe 'Request Cycle Cache', type: :request do
52
52
  it 'sets different uniq request ids as base for request cycle caching for different requests',
53
53
  dummy_models: true, request_cycle_cache: true do
54
54
  get '/request_cycle_cache/simple'
55
- first_request_id = LHS::Record::RequestCycleCache::RequestCycleThreadRegistry.request_id
55
+ first_request_id = LHS::Interceptors::RequestCycleCache::ThreadRegistry.request_id
56
56
  second_request_id = nil
57
57
  thread = Thread.new do
58
58
  get '/request_cycle_cache/simple'
59
- second_request_id = LHS::Record::RequestCycleCache::RequestCycleThreadRegistry.request_id
59
+ second_request_id = LHS::Interceptors::RequestCycleCache::ThreadRegistry.request_id
60
60
  end
61
61
  thread.join
62
62
  expect(first_request_id).not_to be_nil
@@ -70,7 +70,7 @@ describe 'Request Cycle Cache', type: :request do
70
70
  expect(lambda do
71
71
  get '/request_cycle_cache/no_caching_interceptor'
72
72
  end).not_to output(
73
- %r{\[WARNING\] Can't enable LHS::RequestCycleCache as LHC::Caching interceptor is not enabled/configured \(see https://github.com/local-ch/lhc/blob/master/docs/interceptors/caching.md#caching-interceptor\)!}
73
+ %r{\[WARNING\] Can't enable request cycle cache as LHC::Caching interceptor is not enabled/configured \(see https://github.com/local-ch/lhc/blob/master/docs/interceptors/caching.md#caching-interceptor\)!}
74
74
  ).to_stderr
75
75
  expect(request).to have_been_made.times(2)
76
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 19.9.0
4
+ version: 19.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-05 00:00:00.000000000 Z
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: 4.2.11
125
+ - !ruby/object:Gem::Dependency
126
+ name: rollbar
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rspec-rails
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -261,13 +275,16 @@ files:
261
275
  - lib/lhs/concerns/record/provider.rb
262
276
  - lib/lhs/concerns/record/relations.rb
263
277
  - lib/lhs/concerns/record/request.rb
264
- - lib/lhs/concerns/record/request_cycle_cache/interceptor.rb
265
- - lib/lhs/concerns/record/request_cycle_cache/request_cycle_thread_registry.rb
266
278
  - lib/lhs/concerns/record/scope.rb
267
279
  - lib/lhs/concerns/record/tracing.rb
268
280
  - lib/lhs/config.rb
269
281
  - lib/lhs/data.rb
270
282
  - lib/lhs/endpoint.rb
283
+ - lib/lhs/interceptors/extended_rollbar/handler.rb
284
+ - lib/lhs/interceptors/extended_rollbar/interceptor.rb
285
+ - lib/lhs/interceptors/extended_rollbar/thread_registry.rb
286
+ - lib/lhs/interceptors/request_cycle_cache/interceptor.rb
287
+ - lib/lhs/interceptors/request_cycle_cache/thread_registry.rb
271
288
  - lib/lhs/item.rb
272
289
  - lib/lhs/pagination/base.rb
273
290
  - lib/lhs/pagination/link.rb
@@ -322,6 +339,7 @@ files:
322
339
  - spec/dummy/app/controllers/application_controller.rb
323
340
  - spec/dummy/app/controllers/concerns/.keep
324
341
  - spec/dummy/app/controllers/error_handling_with_chains_controller.rb
342
+ - spec/dummy/app/controllers/extended_rollbar_controller.rb
325
343
  - spec/dummy/app/controllers/option_blocks_controller.rb
326
344
  - spec/dummy/app/controllers/request_cycle_cache_controller.rb
327
345
  - spec/dummy/app/helpers/application_helper.rb
@@ -350,6 +368,7 @@ files:
350
368
  - spec/dummy/config/initializers/filter_parameter_logging.rb
351
369
  - spec/dummy/config/initializers/inflections.rb
352
370
  - spec/dummy/config/initializers/mime_types.rb
371
+ - spec/dummy/config/initializers/rollbar.rb
353
372
  - spec/dummy/config/initializers/session_store.rb
354
373
  - spec/dummy/config/initializers/wrap_parameters.rb
355
374
  - spec/dummy/config/locales/en.yml
@@ -362,6 +381,7 @@ files:
362
381
  - spec/dummy/public/500.html
363
382
  - spec/dummy/public/favicon.ico
364
383
  - spec/endpoint/for_url_spec.rb
384
+ - spec/extended_rollbar_spec.rb
365
385
  - spec/item/access_errors_spec.rb
366
386
  - spec/item/accessors_spec.rb
367
387
  - spec/item/add_error_spec.rb
@@ -535,6 +555,7 @@ test_files:
535
555
  - spec/dummy/app/controllers/application_controller.rb
536
556
  - spec/dummy/app/controllers/concerns/.keep
537
557
  - spec/dummy/app/controllers/error_handling_with_chains_controller.rb
558
+ - spec/dummy/app/controllers/extended_rollbar_controller.rb
538
559
  - spec/dummy/app/controllers/option_blocks_controller.rb
539
560
  - spec/dummy/app/controllers/request_cycle_cache_controller.rb
540
561
  - spec/dummy/app/helpers/application_helper.rb
@@ -563,6 +584,7 @@ test_files:
563
584
  - spec/dummy/config/initializers/filter_parameter_logging.rb
564
585
  - spec/dummy/config/initializers/inflections.rb
565
586
  - spec/dummy/config/initializers/mime_types.rb
587
+ - spec/dummy/config/initializers/rollbar.rb
566
588
  - spec/dummy/config/initializers/session_store.rb
567
589
  - spec/dummy/config/initializers/wrap_parameters.rb
568
590
  - spec/dummy/config/locales/en.yml
@@ -575,6 +597,7 @@ test_files:
575
597
  - spec/dummy/public/500.html
576
598
  - spec/dummy/public/favicon.ico
577
599
  - spec/endpoint/for_url_spec.rb
600
+ - spec/extended_rollbar_spec.rb
578
601
  - spec/item/access_errors_spec.rb
579
602
  - spec/item/accessors_spec.rb
580
603
  - spec/item/add_error_spec.rb
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support'
4
-
5
- class LHS::Record
6
-
7
- module RequestCycleCache
8
- extend ActiveSupport::Concern
9
-
10
- class Interceptor < LHC::Interceptor
11
-
12
- VERSION = 1
13
- CACHED_METHODS = [:get].freeze
14
-
15
- def before_request
16
- request.options = request.options.merge({
17
- cache: {
18
- expires_in: 5.minutes,
19
- race_condition_ttl: 5.seconds,
20
- key: cache_key_for(request),
21
- methods: CACHED_METHODS,
22
- use: LHS.config.request_cycle_cache
23
- }
24
- }.merge(request.options))
25
- end
26
-
27
- private
28
-
29
- def cache_key_for(request)
30
- [
31
- "LHS_REQUEST_CYCLE_CACHE(v#{VERSION})",
32
- request.method.upcase,
33
- [request.url, request.params.presence].compact.join('?'),
34
- "REQUEST=#{LHS::Record::RequestCycleCache::RequestCycleThreadRegistry.request_id}",
35
- "HEADERS=#{request.headers.hash}"
36
- ].join(' ')
37
- end
38
- end
39
- end
40
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_support'
4
-
5
- class LHS::Record
6
-
7
- module RequestCycleCache
8
- class RequestCycleThreadRegistry
9
- # Using ActiveSupports PerThreadRegistry to be able to support Active Support v4.
10
- # Will switch to thread_mattr_accessor (which comes with Activesupport) when we dropping support for Active Support v5.
11
- extend ActiveSupport::PerThreadRegistry
12
- attr_accessor :request_id
13
- end
14
- end
15
- end