Module: TraceView::Grape::Endpoint

Defined in:
lib/traceview/frameworks/grape.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



19
20
21
# File 'lib/traceview/frameworks/grape.rb', line 19

def self.included(klass)
  ::TraceView::Util.method_alias(klass, :run, ::Grape::Endpoint)
end

Instance Method Details

#run_with_traceview(env) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/traceview/frameworks/grape.rb', line 23

def run_with_traceview(env)
  if TraceView.tracing?
    report_kvs = {}

    report_kvs[:Controller] = self.class
    report_kvs[:Action] = env['PATH_INFO']

    # Fall back to the raw tracing API so we can pass KVs
    # back on exit (a limitation of the TraceView::API.trace
    # block method) This removes the need for an info
    # event to send additonal KVs
    ::TraceView::API.log_entry('grape', {})

    begin
      run_without_traceview(env)
    ensure
      ::TraceView::API.log_exit('grape', report_kvs)
    end
  else
    run_without_traceview(env)
  end
end