Commit f2051701 authored by Krasimir Angelov's avatar Krasimir Angelov

Merge branch...

Merge branch '235798-add-telemetry-tracking-for-users-associating-group-milestones-to-releases-2' into 'master'

Add Telemetry Tracking for Users Associating Milestones to Releases

See merge request gitlab-org/gitlab!71287
parents ed4ed51a bf999ff0
......@@ -33,6 +33,7 @@ class Release < ApplicationRecord
includes(:author, :evidences, :milestones, :links, :sorted_links,
project: [:project_feature, :route, { namespace: :route }])
}
scope :with_milestones, -> { joins(:milestone_releases) }
scope :recent, -> { sorted.limit(MAX_NUMBER_TO_DISPLAY) }
scope :without_evidence, -> { left_joins(:evidences).where(::Releases::Evidence.arel_table[:id].eq(nil)) }
scope :released_within_2hrs, -> { where(released_at: Time.zone.now - 1.hour..Time.zone.now + 1.hour) }
......
---
key_path: usage_activity_by_stage_monthly.release.releases_with_milestones
description: Unique users creating releases with milestones associated
performance_indicator_type: [smau]
product_section: ops
product_stage: release
product_group: 'group::release'
product_category: Release Orchestration
value_type: number
status: active
milestone: "14.4"
introduced_by_url: 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71287'
time_frame: 28d
data_source: database
instrumentation_class: 'CountUsersAssociatingMilestonesToReleasesMetric'
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: usage_activity_by_stage.release.releases_with_milestones
description: Unique users creating releases with milestones associated
performance_indicator_type: []
product_section: ops
product_stage: release
product_group: 'group::release'
product_category: Release Orchestration
value_type: number
status: active
milestone: "14.4"
introduced_by_url: 'https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71287'
time_frame: 28d
data_source: database
instrumentation_class: 'CountUsersAssociatingMilestonesToReleasesMetric'
data_category: Optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
# frozen_string_literal: true
class AddReleasesAuthorIdIdCreatedAtIndex < Gitlab::Database::Migration[1.0]
disable_ddl_transaction!
INDEX_NAME = 'index_releases_on_author_id_id_created_at'
def up
add_concurrent_index :releases, [:author_id, :id, :created_at], name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :releases, INDEX_NAME
end
end
432dc1f1e0280a79e4a6af56c2f2cb40c99edbc09e254b82b7f48c7c9217372b
\ No newline at end of file
......@@ -26263,6 +26263,8 @@ CREATE UNIQUE INDEX index_release_links_on_release_id_and_url ON release_links U
CREATE INDEX index_releases_on_author_id ON releases USING btree (author_id);
CREATE INDEX index_releases_on_author_id_id_created_at ON releases USING btree (author_id, id, created_at);
CREATE INDEX index_releases_on_project_id_and_tag ON releases USING btree (project_id, tag);
CREATE INDEX index_releases_on_released_at ON releases USING btree (released_at);
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module Instrumentations
class CountUsersAssociatingMilestonesToReleasesMetric < DatabaseMetric
operation :distinct_count, column: :author_id
relation { Release.with_milestones }
start { Release.minimum(:author_id) }
finish { Release.maximum(:author_id) }
end
end
end
end
end
......@@ -647,7 +647,7 @@ module Gitlab
# Omitted because of encrypted properties: `projects_jira_cloud_active`, `projects_jira_server_active`
# rubocop: disable CodeReuse/ActiveRecord
def usage_activity_by_stage_plan(time_period)
time_frame = time_period.present? ? '28d' : 'none'
time_frame = metric_time_period(time_period)
{
issues: add_metric('CountUsersCreatingIssuesMetric', time_frame: time_frame),
notes: distinct_count(::Note.where(time_period), :author_id),
......@@ -665,11 +665,13 @@ module Gitlab
# Omitted because no user, creator or author associated: `environments`, `feature_flags`, `in_review_folder`, `pages_domains`
# rubocop: disable CodeReuse/ActiveRecord
def usage_activity_by_stage_release(time_period)
time_frame = metric_time_period(time_period)
{
deployments: distinct_count(::Deployment.where(time_period), :user_id),
failed_deployments: distinct_count(::Deployment.failed.where(time_period), :user_id),
releases: distinct_count(::Release.where(time_period), :author_id),
successful_deployments: distinct_count(::Deployment.success.where(time_period), :user_id)
successful_deployments: distinct_count(::Deployment.success.where(time_period), :user_id),
releases_with_milestones: add_metric('CountUsersAssociatingMilestonesToReleasesMetric', time_frame: time_frame)
}
end
# rubocop: enable CodeReuse/ActiveRecord
......@@ -755,6 +757,10 @@ module Gitlab
private
def metric_time_period(time_period)
time_period.present? ? '28d' : 'none'
end
def gitaly_apdex
with_prometheus_client(verify: false, fallback: FALLBACK) do |client|
result = client.query('avg_over_time(gitlab_usage_ping:gitaly_apdex:ratio_avg_over_time_5m[1w])').first
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Usage::Metrics::Instrumentations::CountUsersAssociatingMilestonesToReleasesMetric do
let_it_be(:release) { create(:release, created_at: 3.days.ago) }
let_it_be(:release_with_milestone) { create(:release, :with_milestones, created_at: 3.days.ago) }
it_behaves_like 'a correct instrumented metric value', { time_frame: '28d', data_source: 'database' } do
let(:expected_value) { 1 }
end
end
......@@ -469,7 +469,8 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
for_defined_days_back do
user = create(:user)
create(:deployment, :failed, user: user)
create(:release, author: user)
release = create(:release, author: user)
create(:milestone, project: release.project, releases: [release])
create(:deployment, :success, user: user)
end
......@@ -477,13 +478,15 @@ RSpec.describe Gitlab::UsageData, :aggregate_failures do
deployments: 2,
failed_deployments: 2,
releases: 2,
successful_deployments: 2
successful_deployments: 2,
releases_with_milestones: 2
)
expect(described_class.usage_activity_by_stage_release(described_class.monthly_time_range_db_params)).to include(
deployments: 1,
failed_deployments: 1,
releases: 1,
successful_deployments: 1
successful_deployments: 1,
releases_with_milestones: 1
)
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