Class: Rack::Bug::SpeedTrace::ServerEvent

Inherits:
TraceRecord
  • Object
show all
Defined in:
lib/rack/bug/speedtracer/tracer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TraceRecord

#duration, #finish, #time_in_children, #to_json

Methods included from Render

#compiled_source

Constructor Details

#initialize(id, file, line, method, context, arguments) ⇒ ServerEvent

Returns a new instance of ServerEvent.



53
54
55
56
57
58
59
60
61
62
# File 'lib/rack/bug/speedtracer/tracer.rb', line 53

def initialize(id, file, line, method, context, arguments)
  super(id)

  @file = file
  @line = line
  @method = method
  @context = context
  @arguments = arguments
  @name = [context, method, "(", arguments, ")"].join("")
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



50
51
52
# File 'lib/rack/bug/speedtracer/tracer.rb', line 50

def children
  @children
end

#nameObject (readonly)

Returns the value of attribute name.



51
52
53
# File 'lib/rack/bug/speedtracer/tracer.rb', line 51

def name
  @name
end

Instance Method Details

#hash_representationObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/rack/bug/speedtracer/tracer.rb', line 64

def hash_representation
  {
    'range' => range(@start, @finish),
    #'id' =>  @id,
    'operation' =>  {
    #          'sourceCodeLocation' =>  {
    #          'className'   =>  @file,
    #          'methodName'  =>  @method,
    #          'lineNumber'  =>  @line
    #        },
    'type' =>  'METHOD',
    'label' =>  @name
  },
    'children' =>  @children
  }
end

#to_htmlObject



81
82
83
84
# File 'lib/rack/bug/speedtracer/tracer.rb', line 81

def to_html
  render_template('serverevent', 
                  {:self_time => duration - time_in_children}.merge(symbolize_hash(hash_representation)))
end