Module: Sequel::TracingDataset

Defined in:
lib/sequel/extensions/dataset_instrumentation.rb

Constant Summary collapse

OPTS =

datasets are included, not extended

{}.freeze

Instance Method Summary collapse

Instance Method Details

#execute(sql, opts = OPTS, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/sequel/extensions/dataset_instrumentation.rb', line 9

def execute(sql, opts = OPTS, &block)
  tags = populate_tracing_tags(sql)

  ::Sequel::Instrumentation.trace_query('sequel.dataset.execute', tags) do
    super
  end
end

#execute_dui(sql, opts = OPTS, &block) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/sequel/extensions/dataset_instrumentation.rb', line 17

def execute_dui(sql, opts = OPTS, &block)
  tags = populate_tracing_tags(sql)

  ::Sequel::Instrumentation.trace_query('sequel.dataset.execute', tags) do
    super
  end
end

#execute_insert(sql, opts = OPTS, &block) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/sequel/extensions/dataset_instrumentation.rb', line 25

def execute_insert(sql, opts = OPTS, &block)
  tags = populate_tracing_tags(sql)

  ::Sequel::Instrumentation.trace_query('sequel.dataset.execute_insert', tags) do
    super
  end
end

#populate_tracing_tags(sql) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/sequel/extensions/dataset_instrumentation.rb', line 33

def populate_tracing_tags(sql)
  tags = {
    'db.type' => @db.database_type.to_s,
    'db.statement' => sql,
  }
  tags['db.instance'] = @opts[:from].first.to_s if @opts[:from] && !@opts[:from].empty?

  tags
end