class InfluxReporter::Injections::Sinatra::Injector

Public Instance Methods

compile_template(engine, data, opts, *args, &block) click to toggle source
# File lib/influx_reporter/injections/sinatra.rb, line 21
def compile_template(engine, data, opts, *args, &block)
  opts[:__influx_reporter_template_sig] = case data
                                            when Symbol
                                              data.to_s
                                            else
                                              "Inline #{engine}"
                                          end

  compile_template_with_opb(engine, data, opts, *args, &block)
end
dispatch!(*args, &block) click to toggle source
# File lib/influx_reporter/injections/sinatra.rb, line 12
def dispatch!(*args, &block)
  dispatch_without_opb!(*args, &block).tap do
    transaction = InfluxReporter.transaction(nil)
    if (route = env['sinatra.route']) && transaction
      transaction.endpoint = route
    end
  end
end
install() click to toggle source
# File lib/influx_reporter/injections/sinatra.rb, line 7
def install
  ::Sinatra::Base.class_eval do
    alias_method :dispatch_without_opb!, :dispatch!
    alias_method :compile_template_with_opb, :compile_template

    def dispatch!(*args, &block)
      dispatch_without_opb!(*args, &block).tap do
        transaction = InfluxReporter.transaction(nil)
        if (route = env['sinatra.route']) && transaction
          transaction.endpoint = route
        end
      end
    end

    def compile_template(engine, data, opts, *args, &block)
      opts[:__influx_reporter_template_sig] = case data
                                                when Symbol
                                                  data.to_s
                                                else
                                                  "Inline #{engine}"
                                              end

      compile_template_with_opb(engine, data, opts, *args, &block)
    end
  end
end