Commit 24c9ac0e authored by Dylan Griffith's avatar Dylan Griffith

Merge branch 'mattkasa/207510-terraform-state-usage-ping' into 'master'

Add terraform state metrics to usage data

Closes #207510

See merge request gitlab-org/gitlab!31280
parents d1b31894 a08a8f55
......@@ -2,6 +2,8 @@
module Terraform
class State < ApplicationRecord
include UsageStatistics
DEFAULT = '{"version":1}'.freeze
HEX_REGEXP = %r{\A\h+\z}.freeze
UUID_LENGTH = 32
......
---
title: Add usage data metrics for terraform states
merge_request: 31280
author:
type: added
......@@ -132,12 +132,14 @@ module Gitlab
projects_with_alerts_service_enabled: count(AlertsService.active),
projects_with_prometheus_alerts: distinct_count(PrometheusAlert, :project_id),
projects_with_terraform_reports: distinct_count(::Ci::JobArtifact.terraform_reports, :project_id),
projects_with_terraform_states: distinct_count(::Terraform::State, :project_id),
protected_branches: count(ProtectedBranch),
releases: count(Release),
remote_mirrors: count(RemoteMirror),
snippets: count(Snippet),
suggestions: count(Suggestion),
terraform_reports: count(::Ci::JobArtifact.terraform_reports),
terraform_states: count(::Terraform::State),
todos: count(Todo),
uploads: count(Upload),
web_hooks: count(WebHook),
......
......@@ -36,6 +36,9 @@ FactoryBot.define do
create(:merge_request, :simple, :with_terraform_reports, source_project: projects[0])
create(:merge_request, :rebased, :with_terraform_reports, source_project: projects[0])
create(:merge_request, :simple, :with_terraform_reports, source_project: projects[1])
create(:terraform_state, project: projects[0])
create(:terraform_state, project: projects[0])
create(:terraform_state, project: projects[1])
create(:zoom_meeting, project: projects[0], issue: projects[0].issues[0], issue_status: :added)
create_list(:zoom_meeting, 2, project: projects[0], issue: projects[0].issues[1], issue_status: :removed)
create(:zoom_meeting, project: projects[0], issue: projects[0].issues[2], issue_status: :added)
......
......@@ -58,7 +58,9 @@ describe Gitlab::UsageData, :aggregate_failures do
expect(count_data[:projects_with_alerts_service_enabled]).to eq(1)
expect(count_data[:projects_with_prometheus_alerts]).to eq(2)
expect(count_data[:projects_with_terraform_reports]).to eq(2)
expect(count_data[:projects_with_terraform_states]).to eq(2)
expect(count_data[:terraform_reports]).to eq(3)
expect(count_data[:terraform_states]).to eq(3)
expect(count_data[:issues_created_from_gitlab_error_tracking_ui]).to eq(1)
expect(count_data[:issues_with_associated_zoom_link]).to eq(2)
expect(count_data[:issues_using_zoom_quick_actions]).to eq(3)
......
......@@ -118,6 +118,7 @@ module UsageDataHelpers
projects_with_expiration_policy_enabled_with_cadence_set_to_1month
projects_with_expiration_policy_enabled_with_cadence_set_to_3month
projects_with_terraform_reports
projects_with_terraform_states
pages_domains
protected_branches
releases
......@@ -125,6 +126,7 @@ module UsageDataHelpers
snippets
suggestions
terraform_reports
terraform_states
todos
uploads
web_hooks
......
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