Add database event tracking for new models
What does this MR do and why?
Related to #390827 (closed)
We want to add db event tracking to two new models. So far we only had it in one model (analytics stage), so I also redesigned test cases into a shared example group.
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
- Enable snowplow micro
- Enable the previous feature flag:
Feature.enable(:product_intelligence_database_event_tracking)
- Enable the new feature flag:
Feature.enable(:product_intelligence_database_event_tracking_batch2)
- Trigger the new events:
- Create/update a merge request
- Create/change status of a vulnerability [project menu -> Security and Compliance -> Vulnerability report]
- Check if a new event with
database_event_create
/database_event_update
action and model class category has been registered atlocalhost:9091/micro/good
DB queries:
Before: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/17377/commands/58240
INSERT INTO merge_request_metrics (merge_request_id, target_project_id, updated_at, created_at)
VALUES (146, 31, NOW(), NOW())
ON CONFLICT (merge_request_id)
DO UPDATE SET
target_project_id = EXCLUDED.target_project_id,
updated_at = NOW()
After: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/17377/commands/58241
INSERT INTO merge_request_metrics (merge_request_id, target_project_id, updated_at, created_at)
VALUES (146, 31, NOW(), NOW())
ON CONFLICT (merge_request_id)
DO UPDATE SET
target_project_id = EXCLUDED.target_project_id,
updated_at = NOW()
RETURNING id, merge_request_id, target_project_id, updated_at, created_at
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Michał Wielich