Class: Labkit::Tracing::Rails::ActiveRecord::SqlInstrumenter Private
- Inherits:
-
AbstractInstrumenter
- Object
- AbstractInstrumenter
- Labkit::Tracing::Rails::ActiveRecord::SqlInstrumenter
- Defined in:
- lib/labkit/tracing/rails/active_record/sql_instrumenter.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
For more information on the payloads: guides.rubyonrails.org/active_support_instrumentation.html
Constant Summary collapse
- OPERATION_NAME_PREFIX =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"active_record:"- DEFAULT_OPERATION_NAME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"sqlquery"
Instance Method Summary collapse
- #span_name(payload) ⇒ Object private
- #tags(payload) ⇒ Object private
Methods inherited from AbstractInstrumenter
Instance Method Details
#span_name(payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 |
# File 'lib/labkit/tracing/rails/active_record/sql_instrumenter.rb', line 12 def span_name(payload) OPERATION_NAME_PREFIX + (payload[:name].presence || DEFAULT_OPERATION_NAME) end |
#tags(payload) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/labkit/tracing/rails/active_record/sql_instrumenter.rb', line 16 def (payload) if Labkit::Tracing.sampled? && payload[:sql] sql = Labkit::Logging::Sanitizer.sanitize_sql(payload[:sql]) fingerprint = Labkit::Logging::Sanitizer.sql_fingerprint(sql) end = { "component" => COMPONENT_TAG, "span.kind" => "client", "db.type" => "sql", "db.cached" => payload[:cached] || false, } # OpenTelemetry rejects nil attributes, so only add statement fields # when ActiveRecord supplies SQL (schema events may omit it). ["db.statement"] = sql if sql ["db.statement_fingerprint"] = fingerprint if fingerprint ["db.connection_id"] = payload[:connection_id] if payload[:connection_id] end |