module TraceView::Grape::Endpoint

Public Class Methods

included(klass) click to toggle source
# File lib/traceview/frameworks/grape.rb, line 19
def self.included(klass)
  ::TraceView::Util.method_alias(klass, :run, ::Grape::Endpoint)
end

Public Instance Methods

run_with_traceview(*args) click to toggle source
# File lib/traceview/frameworks/grape.rb, line 23
def run_with_traceview(*args)
  if TraceView.tracing?
    report_kvs = {}

    report_kvs[:Controller] = self.class

    if args.empty?
      report_kvs[:Action] = env['PATH_INFO']
    else
      report_kvs[:Action] = args[0]['PATH_INFO']
    end

    # 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(*args)
    ensure
      ::TraceView::API.log_exit('grape', report_kvs)
    end
  else
    run_without_traceview(*args)
  end
end