Class: D13n::Metric::StreamState
- Inherits:
-
Object
- Object
- D13n::Metric::StreamState
- Defined in:
- lib/d13n/metric/stream_state.rb
Constant Summary collapse
- D13N_STREAM_HEADER =
'X-D13n-Stream-ID'
- D13N_APP_HEADER =
'X-D13n-App'
- REQUEST_ID_HEADER =
'HTTP_X_REQUEST_ID'
Instance Attribute Summary collapse
-
#current_stream ⇒ Object
Returns the value of attribute current_stream.
-
#is_cross_app_caller ⇒ Object
Returns the value of attribute is_cross_app_caller.
-
#referring_stream_id ⇒ Object
Returns the value of attribute referring_stream_id.
-
#request ⇒ Object
Returns the value of attribute request.
-
#request_info ⇒ Object
Returns the value of attribute request_info.
-
#tag_hash ⇒ Object
Returns the value of attribute tag_hash.
-
#traced_span_stack ⇒ Object
readonly
Returns the value of attribute traced_span_stack.
Class Method Summary collapse
- .default_metric_data ⇒ Object
- .request_info ⇒ Object
- .st_get ⇒ Object
- .st_state_for(thread) ⇒ Object
Instance Method Summary collapse
- #clear_referring_stream_id ⇒ Object
-
#initialize ⇒ StreamState
constructor
A new instance of StreamState.
- #notify_call(request) ⇒ Object
- #notify_rack_call(request) ⇒ Object
- #reset(stream = nil) ⇒ Object
- #save_referring_stream_id(request) ⇒ Object
Constructor Details
#initialize ⇒ StreamState
Returns a new instance of StreamState.
39 40 41 42 43 44 |
# File 'lib/d13n/metric/stream_state.rb', line 39 def initialize @traced_span_stack = D13n::Metric::Stream::TracedSpanStack.new @current_stream = nil @referring_stream_id = nil @is_cross_app_caller = false end |
Instance Attribute Details
#current_stream ⇒ Object
Returns the value of attribute current_stream.
35 36 37 |
# File 'lib/d13n/metric/stream_state.rb', line 35 def current_stream @current_stream end |
#is_cross_app_caller ⇒ Object
Returns the value of attribute is_cross_app_caller.
37 38 39 |
# File 'lib/d13n/metric/stream_state.rb', line 37 def is_cross_app_caller @is_cross_app_caller end |
#referring_stream_id ⇒ Object
Returns the value of attribute referring_stream_id.
37 38 39 |
# File 'lib/d13n/metric/stream_state.rb', line 37 def referring_stream_id @referring_stream_id end |
#request ⇒ Object
Returns the value of attribute request.
36 37 38 |
# File 'lib/d13n/metric/stream_state.rb', line 36 def request @request end |
#request_info ⇒ Object
Returns the value of attribute request_info.
33 34 35 |
# File 'lib/d13n/metric/stream_state.rb', line 33 def request_info @request_info end |
#tag_hash ⇒ Object
Returns the value of attribute tag_hash.
34 35 36 |
# File 'lib/d13n/metric/stream_state.rb', line 34 def tag_hash @tag_hash end |
#traced_span_stack ⇒ Object (readonly)
Returns the value of attribute traced_span_stack.
32 33 34 |
# File 'lib/d13n/metric/stream_state.rb', line 32 def traced_span_stack @traced_span_stack end |
Class Method Details
.default_metric_data ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/d13n/metric/stream_state.rb', line 22 def self.default_metric_data state = st_get stream = state.current_stream if stream stream.default_metric_data else {} end end |
.request_info ⇒ Object
18 19 20 |
# File 'lib/d13n/metric/stream_state.rb', line 18 def self.request_info st_get.request_info end |
.st_get ⇒ Object
10 11 12 |
# File 'lib/d13n/metric/stream_state.rb', line 10 def self.st_get st_state_for(Thread.current) end |
.st_state_for(thread) ⇒ Object
14 15 16 |
# File 'lib/d13n/metric/stream_state.rb', line 14 def self.st_state_for(thread) thread[:d13n_stream_state] ||= new end |
Instance Method Details
#clear_referring_stream_id ⇒ Object
64 65 66 |
# File 'lib/d13n/metric/stream_state.rb', line 64 def clear_referring_stream_id() @referring_stream_id = nil end |
#notify_call(request) ⇒ Object
56 57 58 |
# File 'lib/d13n/metric/stream_state.rb', line 56 def notify_call(request) save_referring_stream_id(request) end |
#notify_rack_call(request) ⇒ Object
52 53 54 |
# File 'lib/d13n/metric/stream_state.rb', line 52 def notify_rack_call(request) notify_call(request) end |
#reset(stream = nil) ⇒ Object
46 47 48 49 50 |
# File 'lib/d13n/metric/stream_state.rb', line 46 def reset(stream=nil) @traced_span_stack.clear @current_stream = stream @is_cross_app_caller = false end |
#save_referring_stream_id(request) ⇒ Object
60 61 62 |
# File 'lib/d13n/metric/stream_state.rb', line 60 def save_referring_stream_id(request) @referring_stream_id = request[D13N_STREAM_HEADER] if request[D13N_STREAM_HEADER] end |