Module: Oboe::Inst::SequelDatabase

Defined in:
lib/oboe/inst/sequel.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



43
44
45
46
47
48
# File 'lib/oboe/inst/sequel.rb', line 43

def self.included(klass)
  ::Oboe::Util.method_alias(klass, :run, ::Sequel::Database)
  ::Oboe::Util.method_alias(klass, :execute_ddl, ::Sequel::Database)
  ::Oboe::Util.method_alias(klass, :execute_dui, ::Sequel::Database)
  ::Oboe::Util.method_alias(klass, :execute_insert, ::Sequel::Database)
end

Instance Method Details

#exec_with_oboe(method, sql, opts = ::Sequel::OPTS, &block) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/oboe/inst/sequel.rb', line 63

def exec_with_oboe(method, sql, opts=::Sequel::OPTS, &block)
  kvs = extract_trace_details(sql, opts)

  Oboe::API.log_entry('sequel', kvs)

  send(method, sql, opts, &block)
rescue => e
  Oboe::API.log_exception('sequel', e)
  raise e
ensure
  Oboe::API.log_exit('sequel')
end

#execute_ddl_with_oboe(sql, opts = ::Sequel::OPTS, &block) ⇒ Object



76
77
78
79
80
81
82
# File 'lib/oboe/inst/sequel.rb', line 76

def execute_ddl_with_oboe(sql, opts=::Sequel::OPTS, &block)
  # If we're already tracing a sequel operation, then this call likely came
  # from Sequel::Dataset.  In this case, just pass it on.
  return execute_ddl_without_oboe(sql, opts, &block) if Oboe.tracing_layer?('sequel')

  exec_with_oboe(:execute_ddl_without_oboe, sql, opts, &block)
end

#execute_dui_with_oboe(sql, opts = ::Sequel::OPTS, &block) ⇒ Object



84
85
86
87
88
89
90
# File 'lib/oboe/inst/sequel.rb', line 84

def execute_dui_with_oboe(sql, opts=::Sequel::OPTS, &block)
  # If we're already tracing a sequel operation, then this call likely came
  # from Sequel::Dataset.  In this case, just pass it on.
  return execute_dui_without_oboe(sql, opts, &block) if Oboe.tracing_layer?('sequel')

  exec_with_oboe(:execute_dui_without_oboe, sql, opts, &block)
end

#execute_insert_with_oboe(sql, opts = ::Sequel::OPTS, &block) ⇒ Object



92
93
94
95
96
97
98
# File 'lib/oboe/inst/sequel.rb', line 92

def execute_insert_with_oboe(sql, opts=::Sequel::OPTS, &block)
  # If we're already tracing a sequel operation, then this call likely came
  # from Sequel::Dataset.  In this case, just pass it on.
  return execute_insert_without_oboe(sql, opts, &block) if Oboe.tracing_layer?('sequel')

  exec_with_oboe(:execute_insert_without_oboe, sql, opts, &block)
end

#run_with_oboe(sql, opts = ::Sequel::OPTS) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/oboe/inst/sequel.rb', line 50

def run_with_oboe(sql, opts=::Sequel::OPTS)
  kvs = extract_trace_details(sql, opts)

  Oboe::API.log_entry('sequel', kvs)

  run_without_oboe(sql, opts)
rescue => e
  Oboe::API.log_exception('sequel', e)
  raise e
ensure
  Oboe::API.log_exit('sequel')
end