Module: Datadog::Contrib::Rails::Utils
- Defined in:
- lib/ddtrace/contrib/rails/utils.rb
Overview
common utilities for Rails
Class Method Summary collapse
-
.normalize_template_name(name) ⇒ Object
in Rails the template name includes the template full path and it’s better to avoid storing such information.
-
.normalize_vendor(vendor) ⇒ Object
TODO: Consider moving this out of Rails.
Class Method Details
.normalize_template_name(name) ⇒ Object
in Rails the template name includes the template full path and it’s better to avoid storing such information. This method returns the relative path from ‘views/` or the template name if a `views/` folder is not in the template full path. A wrong usage ensures that this method will not crash the tracing system.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ddtrace/contrib/rails/utils.rb', line 11 def self.normalize_template_name(name) return if name.nil? base_path = ::Rails.configuration.datadog_trace.fetch(:template_base_path, 'views/') sections_view = name.split(base_path) if sections_view.length == 1 name.split('/')[-1] else sections_view[-1] end rescue return name.to_s end |
.normalize_vendor(vendor) ⇒ Object
TODO: Consider moving this out of Rails. Return a canonical name for a type of database
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ddtrace/contrib/rails/utils.rb', line 28 def self.normalize_vendor(vendor) case vendor when nil 'defaultdb' when 'sqlite3' 'sqlite' when 'postgresql' 'postgres' else vendor end end |