Module: Datadog::Contrib::Sequel::Utils
- Defined in:
- lib/ddtrace/contrib/sequel/utils.rb
Overview
General purpose functions for Sequel
Class Method Summary collapse
- .adapter_name(database) ⇒ Object
- .parse_opts(sql, opts, db_opts) ⇒ Object
- .set_analytics_sample_rate(span) ⇒ Object
Class Method Details
.adapter_name(database) ⇒ Object
7 8 9 |
# File 'lib/ddtrace/contrib/sequel/utils.rb', line 7 def adapter_name(database) Datadog::Utils::Database.normalize_vendor(database.adapter_scheme.to_s) end |
.parse_opts(sql, opts, db_opts) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ddtrace/contrib/sequel/utils.rb', line 11 def parse_opts(sql, opts, db_opts) if ::Sequel::VERSION >= '4.37.0' && !sql.is_a?(String) # In 4.37.0, sql was converted to a prepared statement object sql = sql.prepared_sql unless sql.is_a?(Symbol) end { name: opts[:type], query: sql, database: db_opts[:database], host: db_opts[:host] } end |
.set_analytics_sample_rate(span) ⇒ Object
25 26 27 |
# File 'lib/ddtrace/contrib/sequel/utils.rb', line 25 def set_analytics_sample_rate(span) Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled? end |