module OneApm module Agent class Agent module Helpers def obfuscator @obfuscator ||= lambda {|sql| OneApm::Agent::Database.default_sql_obfuscator(sql) } end # Sets a thread local variable as to whether we should or # should not record sql in the current thread. Returns the # previous value, if there is one def set_record_sql(should_record) #THREAD_LOCAL_ACCESS state = TransactionState.tl_get prev = state.record_sql state.record_sql = should_record prev.nil? || prev end # Sets a thread local variable as to whether we should or # should not record transaction traces in the current # thread. Returns the previous value, if there is one def set_record_tt(should_record) #THREAD_LOCAL_ACCESS state = TransactionState.tl_get prev = state.record_tt state.record_tt = should_record prev.nil? || prev end # Push flag indicating whether we should be tracing in this # thread. This uses a stack which allows us to disable tracing # children of a transaction without affecting the tracing of # the whole transaction def push_trace_execution_flag(should_trace=false) #THREAD_LOCAL_ACCESS TransactionState.tl_get.push_traced(should_trace) end # Pop the current trace execution status. Restore trace execution status # to what it was before we pushed the current flag. def pop_trace_execution_flag #THREAD_LOCAL_ACCESS TransactionState.tl_get.pop_traced end end end end end