Skip to content

Add new destination for gitlab tracking

What does this MR do and why?

Data team needs to record changes happening to some of the tables from PostgreSQL database. After running research decision was made to use parallel Snowplow collection pipeline as preferred solution. This MR lays foundation for that change on the application level adding new parallel tracking method dedicated for described process.

It solves #390805 (closed)

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

How to set up and validate locally

  1. Make sure that you have Snowplow micro collector enabled for gdk https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/snowplow_micro.md
  2. Adjust code from the branch to report via http protocol to correct port
    diff --git a/lib/gitlab/tracking/destinations/database_events_snowplow.rb b/lib/gitlab/tracking/destinations/database_events_snowplow.rb
index befdfea197d3..5c84c0793f09 100644
--- a/lib/gitlab/tracking/destinations/database_events_snowplow.rb
+++ b/lib/gitlab/tracking/destinations/database_events_snowplow.rb
@@ -16,7 +16,10 @@ def options(_)
             app_id: app_id,
             form_tracking: false,
             link_click_tracking: false,
-            hostname: hostname
+            hostname: hostname,
+            protocol: 'http',
+            port: 9091,
+            force_secure_tracker: false
           }.transform_keys! { |key| key.to_s.camelize(:lower).to_sym }
         end

@@ -31,6 +34,16 @@ def hostname
           HOSTNAME
         end

+        override :port
+        def port
+          9091
+        end
+
+        override :protocol
+        def protocol
+          'http'
+        end
+
         private
  1. In rails console
[1] pry(main)> Feature.enable(:product_intelligence_database_event_tracking)
[2] pry(main)> class Issue < ApplicationRecord
  include DatabaseEventTracking
  SNOWPLOW_ATTRIBUTES = %i[id title]
end
[3] pry(main)> Issue.first.update(created_at: Time.current)
  1. Check new events at http://localhost:9091/micro/good

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Niko Belokolodov

Merge request reports