Class: Utils::ServiceObserver
- Inherits:
-
Object
- Object
- Utils::ServiceObserver
- Defined in:
- lib/xray_method_tracer/utils/service_observer.rb
Instance Attribute Summary collapse
-
#segment ⇒ Object
Returns the value of attribute segment.
Class Method Summary collapse
- .begin_subsegment(segment_name) ⇒ Object
-
.capture(segment_name) ⇒ Object
カスタム計装をする際には、下記のように記述する事で軽装を実施する事ができる ServiceObserver.capture(‘segment_name’) do somefunction() end.
- .end_subsegment ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#segment ⇒ Object
Returns the value of attribute segment.
12 13 14 |
# File 'lib/xray_method_tracer/utils/service_observer.rb', line 12 def segment @segment end |
Class Method Details
.begin_subsegment(segment_name) ⇒ Object
26 27 28 29 |
# File 'lib/xray_method_tracer/utils/service_observer.rb', line 26 def begin_subsegment(segment_name) segment = XRay.recorder.begin_subsegment(segment_name) new(segment) end |
.capture(segment_name) ⇒ Object
カスタム計装をする際には、下記のように記述する事で軽装を実施する事ができる ServiceObserver.capture(‘segment_name’) do
somefunction()
end
19 20 21 22 23 24 |
# File 'lib/xray_method_tracer/utils/service_observer.rb', line 19 def capture(segment_name) begin_subsegment(segment_name) yield ensure end_subsegment end |
.end_subsegment ⇒ Object
31 32 33 |
# File 'lib/xray_method_tracer/utils/service_observer.rb', line 31 def end_subsegment XRay.recorder.end_subsegment end |
Instance Method Details
#add_exception(error) ⇒ Object
66 67 68 |
# File 'lib/xray_method_tracer/utils/service_observer.rb', line 66 def add_exception(error) segment.add_exception(exception: error) end |
#add_metadata(key, value) ⇒ Object
62 63 64 |
# File 'lib/xray_method_tracer/utils/service_observer.rb', line 62 def (key, value) segment.[key] = value end |