Module: BaselineRedRpm::Instruments::ActiveRecord::Adapters::Mysql2
- Includes:
- Utils
- Defined in:
- lib/baseline_red_rpm/instruments/active_record/adapters/mysql2.rb
Constant Summary
collapse
- IGNORE_STATEMENTS =
{
"SCHEMA" => true,
"EXPLAIN" => true,
"CACHE" => true
}
Instance Method Summary
collapse
Methods included from Utils
#connection_config, #format_redis, #format_redis_command, log_source_and_backtrace, #sanitize_sql
Instance Method Details
#execute_with_trace(sql, name = nil) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/baseline_red_rpm/instruments/active_record/adapters/mysql2.rb', line 22
def execute_with_trace(sql, name = nil)
if ::BaselineRedRpm::Tracer.tracing?
unless ignore_trace?(name)
adapter = connection_config.fetch(:adapter)
sanitized_sql = sanitize_sql(sql, adapter)
span = BaselineRedRpm.tracer.start_span(name || 'SQL', tags: {
"component" => "ActiveRecord",
"span.kind" => "client",
"db.statement" => sanitized_sql,
"db.user" => connection_config.fetch(:username, 'unknown'),
"db.instance" => connection_config.fetch(:database),
"db.vendor" => adapter,
"db.type" => "sql"
})
BaselineRedRpm::Utils.log_source_and_backtrace(span, :active_record)
end
end
execute_without_trace(sql, name)
rescue Exception => e
if span
span.set_tag('error', true)
span.log_error(e)
end
raise
ensure
span.finish if span
end
|
#ignore_trace?(name) ⇒ Boolean
16
17
18
19
20
|
# File 'lib/baseline_red_rpm/instruments/active_record/adapters/mysql2.rb', line 16
def ignore_trace?(name)
IGNORE_STATEMENTS[name.to_s] ||
(name && name.to_sym == :skip_logging) ||
name == 'ActiveRecord::SchemaMigration Load'
end
|