Class: Mmtrix::Agent::TransactionSampler

Inherits:
Object
  • Object
show all
Defined in:
lib/mmtrix/agent/transaction_sampler.rb

Overview

This class contains the logic for recording and storing transaction traces (sometimes referred to as ‘transaction samples’).

A transaction trace is a detailed timeline of the events that happened during the processing of a single transaction, including database calls, template rendering calls, and other instrumented method calls.

Instance Method Summary collapse

Instance Method Details

#notice_nosql(key, duration) ⇒ Object

Deprecated.

Attaches an additional non-SQL query parameter to the current transaction trace node.

This may be used for recording a query against a key-value store like memcached or redis.

This method should be used only by gem authors wishing to extend the Ruby agent to instrument uninstrumented key-value stores - it should generally not be called directly from application code.

Parameters:

  • key (String)

    the name of the key that was queried

  • duration (Float)

    number of seconds the query took to execute



224
225
226
227
# File 'lib/mmtrix/agent/transaction_sampler.rb', line 224

def notice_nosql(key, duration) #THREAD_LOCAL_ACCESS
  builder = tl_builder
  notice_extra_data(builder, key, duration, :key)
end

#notice_sql(sql, config, duration, state = nil, explainer = nil) ⇒ Object

Deprecated.

Use Datastores.notice_sql instead.

Attaches an SQL query on the current transaction trace node.

This method should be used only by gem authors wishing to extend the Ruby agent to instrument new database interfaces - it should generally not be called directly from application code.

Parameters:

  • sql (String)

    the SQL query being recorded

  • config (Object)

    the driver configuration for the connection

  • duration (Float)

    number of seconds the query took to execute

  • explainer (Proc) (defaults to: nil)

    for internal use only - 3rd-party clients must not pass this parameter.



186
187
188
189
190
191
192
193
194
195
# File 'lib/mmtrix/agent/transaction_sampler.rb', line 186

def notice_sql(sql, config, duration, state=nil, explainer=nil) #THREAD_LOCAL_ACCESS sometimes
  # some statements (particularly INSERTS with large BLOBS
  # may be very large; we should trim them to a maximum usable length
  state ||= TransactionState.tl_get
  builder = state.transaction_sample_builder
  if state.is_sql_recorded?
    statement = build_database_statement(sql, config, explainer)
    notice_extra_data(builder, statement, duration, :sql)
  end
end