Sha256: 6b36654246d48a5d2059c09950dd4c74e7b87d8721ac494564d6c6eb43b07a62

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

# encoding: utf-8
require 'ting_yun/agent/database'
module TingYun
  module Agent
    module Collector
      class SlowSql
        attr_reader :statement
        attr_reader :metric_name
        attr_reader :duration
        attr_reader :backtrace
        attr_reader :start_time


        def initialize(statement, metric_name, duration, time,  backtrace=nil)
          @start_time = time
          @statement = statement
          @metric_name = metric_name
          @duration = duration
          @backtrace = backtrace
        end

        def sql
          statement.sql
        end

        def obfuscate
          TingYun::Agent::Database.obfuscate_sql(statement)
        end


        def normalize
          TingYun::Agent::Database::Obfuscator.instance.default_sql_obfuscator(statement)
        end

        def explain
          TingYun::Agent::Database.explain_sql(statement) if statement.config && statement.explainer
        end

        # We can't serialize the explainer, so clear it before we transmit
        def prepare_to_send
          statement.explainer = nil
        end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tingyun_rpm-3.2.0 lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb
tingyun_rpm-1.6.1 lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb
tingyun_rpm-1.5.0 lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb
tingyun_rpm-1.4.2 lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb
tingyun_rpm-1.4.1 lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb
tingyun_rpm-1.3.1 lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb
tingyun_rpm-1.3.0 lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb
tingyun_rpm-1.2.0 lib/ting_yun/agent/collector/sql_sampler/slow_sql.rb