Commit 9c4c93ae authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch 'sy-on-call-usage-ping' into 'master'

Add new metric definition for on-call notifications [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!58606
parents e4757344 c77c0e91
---
title: Add count of unique users to receive on-call notification to usage ping
merge_request: 58606
author:
type: changed
---
name: usage_data_i_incident_management_oncall_notification_sent
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58606
rollout_issue_url:
milestone: '13.11'
type: development
group: group::monitor
default_enabled: true
...@@ -10412,6 +10412,30 @@ Status: `data_available` ...@@ -10412,6 +10412,30 @@ Status: `data_available`
Tiers: Tiers:
### `redis_hll_counters.incident_management.i_incident_management_oncall_notification_sent_monthly`
Count of unique users to receive a notification while on-call
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_28d/20210405222005_i_incident_management_oncall_notification_sent_monthly.yml)
Group: `group::monitor`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.incident_management.i_incident_management_oncall_notification_sent_weekly`
Count of unique users to receive a notification while on-call
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/config/metrics/counts_7d/20210405220139_i_incident_management_oncall_notification_sent_weekly.yml)
Group: `group::monitor`
Status: `implemented`
Tiers: `premium`, `ultimate`
### `redis_hll_counters.incident_management.incident_management_alert_assigned_monthly` ### `redis_hll_counters.incident_management.incident_management_alert_assigned_monthly`
Missing description Missing description
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module EE module EE
module NotificationService module NotificationService
include ::Gitlab::Utils::UsageData
# When we add approvers to a merge request we should send an email to: # When we add approvers to a merge request we should send an email to:
# #
# * the new approvers # * the new approvers
...@@ -67,6 +69,8 @@ module EE ...@@ -67,6 +69,8 @@ module EE
end end
def notify_oncall_users_of_alert(users, alert) def notify_oncall_users_of_alert(users, alert)
track_usage_event(:i_incident_management_oncall_notification_sent, users.map(&:id))
users.each do |user| users.each do |user|
mailer.prometheus_alert_fired_email(alert.project, user, alert).deliver_later mailer.prometheus_alert_fired_email(alert.project, user, alert).deliver_later
end end
......
---
key_path: redis_hll_counters.incident_management.i_incident_management_oncall_notification_sent_monthly
description: Count of unique users to receive a notification while on-call
product_section: ops
product_stage: monitor
product_group: group::monitor
product_category: incident_management
value_type: number
status: implemented
milestone: "13.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58606
time_frame: 28d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
---
key_path: redis_hll_counters.incident_management.i_incident_management_oncall_notification_sent_weekly
description: Count of unique users to receive a notification while on-call
product_section: ops
product_stage: monitor
product_group: group::monitor
product_category: incident_management
value_type: number
status: implemented
milestone: "13.11"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/58606
time_frame: 7d
data_source: redis_hll
distribution:
- ee
tier:
- premium
- ultimate
...@@ -899,12 +899,25 @@ RSpec.describe EE::NotificationService, :mailer do ...@@ -899,12 +899,25 @@ RSpec.describe EE::NotificationService, :mailer do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:alert) { create(:alert_management_alert) } let_it_be(:alert) { create(:alert_management_alert) }
let_it_be(:project) { alert.project } let_it_be(:project) { alert.project }
let(:tracking_params) do
{
event_names: 'i_incident_management_oncall_notification_sent',
start_date: 1.week.ago,
end_date: 1.week.from_now
}
end
it 'sends an email to the specified users' do it 'sends an email to the specified users' do
expect(Notify).to receive(:prometheus_alert_fired_email).with(project, user, alert).and_call_original expect(Notify).to receive(:prometheus_alert_fired_email).with(project, user, alert).and_call_original
subject.notify_oncall_users_of_alert([user], alert) subject.notify_oncall_users_of_alert([user], alert)
end end
it 'tracks a count of unique recipients', :clean_gitlab_redis_shared_state do
expect { subject.notify_oncall_users_of_alert([user], alert) }
.to change { Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(**tracking_params) }
.by 1
end
end end
end end
end end
...@@ -247,6 +247,12 @@ ...@@ -247,6 +247,12 @@
category: incident_management_alerts category: incident_management_alerts
aggregation: weekly aggregation: weekly
feature_flag: usage_data_incident_management_alert_create_incident feature_flag: usage_data_incident_management_alert_create_incident
# Incident management on-call
- name: i_incident_management_oncall_notification_sent
redis_slot: incident_management
category: incident_management_oncall
aggregation: weekly
feature_flag: usage_data_i_incident_management_oncall_notification_sent
# Testing category # Testing category
- name: i_testing_test_case_parsed - name: i_testing_test_case_parsed
category: testing category: testing
......
...@@ -34,6 +34,7 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s ...@@ -34,6 +34,7 @@ RSpec.describe Gitlab::UsageDataCounters::HLLRedisCounter, :clean_gitlab_redis_s
'source_code', 'source_code',
'incident_management', 'incident_management',
'incident_management_alerts', 'incident_management_alerts',
'incident_management_oncall',
'testing', 'testing',
'issues_edit', 'issues_edit',
'ci_secrets_management', 'ci_secrets_management',
......
...@@ -1362,7 +1362,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do ...@@ -1362,7 +1362,7 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
let(:categories) { ::Gitlab::UsageDataCounters::HLLRedisCounter.categories } let(:categories) { ::Gitlab::UsageDataCounters::HLLRedisCounter.categories }
let(:ineligible_total_categories) do let(:ineligible_total_categories) do
%w[source_code ci_secrets_management incident_management_alerts snippets terraform] %w[source_code ci_secrets_management incident_management_alerts snippets terraform incident_management_oncall]
end end
context 'with redis_hll_tracking feature enabled' do context 'with redis_hll_tracking feature enabled' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment