Class: StackifyRubyAPM::Util::Inspector Private
- Inherits:
-
Object
- Object
- StackifyRubyAPM::Util::Inspector
- Defined in:
- lib/stackify_apm/util/inspector.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize(width = 80) ⇒ Inspector
constructor
private
A new instance of Inspector.
- #transaction(transaction) ⇒ Object private
Constructor Details
#initialize(width = 80) ⇒ Inspector
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Inspector.
5 6 7 |
# File 'lib/stackify_apm/util/inspector.rb', line 5 def initialize(width = 80) @width = width end |
Instance Method Details
#transaction(transaction) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/stackify_apm/util/inspector.rb', line 9 def transaction(transaction) unless transaction.done? raise ArgumentError, 'Transaction still running' end width_factor = @width.to_f / ms(transaction.duration) lines = ['=' * @width] lines << "[T] #{transaction.name} " \ "- #{transaction.type} (#{ms transaction.duration} ms)" lines << "+#{'-' * (@width - 2)}+" transaction.spans.each do |span| indent = (ms(span.relative_start) * width_factor).to_i if span.duration span_width = ms(span.duration) * width_factor duration_desc = ms(span.duration) else span_width = @width - indent duration_desc = 'RUNNING' end description = "[#{span.id}] " \ "#{span.name} - #{span.type} (#{duration_desc} ms)" description_indent = [ 0, [indent, @width - description.length].min ].max lines << "#{' ' * description_indent}#{description}" lines << "#{' ' * indent}+#{'-' * [(span_width - 2), 0].max}+" end lines.map { |s| s[0..@width] }.join("\n") rescue StandardError => e puts e puts e.backtrace.join("\n") nil end |