Class: Rack::SpeedTracer::ServerEvent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from TraceRecord

#finish

Constructor Details

#initialize(id, file, line, method, name) ⇒ ServerEvent

Returns a new instance of ServerEvent.



27
28
29
30
31
32
33
34
# File 'lib/rack/speedtracer/tracer.rb', line 27

def initialize(id, file, line, method, name)
  super(id)

  @file = file
  @line = line
  @method = method
  @name = name
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



25
26
27
# File 'lib/rack/speedtracer/tracer.rb', line 25

def children
  @children
end

Instance Method Details

#to_jsonObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rack/speedtracer/tracer.rb', line 36

def to_json
  Yajl::Encoder.encode({
    'range' => range(@start, @finish),
    'id' =>  @id,
    'operation' =>  {
      'sourceCodeLocation' =>  {
        'className'   =>  @file,
        'methodName'  =>  @method,
        'lineNumber'  =>  @line
      },
      'type' =>  'METHOD',
      'label' =>  @name
    },
    'children' =>  @children
  })
end