Class: Insight::SpeedTracer::Panel

Inherits:
Panel
  • Object
show all
Defined in:
lib/insight/panels/speedtracer_panel.rb

Instance Attribute Summary

Attributes inherited from Panel

#request

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Panel

#after, #before, current_panel_file, excluded, file_index, from_file, #has_content?, #heading_for_request, inherited, #panel_app, panel_exclusion, #render

Methods included from Instrumentation::Client

#after_detect, #before_detect, #probe, #request_finish, #request_start

Methods included from Logging

logger

Methods included from Database::RequestDataClient

#key_sql_template, #retrieve, #store, #table_length, #table_setup

Methods included from Render

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

Constructor Details

#initialize(app) ⇒ Panel

Returns a new instance of Panel.



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
49
50
51
52
53
# File 'lib/insight/panels/speedtracer_panel.rb', line 14

def initialize(app)
  @app = app
  @uuid = UUID.new
  table_setup("speedtracer", "uuid")
  key_sql_template("'%s'")

  @tracer = Tracer.new(@table)
  probe(@tracer) do
    instrument("ActiveSupport::Notifications") do
      class_probe :instrument
    end

    instrument("ActionView::Rendering") do
      instance_probe :render
    end

    instrument("ActionView::Helpers::RecordTagHelper") do
      instance_probe :content_tag_for
    end

    instrument("ActionView::Partials::PartialRenderer") do
      instance_probe :render, :find_template, :render_collection, :collection_with_template, :collection_without_template, :partial_path, :collection_paths
    end

    instrument("ActionView::Template") do
      instance_probe :render, :compile
    end

    instrument("ActiveRecord::Base") do
      class_probe :find, :find_by_sql, :all, :first, :last, :count, :delete_all
      instance_probe :save, :save!, :destroy, :delete
    end

    instrument("ActionController::Base") do
      instance_probe :process, :render
    end
  end

  super
end

Class Method Details

.panel_mappingsObject



66
67
68
# File 'lib/insight/panels/speedtracer_panel.rb', line 66

def self.panel_mappings
  { "speedtracer" => TraceApp.new }
end

Instance Method Details

#call(env) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'lib/insight/panels/speedtracer_panel.rb', line 56

def call(env)
  env['insight.speedtracer-id'] = @uuid.generate

  status, headers, body = @app.call(env)

  store(env, env['insight.speedtracer-id'], env['insight.speedtracer-record'])
  headers['X-TraceUrl'] = '__insight__/speedtracer?id=' + env['insight.speedtracer-id']
  return [status, headers, body]
end

#content_for_request(request_id) ⇒ Object



78
79
80
81
82
83
84
85
86
# File 'lib/insight/panels/speedtracer_panel.rb', line 78

def content_for_request(request_id)
trace = retrieve(request_id).first
return "" if trace.nil?
advice = []
if not defined?(Yajl)
  advice << "yajl-ruby not installed - Speedtracer server events won't be available"
end
render_template "panels/speedtracer/traces", :trace => trace, :advice => advice
end

#headingObject



74
75
76
# File 'lib/insight/panels/speedtracer_panel.rb', line 74

def heading
  "#{table_length} traces"
end

#nameObject



70
71
72
# File 'lib/insight/panels/speedtracer_panel.rb', line 70

def name
  "speedtracer"
end