Class: Rack::Insight::SpeedTracer::RequestRecord

Inherits:
TraceRecord
  • Object
show all
Defined in:
lib/rack/insight/panels/speedtracer_panel/tracer.rb

Instance Attribute Summary

Attributes inherited from TraceRecord

#children, #start

Instance Method Summary collapse

Methods inherited from TraceRecord

#duration, #finish, #time_in_children, #to_json

Methods included from Render

#compile, #compile!, #compiled_source, #method_name, #method_name_without_locals, #render_template, #signed_params

Methods included from Logging

logger, verbose, verbosity

Constructor Details

#initialize(id, method, uri) ⇒ RequestRecord

Returns a new instance of RequestRecord.



165
166
167
168
169
170
171
172
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 165

def initialize(id, method, uri)
  super()

  @id = id
  @method = method
  @uri = uri
  @event_id = 0
end

Instance Method Details

#hash_representationObject



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 178

def hash_representation
  finish
  { 'trace' =>  {

    'url' => "/__insight__/speedtracer?id=#@id",

    'frameStack' => {

      'range' => range(@start, @finish),
      'operation' =>  {
      'type' =>  'HTTP',
      'label' =>  [@method, @uri].join(' ')
    },
      'children' =>  @children

    }, #end frameStack

      'resources' => {
      'Application' => '/', #Should get the Rails app name...
      'Application.endpoint' => '/' #Should get the env path thing
    }, #From what I can tell, Speed Tracer treats this whole hash as optional

      'range' =>  range(@start, @finish)
  }
  }
end

#to_htmlObject



205
206
207
208
209
210
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 205

def to_html
  hash = hash_representation
  extra = {:self_time => duration - time_in_children}
  "<a href='#{hash['trace']['url']}'>Raw JSON</a>\n" +
    render_template('panels/speedtracer/serverevent', extra.merge(symbolize_hash(hash['trace']['frameStack'])))
end

#uuidObject



174
175
176
# File 'lib/rack/insight/panels/speedtracer_panel/tracer.rb', line 174

def uuid
  @id
end