Skip to content

Fix Service Ping manage events monthly metric

What does this MR do and why?

Within !73670 (merged) metric usage_activity_by_stage_monthly.manage.events was modified to use dedicated start and finish queries that was able to utilize dedicated index. However for finish query order wasn't set properly resulting in wrong range being analyzed.

Finish query plan: https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/7145/commands/25316

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

While in rails console sessions:

# seed some data
User.take(4).each { |user| Event.create(author: user, action: "closed", target_type: "Issue", created_at: 3.days.ago, updated_at: 3.days.ago) }

# stub batch size in underlying counter
Gitlab::Database::PostgresHll::BatchDistinctCounter::MIN_REQUIRED_BATCH_SIZE = 0
Gitlab::Database::PostgresHll::BatchDistinctCounter::DEFAULT_BATCH_SIZE = 1

# get metric data, prior to fix it would return value close to 1
# after fix the value should be around 4 or more (if you had more pre existing data in your local db)
Gitlab::UsageData.send(:stage_manage_events, Gitlab::UsageData.monthly_time_range_db_params)

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 Mikołaj Wawrzyniak

Merge request reports