Commit 10ab24bd authored by alinamihaila's avatar alinamihaila

Add issues metric instrumentation

  - Add CountIssuesMetric
  - Add CountUsersCreatingIssuesMetric
parent cfdd2aca
---
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_group: group::project management
......@@ -9,6 +9,7 @@ value_type: number
status: data_available
time_frame: 28d
data_source: database
instrumentation_class: 'Gitlab::Usage::Metrics::Instrumentations::CountUsersCreatingIssuesMetric'
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::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
......@@ -20,6 +20,18 @@ RSpec.describe Gitlab::UsageDataMetrics do
it 'includes top level keys' do
expect(subject).to include(:uuid)
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