Sha256: caff75dbb3b4f0e5a6a00f0dd95589ada21da8837f2294bba66d2ce826174093
Contents?: true
Size: 1.99 KB
Versions: 9
Compression:
Stored size: 1.99 KB
Contents
require 'ddtrace/ext/sql' require 'ddtrace/ext/app_types' require 'ddtrace/contrib/analytics' require 'ddtrace/contrib/sequel/ext' require 'ddtrace/contrib/sequel/utils' module Datadog module Contrib module Sequel # Adds instrumentation to Sequel::Dataset module Dataset def self.included(base) base.send(:prepend, InstanceMethods) end # Instance methods for instrumenting Sequel::Dataset module InstanceMethods def execute(sql, options = ::Sequel::OPTS, &block) trace_execute(proc { super(sql, options, &block) }, sql, options, &block) end def execute_ddl(sql, options = ::Sequel::OPTS, &block) trace_execute(proc { super(sql, options, &block) }, sql, options, &block) end def execute_dui(sql, options = ::Sequel::OPTS, &block) trace_execute(proc { super(sql, options, &block) }, sql, options, &block) end def execute_insert(sql, options = ::Sequel::OPTS, &block) trace_execute(proc { super(sql, options, &block) }, sql, options, &block) end def datadog_pin Datadog::Pin.get_from(db) end private def trace_execute(super_method, sql, options, &block) opts = Utils.parse_opts(sql, options, db.opts, self) response = nil datadog_pin.tracer.trace(Ext::SPAN_QUERY) do |span| span.service = datadog_pin.service span.resource = opts[:query] span.span_type = Datadog::Ext::SQL::TYPE Utils.set_common_tags(span) span.set_tag(Ext::TAG_DB_VENDOR, adapter_name) span.set_tag(Ext::TAG_PREPARED_NAME, opts[:prepared_name]) if opts[:prepared_name] response = super_method.call(sql, options, &block) end response end def adapter_name Utils.adapter_name(db) end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems