Module: Sentry::Sequel::DatabaseExtension

Defined in:
lib/sentry/sequel.rb

Overview

Sequel Database extension module that instruments queries

Instance Method Summary collapse

Instance Method Details

#log_connection_yield(sql, conn, args = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sentry/sequel.rb', line 10

def log_connection_yield(sql, conn, args = nil)
  return super unless Sentry.initialized?

  Sentry.with_child_span(op: OP_NAME, start_timestamp: Sentry.utc_now.to_f, origin: SPAN_ORIGIN) do |span|
    result = super

    if span
      span.set_description(sql)
      span.set_data(Span::DataConventions::DB_SYSTEM, database_type.to_s)
      span.set_data(Span::DataConventions::DB_NAME, opts[:database]) if opts[:database]
      span.set_data(Span::DataConventions::SERVER_ADDRESS, opts[:host]) if opts[:host]
      span.set_data(Span::DataConventions::SERVER_PORT, opts[:port]) if opts[:port]
    end

    result
  end
end