Commit dd2cf5cf authored by Amy Qualls's avatar Amy Qualls

Merge branch 'sy-status-page-usage-ping' into 'master'

Update usage ping to reflect usage of status page publishing/unpublishing

See merge request gitlab-org/gitlab!33790
parents e75abeb5 64e1dce1
......@@ -562,6 +562,8 @@ appear to be associated to any of the services running, since they all appear to
| `sast_jobs` | `counts` | | | |
| `status_page_projects` | `counts` | `monitor` | | Projects with status page enabled |
| `status_page_issues` | `counts` | `monitor` | | Issues published to a Status Page |
| `status_page_incident_publishes` | `counts` | `monitor` | | Cumulative count of usages of publish operation |
| `status_page_incident_unpublishes` | `counts` | `monitor` | | Cumulative count of usages of unpublish operation |
| `epics_deepest_relationship_level` | `counts` | | | |
| `operations_dashboard_default_dashboard` | `counts` | `monitor` | | Active users with enabled operations dashboard |
| `operations_dashboard_users_with_projects_added` | `counts` | `monitor` | | Active users with projects on operations dashboard|
......
......@@ -26,7 +26,12 @@ module EE
issue_ids = EpicIssue.where(epic_id: epics).select(:issue_id)
id_in(issue_ids)
end
scope :on_status_page, -> { joins(:status_page_published_incident).public_only }
scope :on_status_page, -> do
joins(project: :status_page_setting)
.where(status_page_settings: { enabled: true })
.joins(:status_page_published_incident)
.public_only
end
scope :counts_by_health_status, -> { reorder(nil).group(:health_status).count }
scope :with_health_status, -> { where.not(health_status: nil) }
......
......@@ -44,6 +44,8 @@ module StatusPage
end
def track_incident
::StatusPage::UsageDataCounters::IncidentCounter.count(:publishes)
PublishedIncident.track(issue)
end
......
......@@ -14,6 +14,7 @@ module StatusPage
def process(issue)
PublishedIncident.untrack(issue)
::StatusPage::UsageDataCounters::IncidentCounter.count(:unpublishes)
# Delete the incident prior to deleting images to avoid broken links
json_key = json_object_key(issue)
......
---
title: Add new status page attributes to usage ping
merge_request: 33790
author:
type: other
......@@ -34,7 +34,11 @@ module EE
override :usage_data_counters
def usage_data_counters
super + [::Gitlab::UsageDataCounters::LicensesList, ::Gitlab::UsageDataCounters::IngressModsecurityCounter]
super + [
::Gitlab::UsageDataCounters::LicensesList,
::Gitlab::UsageDataCounters::IngressModsecurityCounter,
StatusPage::UsageDataCounters::IncidentCounter
]
end
override :uncached_data
......
# frozen_string_literal: true
module StatusPage
module UsageDataCounters
class IncidentCounter < ::Gitlab::UsageDataCounters::BaseCounter
KNOWN_EVENTS = %w[publishes unpublishes].freeze
PREFIX = 'status_page_incident'
end
end
end
......@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe StatusPage::IncidentsFinder do
let_it_be(:project) { create(:project) }
let_it_be(:status_page_setting) { create(:status_page_setting, :enabled, project: project)}
let_it_be(:issues) do
{
......
......@@ -55,6 +55,7 @@ RSpec.describe Gitlab::UsageData do
# 1 published issue on 1 projects with status page enabled
create(:issue, project: projects[0])
create(:issue, :published, project: projects[0])
create(:issue, :published, project: projects[1])
end
subject { described_class.data }
......@@ -111,8 +112,10 @@ RSpec.describe Gitlab::UsageData do
projects_with_tracing_enabled
sast_jobs
secret_detection_jobs
status_page_projects
status_page_incident_publishes
status_page_incident_unpublishes
status_page_issues
status_page_projects
user_preferences_group_overview_details
user_preferences_group_overview_security_dashboard
template_repositories
......
# frozen_string_literal: true
require 'spec_helper'
describe StatusPage::UsageDataCounters::IncidentCounter do
it_behaves_like 'a redis usage counter', 'StatusPage::IncidentCounter', :publishes
it_behaves_like 'a redis usage counter', 'StatusPage::IncidentCounter', :unpublishes
it_behaves_like 'a redis usage counter with totals', :status_page_incident, publishes: 7, unpublishes: 2
end
......@@ -98,6 +98,14 @@ RSpec.describe Issue do
it { expect(Issue.on_status_page.count).to eq(1) }
it { expect(Issue.on_status_page.first).to eq(published_issue) }
context 'with status page disabled' do
before do
status_page_setting.update!(enabled: false)
end
it { expect(Issue.on_status_page.count).to eq(0) }
end
end
context 'epics' do
......
......@@ -54,6 +54,12 @@ RSpec.describe StatusPage::MarkForPublicationService do
specify { expect { subject }.to change { ::StatusPage::PublishedIncident.count }.by(1) }
specify { expect { subject }.to change { issue.notes.count }.by(1) }
specify { expect(subject).to be_success }
it 'increments the publish counter' do
expect(StatusPage::UsageDataCounters::IncidentCounter).to receive(:count).with(:publishes).once
subject
end
end
context 'when issue is confidential' do
......
......@@ -53,6 +53,7 @@ RSpec.describe StatusPage::UnpublishDetailsService do
it 'untracks the issue' do
expect(StatusPage::PublishedIncident).to receive(:untrack).with(issue)
expect(StatusPage::UsageDataCounters::IncidentCounter).to receive(:count).with(:unpublishes).once
result
end
......
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