diff options
Diffstat (limited to 'lib/gitlab/usage/metrics')
9 files changed, 27 insertions, 33 deletions
diff --git a/lib/gitlab/usage/metrics/instrumentations/batched_background_migration_failed_jobs_metric.rb b/lib/gitlab/usage/metrics/instrumentations/batched_background_migration_failed_jobs_metric.rb index f5d963cf522..807e0ee071a 100644 --- a/lib/gitlab/usage/metrics/instrumentations/batched_background_migration_failed_jobs_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/batched_background_migration_failed_jobs_metric.rb @@ -27,6 +27,10 @@ module Gitlab } end end + + def to_sql + relation.unscope(:order).to_sql + end end end end diff --git a/lib/gitlab/usage/metrics/instrumentations/count_connected_agents_metric.rb b/lib/gitlab/usage/metrics/instrumentations/count_connected_agents_metric.rb new file mode 100644 index 00000000000..dea3f73c008 --- /dev/null +++ b/lib/gitlab/usage/metrics/instrumentations/count_connected_agents_metric.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Gitlab + module Usage + module Metrics + module Instrumentations + class CountConnectedAgentsMetric < DatabaseMetric + operation :count + + relation do + Clusters::AgentToken.connected + end + end + end + end + end +end diff --git a/lib/gitlab/usage/metrics/instrumentations/count_imported_projects_total_metric.rb b/lib/gitlab/usage/metrics/instrumentations/count_imported_projects_total_metric.rb index 109d2245635..4430c7453e6 100644 --- a/lib/gitlab/usage/metrics/instrumentations/count_imported_projects_total_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/count_imported_projects_total_metric.rb @@ -10,8 +10,8 @@ module Gitlab relation { Project } operation :count - IMPORT_TYPES = %w(gitlab_project gitlab github bitbucket bitbucket_server gitea git manifest - gitlab_migration).freeze + IMPORT_TYPES = %w[gitlab_project gitlab github bitbucket bitbucket_server gitea git manifest + gitlab_migration].freeze def value count(project_relation) + count(entity_relation) diff --git a/lib/gitlab/usage/metrics/instrumentations/count_issues_created_manually_from_alerts_metric.rb b/lib/gitlab/usage/metrics/instrumentations/count_issues_created_manually_from_alerts_metric.rb index e6093691f48..745d147ac88 100644 --- a/lib/gitlab/usage/metrics/instrumentations/count_issues_created_manually_from_alerts_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/count_issues_created_manually_from_alerts_metric.rb @@ -13,7 +13,7 @@ module Gitlab cache_start_and_finish_as :issue relation do - Issue.with_alert_management_alerts.not_authored_by(::User.alert_bot) + Issue.with_alert_management_alerts.not_authored_by(::Users::Internal.alert_bot) end def value diff --git a/lib/gitlab/usage/metrics/instrumentations/database_metric.rb b/lib/gitlab/usage/metrics/instrumentations/database_metric.rb index 2af7c208fce..7133c815e10 100644 --- a/lib/gitlab/usage/metrics/instrumentations/database_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/database_metric.rb @@ -18,7 +18,7 @@ module Gitlab UnimplementedOperationError = Class.new(StandardError) # rubocop:disable UsageData/InstrumentationSuperclass class << self - IMPLEMENTED_OPERATIONS = %i(count distinct_count estimate_batch_distinct_count sum average).freeze + IMPLEMENTED_OPERATIONS = %i[count distinct_count estimate_batch_distinct_count sum average].freeze private_constant :IMPLEMENTED_OPERATIONS diff --git a/lib/gitlab/usage/metrics/instrumentations/issues_created_from_alerts_metric.rb b/lib/gitlab/usage/metrics/instrumentations/issues_created_from_alerts_metric.rb index e430bc8eb71..d88128216d6 100644 --- a/lib/gitlab/usage/metrics/instrumentations/issues_created_from_alerts_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/issues_created_from_alerts_metric.rb @@ -7,8 +7,7 @@ module Gitlab class IssuesCreatedFromAlertsMetric < NumbersMetric ISSUES_FROM_ALERTS_METRICS = [ IssuesWithAlertManagementAlertsMetric, - IssuesWithPrometheusAlertEvents, - IssuesWithSelfManagedPrometheusAlertEvents + IssuesWithPrometheusAlertEvents ].freeze operation :add diff --git a/lib/gitlab/usage/metrics/instrumentations/issues_with_self_managed_prometheus_alert_events.rb b/lib/gitlab/usage/metrics/instrumentations/issues_with_self_managed_prometheus_alert_events.rb deleted file mode 100644 index fdbaa65bc68..00000000000 --- a/lib/gitlab/usage/metrics/instrumentations/issues_with_self_managed_prometheus_alert_events.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Usage - module Metrics - module Instrumentations - class IssuesWithSelfManagedPrometheusAlertEvents < DatabaseMetric - # this metric is used in IssuesCreatedFromAlertsMetric - # do not report metric directly in service ping - available? { false } - - operation :count - - start { Issue.minimum(:id) } - finish { Issue.maximum(:id) } - - relation { Issue.with_self_managed_prometheus_alert_events } - - cache_start_and_finish_as :issue - end - end - end - end -end diff --git a/lib/gitlab/usage/metrics/instrumentations/numbers_metric.rb b/lib/gitlab/usage/metrics/instrumentations/numbers_metric.rb index 67fcd226a0a..f168837bd50 100644 --- a/lib/gitlab/usage/metrics/instrumentations/numbers_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/numbers_metric.rb @@ -21,7 +21,7 @@ module Gitlab UnimplementedOperationError = Class.new(StandardError) # rubocop:disable UsageData/InstrumentationSuperclass class << self - IMPLEMENTED_OPERATIONS = %i(add).freeze + IMPLEMENTED_OPERATIONS = %i[add].freeze private_constant :IMPLEMENTED_OPERATIONS diff --git a/lib/gitlab/usage/metrics/instrumentations/redis_metric.rb b/lib/gitlab/usage/metrics/instrumentations/redis_metric.rb index ca5e5b706c4..217fa6aca49 100644 --- a/lib/gitlab/usage/metrics/instrumentations/redis_metric.rb +++ b/lib/gitlab/usage/metrics/instrumentations/redis_metric.rb @@ -48,8 +48,6 @@ module Gitlab end end - private - def redis_key key = metric_event.dup key.prepend("#{prefix}_") if prefix |