Commit dadae068 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'am-add-usage-data-count-issues-instrumetation' into 'master'

Add issues metric instrumentation

See merge request gitlab-org/gitlab!60014
parents da05f79b 10ab24bd
---
key_path: usage_activity_by_stage_monthly.plan.issues
description: Count of MAU creating issues
description: Count of users creating Issues in last 28 days.
product_section: dev
product_stage: plan
product_stage: plan
product_group: group::project management
product_category: issue_tracking
product_category: issue_tracking
value_type: number
status: data_available
time_frame: 28d
data_source: database
instrumentation_class: 'Gitlab::Usage::Metrics::Instrumentations::CountUsersCreatingIssuesMetric'
distribution:
- ce
- ee
- ee
tier:
- free
- premium
- premium
- ultimate
......@@ -9,6 +9,7 @@ value_type: number
status: data_available
time_frame: all
data_source: database
instrumentation_class: 'Gitlab::Usage::Metrics::Instrumentations::CountIssuesMetric'
distribution:
- ce
- ee
......
......@@ -9,6 +9,7 @@ value_type: number
status: data_available
time_frame: all
data_source: database
instrumentation_class: 'Gitlab::Usage::Metrics::Instrumentations::CountUsersCreatingIssuesMetric'
distribution:
- ce
- ee
......
......@@ -18256,7 +18256,7 @@ Tiers: `free`
### `usage_activity_by_stage_monthly.plan.issues`
Count of MAU creating issues
Count of users creating Issues in last 28 days.
[YAML definition](https://gitlab.com/gitlab-org/gitlab/-/blob/master/config/metrics/counts_28d/20210216181139_issues.yml)
......
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class CountIssuesMetric < DatabaseMetric
operation :count
start { Issue.minimum(:id) }
finish { Issue.maximum(:id) }
relation { Issue }
end
end
end
end
end
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class CountUsersCreatingIssuesMetric < DatabaseMetric
operation :distinct_count, column: :author_id
relation { Issue }
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::CountIssuesMetric do
let_it_be(:issue) { create(:issue) }
it_behaves_like 'a correct instrumented metric value', { time_frame: 'all', data_source: 'database' }, 1
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::CountUsersCreatingIssuesMetric do
let_it_be(:author) { create(:user) }
let_it_be(:issues) { create_list(:issue, 2, author: author, created_at: 4.days.ago) }
let_it_be(:old_issue) { create(:issue, author: author, created_at: 2.months.ago) }
context 'with all time frame' do
it_behaves_like 'a correct instrumented metric value', { time_frame: 'all', data_source: 'database' }, 1
end
context 'for 28d time frame' do
it_behaves_like 'a correct instrumented metric value', { time_frame: '28d', data_source: 'database' }, 1
end
end
......@@ -30,6 +30,18 @@ RSpec.describe Gitlab::UsageDataMetrics do
expect(subject[:redis_hll_counters][:quickactions]).to include(:i_quickactions_approve_monthly)
expect(subject[:redis_hll_counters][:quickactions]).to include(:i_quickactions_approve_weekly)
end
it 'includes counts keys' do
expect(subject[:counts]).to include(:issues)
end
it 'includes usage_activity_by_stage keys' do
expect(subject[:usage_activity_by_stage][:plan]).to include(:issues)
end
it 'includes usage_activity_by_stage_monthly keys' do
expect(subject[:usage_activity_by_stage_monthly][:plan]).to include(:issues)
end
end
end
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