Class: ActiveRecord::OpenTracing::Processor
- Inherits:
-
Object
- Object
- ActiveRecord::OpenTracing::Processor
- Defined in:
- lib/active_record/opentracing/processor.rb
Constant Summary collapse
- DEFAULT_OPERATION_NAME =
'sql.query'- COMPONENT_NAME =
'ActiveRecord'- SPAN_KIND =
'client'- DB_TYPE =
'sql'
Instance Method Summary collapse
- #call(_event_name, start, finish, _id, payload) ⇒ Object
-
#initialize(tracer) ⇒ Processor
constructor
A new instance of Processor.
Constructor Details
#initialize(tracer) ⇒ Processor
Returns a new instance of Processor.
11 12 13 |
# File 'lib/active_record/opentracing/processor.rb', line 11 def initialize(tracer) @tracer = tracer end |
Instance Method Details
#call(_event_name, start, finish, _id, payload) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/active_record/opentracing/processor.rb', line 15 def call(_event_name, start, finish, _id, payload) span = @tracer.start_span( payload[:name] || DEFAULT_OPERATION_NAME, start_time: start, tags: { 'component' => COMPONENT_NAME, 'span.kind' => SPAN_KIND, 'db.instance' => db_instance, 'db.cached' => payload.fetch(:cached, false), 'db.statement' => payload.fetch(:sql).squish, 'db.type' => DB_TYPE, 'peer.address' => db_address } ) if (exception = payload[:exception_object]) span.record_exception(exception) end span.finish(end_time: finish) end |