Class: RequestTagger::Setup
- Inherits:
-
Object
- Object
- RequestTagger::Setup
- Defined in:
- lib/request_tagger/setup.rb
Class Method Summary collapse
- .http_tag ⇒ Object
- .inbound_header ⇒ Object
- .request_id ⇒ Object
- .request_id=(val) ⇒ Object
- .sql_tag ⇒ Object
- .start(options = {}) ⇒ Object
- .stop ⇒ Object
Class Method Details
.http_tag ⇒ Object
36 37 38 |
# File 'lib/request_tagger/setup.rb', line 36 def self.http_tag { field: http_tag_identifier, value: request_id } end |
.inbound_header ⇒ Object
28 29 30 |
# File 'lib/request_tagger/setup.rb', line 28 def self.inbound_header @options[:header] || 'HTTP_X_REQUEST_ID' end |
.request_id ⇒ Object
47 48 49 |
# File 'lib/request_tagger/setup.rb', line 47 def self.request_id Thread.current[:__request_tagger__request_id__] || uninitialized end |
.request_id=(val) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/request_tagger/setup.rb', line 40 def self.request_id=(val) # I would prefer not to use `Thread.current` for storage but, since we # can't control what kind of Rails server is in use, we don't have much # choice. Thread.current[:__request_tagger__request_id__] = val end |
.sql_tag ⇒ Object
32 33 34 |
# File 'lib/request_tagger/setup.rb', line 32 def self.sql_tag "/* #{sql_tag_identifier}: #{sql_sanitize(request_id)} */" end |
.start(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/request_tagger/setup.rb', line 7 def self.start( = {}) raise AlreadyStartedError, I18n.t('errors.start_once') if @initialized @options = wrap_active_record wrap_http @initialized = true end |
.stop ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/request_tagger/setup.rb', line 18 def self.stop return unless @initialized restore_active_record restore_http @options = {} @initialized = false end |