Module: ROM::Plugins::Relation::SQL::Instrumentation
- Defined in:
- lib/rom/plugins/relation/sql/instrumentation.rb
Overview
Instrumentation for relations and commands
This plugin allows configuring a notification system, that will be used to instrument interactions with databases, it's based on an abstract API so it should work with any instrumentation object that provides `instrument(identifier, payload)` method.
By default, instrumentation is triggered with following arguments:
- `identifier` is set to `:sql`
- `payload` is set to a hash with following keys:
- `:name` database type, ie `:sqlite`, `:postgresql` etc.
- `:query` a string with an SQL statement that was executed
Defined Under Namespace
Classes: Instrumenter
Class Method Summary collapse
- .apply(target, notifications:) ⇒ Object
-
.included(klass) ⇒ Object
private
Add `:notifications` option to a relation.
Class Method Details
.apply(target, notifications:) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rom/plugins/relation/sql/instrumentation.rb', line 33 def self.apply(target, notifications:, **) db = registry.gateways[target.config.component.gateway].connection return if db.respond_to?(:rom_instrumentation?) db.extend(Instrumenter.new(db.database_type, notifications)) end |
.included(klass) ⇒ 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.
Add `:notifications` option to a relation
83 84 85 86 |
# File 'lib/rom/plugins/relation/sql/instrumentation.rb', line 83 def self.included(klass) super klass.option :notifications end |