Module: Datadog::Tracing::Contrib::Sequel::Database::InstanceMethods

Defined in:
lib/datadog/tracing/contrib/sequel/database.rb

Overview

Instance methods for instrumenting Sequel::Database

Instance Method Summary collapse

Instance Method Details

#run(sql, options = ::Sequel::OPTS) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/datadog/tracing/contrib/sequel/database.rb', line 18

def run(sql, options = ::Sequel::OPTS)
  opts = parse_opts(sql, options)

  response = nil

  Tracing.trace(Ext::SPAN_QUERY) do |span|
    span.service =  Datadog.configuration_for(self, :service_name) \
                    || Datadog.configuration.tracing[:sequel][:service_name] \
                    || Contrib::SpanAttributeSchema.fetch_service_name(
                      '',
                      adapter_name
                    )
    span.resource = opts[:query]
    span.span_type = Tracing::Metadata::Ext::SQL::TYPE
    Utils.set_common_tags(span, self)
    span.set_tag(Ext::TAG_DB_VENDOR, adapter_name)
    response = super(sql, options)
  end
  response
end