Class: Couchbase::Tracing::ThresholdLoggingSpan
- Inherits:
-
RequestSpan
- Object
- RequestSpan
- Couchbase::Tracing::ThresholdLoggingSpan
- Defined in:
- lib/couchbase/tracing/threshold_logging_span.rb,
/home/runner/work/couchbase-ruby-client/couchbase-ruby-client/lib/couchbase/tracing/threshold_logging_span.rb
Instance Attribute Summary collapse
-
#encode_duration_us ⇒ Object
Returns the value of attribute encode_duration_us.
-
#last_dispatch_duration_us ⇒ Object
Returns the value of attribute last_dispatch_duration_us.
-
#last_local_id ⇒ Object
Returns the value of attribute last_local_id.
-
#last_peer_address ⇒ Object
Returns the value of attribute last_peer_address.
-
#last_peer_port ⇒ Object
Returns the value of attribute last_peer_port.
-
#last_server_duration_us ⇒ Object
Returns the value of attribute last_server_duration_us.
-
#name ⇒ Object
Returns the value of attribute name.
-
#operation_id ⇒ Object
Returns the value of attribute operation_id.
-
#service ⇒ Object
Returns the value of attribute service.
-
#should_report ⇒ Object
Returns the value of attribute should_report.
-
#total_dispatch_duration_us ⇒ Object
Returns the value of attribute total_dispatch_duration_us.
-
#total_server_duration_us ⇒ Object
Returns the value of attribute total_server_duration_us.
Instance Method Summary collapse
- #finish(end_timestamp: nil) ⇒ Object
-
#initialize(name, start_timestamp: nil, parent: nil, tracer: nil) ⇒ ThresholdLoggingSpan
constructor
A new instance of ThresholdLoggingSpan.
- #set_attribute(key, value) ⇒ Object
- #status= ⇒ Object
Constructor Details
#initialize(name, start_timestamp: nil, parent: nil, tracer: nil) ⇒ ThresholdLoggingSpan
Returns a new instance of ThresholdLoggingSpan.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 36 def initialize(name, start_timestamp: nil, parent: nil, tracer: nil) super() @name = name @parent = parent @tracer = tracer @start_timestamp = if .nil? Time.now else end end |
Instance Attribute Details
#encode_duration_us ⇒ Object
Returns the value of attribute encode_duration_us.
26 27 28 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 26 def encode_duration_us @encode_duration_us end |
#last_dispatch_duration_us ⇒ Object
Returns the value of attribute last_dispatch_duration_us.
27 28 29 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 27 def last_dispatch_duration_us @last_dispatch_duration_us end |
#last_local_id ⇒ Object
Returns the value of attribute last_local_id.
31 32 33 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 31 def last_local_id @last_local_id end |
#last_peer_address ⇒ Object
Returns the value of attribute last_peer_address.
33 34 35 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 33 def last_peer_address @last_peer_address end |
#last_peer_port ⇒ Object
Returns the value of attribute last_peer_port.
34 35 36 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 34 def last_peer_port @last_peer_port end |
#last_server_duration_us ⇒ Object
Returns the value of attribute last_server_duration_us.
29 30 31 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 29 def last_server_duration_us @last_server_duration_us end |
#name ⇒ Object
Returns the value of attribute name.
23 24 25 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 23 def name @name end |
#operation_id ⇒ Object
Returns the value of attribute operation_id.
32 33 34 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 32 def operation_id @operation_id end |
#service ⇒ Object
Returns the value of attribute service.
25 26 27 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 25 def service @service end |
#should_report ⇒ Object
Returns the value of attribute should_report.
24 25 26 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 24 def should_report @should_report end |
#total_dispatch_duration_us ⇒ Object
Returns the value of attribute total_dispatch_duration_us.
28 29 30 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 28 def total_dispatch_duration_us @total_dispatch_duration_us end |
#total_server_duration_us ⇒ Object
Returns the value of attribute total_server_duration_us.
30 31 32 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 30 def total_server_duration_us @total_server_duration_us end |
Instance Method Details
#finish(end_timestamp: nil) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 68 def finish(end_timestamp: nil) duration_us = ((( || Time.now) - @start_timestamp) * 1_000_000).round case name when Observability::STEP_REQUEST_ENCODING return if @parent.nil? @parent.should_report = true @parent.encode_duration_us = duration_us when Observability::STEP_DISPATCH_TO_SERVER return if @parent.nil? @parent.should_report = true @parent.last_dispatch_duration_us = duration_us @parent.total_dispatch_duration_us = 0 if @parent.total_dispatch_duration_us.nil? @parent.total_dispatch_duration_us += duration_us unless @last_server_duration_us.nil? @parent.last_server_duration_us = @last_server_duration_us @parent.total_server_duration_us = 0 if @parent.total_server_duration_us.nil? @parent.total_server_duration_us += @last_server_duration_us end @parent.last_local_id = @last_local_id @parent.operation_id = @operation_id @parent.last_peer_address = @last_peer_address @parent.last_peer_port = @last_peer_port else @should_report ||= @parent.nil? return unless @should_report && !@service.nil? @tracer.record_operation(@service, ThresholdLoggingTracer::Item.new( total_duration_us: duration_us, encode_duration_us: @encode_duration_us, last_dispatch_duration_us: @last_dispatch_duration_us, total_dispatch_duration_us: @total_dispatch_duration_us, last_server_duration_us: @last_server_duration_us, total_server_duration_us: @total_server_duration_us, operation_name: @name, last_local_id: @last_local_id, operation_id: @operation_id, last_remote_socket: "#{@last_peer_address}:#{@last_peer_port}", )) end end |
#set_attribute(key, value) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 49 def set_attribute(key, value) case key when Observability::ATTR_OPERATION_ID @operation_id = value when Observability::ATTR_LOCAL_ID @last_local_id = value when Observability::ATTR_PEER_ADDRESS @last_peer_address = value when Observability::ATTR_PEER_PORT @last_peer_port = value when Observability::ATTR_SERVICE @service = value when Observability::ATTR_SERVER_DURATION @last_server_duration_us = value end end |
#status= ⇒ Object
66 |
# File 'lib/couchbase/tracing/threshold_logging_span.rb', line 66 def status=(*); end |