Module: DatabaseEventTracking
- Extended by:
- ActiveSupport::Concern
- Included in:
- Analytics::CycleAnalytics::Stage, MergeRequest::Metrics
- Defined in:
- app/models/concerns/database_event_tracking.rb
Instance Method Summary collapse
- #filtered_record_attributes ⇒ Object
- #publish_database_create_event ⇒ Object
- #publish_database_destroy_event ⇒ Object
- #publish_database_event(name) ⇒ Object
- #publish_database_update_event ⇒ Object
Instance Method Details
#filtered_record_attributes ⇒ Object
47 48 49 50 51 |
# File 'app/models/concerns/database_event_tracking.rb', line 47 def filtered_record_attributes attributes .with_indifferent_access .slice(*self.class::SNOWPLOW_ATTRIBUTES) end |
#publish_database_create_event ⇒ Object
12 13 14 |
# File 'app/models/concerns/database_event_tracking.rb', line 12 def publish_database_create_event publish_database_event('create') end |
#publish_database_destroy_event ⇒ Object
16 17 18 |
# File 'app/models/concerns/database_event_tracking.rb', line 16 def publish_database_destroy_event publish_database_event('destroy') end |
#publish_database_event(name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/concerns/database_event_tracking.rb', line 24 def publish_database_event(name) # Gitlab::Tracking#event is triggering Snowplow event # Snowplow events are sent with usage of # https://snowplow.github.io/snowplow-ruby-tracker/SnowplowTracker/AsyncEmitter.html # that reports data asynchronously and does not impact performance nor carries a risk of # rollback in case of error Gitlab::Tracking.database_event( self.class.to_s, "database_event_#{name}", label: self.class.table_name, project: try(:project), namespace: (try(:group) || try(:namespace)) || try(:project)&.namespace, property: name, **filtered_record_attributes ) rescue StandardError => err # this rescue should be a dead code due to utilization of AsyncEmitter, however # since this concern is expected to be included in every model, it is better to # prevent against any unexpected outcome Gitlab::ErrorTracking.track_and_raise_for_dev_exception(err) end |
#publish_database_update_event ⇒ Object
20 21 22 |
# File 'app/models/concerns/database_event_tracking.rb', line 20 def publish_database_update_event publish_database_event('update') end |