Module: Sequel::Instrumentation
- Defined in:
- lib/sequel/instrumentation.rb,
lib/sequel/instrumentation/version.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- COMMON_TAGS =
{ 'component' => 'ruby-sequel', 'span.kind' => 'client', }.freeze
- VERSION =
'0.1.0'.freeze
Class Attribute Summary collapse
-
.tracer ⇒ Object
Returns the value of attribute tracer.
Class Method Summary collapse
- .instrument(tracer: OpenTracing.global_tracer) ⇒ Object
-
.trace_query(name, tags) ⇒ Object
This method sets up a span and yields the block.
Class Attribute Details
.tracer ⇒ Object
Returns the value of attribute tracer.
15 16 17 |
# File 'lib/sequel/instrumentation.rb', line 15 def tracer @tracer end |
Class Method Details
.instrument(tracer: OpenTracing.global_tracer) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sequel/instrumentation.rb', line 17 def instrument(tracer: OpenTracing.global_tracer) begin require 'sequel' rescue LoadError return end @tracer = tracer require 'sequel/extensions/database_instrumentation' require 'sequel/extensions/dataset_instrumentation' Sequel::Database.extension :database_instrumentation Sequel::Database.extension :dataset_instrumentation end |
.trace_query(name, tags) ⇒ Object
This method sets up a span and yields the block. Any errors will be caught and tagged before being passed up.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/sequel/instrumentation.rb', line 35 def trace_query(name, ) .merge!(COMMON_TAGS) scope = @tracer.start_active_span(name, tags: ) yield rescue StandardError => error if scope scope.span.set_tag('error', true) scope.span.log_kv(key: 'message', value: error.) end raise error ensure scope.close if scope end |