diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-14 21:09:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-11-14 21:09:21 +0300 |
commit | c3ccd2fdf136f7b3962ef5243ed6ce01de47d8ef (patch) | |
tree | 4d8b1df9d6b4bc09edcf8ae610e014b36a2d4269 /lib/gitlab | |
parent | 15c1cc886c5785d49f2a6dae064a1e8290f59f46 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/application_context.rb | 10 | ||||
-rw-r--r-- | lib/gitlab/usage/metrics/instrumentations/gitlab_config_metric.rb | 31 | ||||
-rw-r--r-- | lib/gitlab/usage_data.rb | 5 |
3 files changed, 39 insertions, 7 deletions
diff --git a/lib/gitlab/application_context.rb b/lib/gitlab/application_context.rb index 67fc2ae2fcc..e46bbc2cfda 100644 --- a/lib/gitlab/application_context.rb +++ b/lib/gitlab/application_context.rb @@ -26,7 +26,8 @@ module Gitlab :artifacts_dependencies_size, :artifacts_dependencies_count, :root_caller_id, - :merge_action_status + :merge_action_status, + :bulk_import_entity_id ].freeze private_constant :KNOWN_KEYS @@ -45,7 +46,8 @@ module Gitlab Attribute.new(:artifacts_dependencies_size, Integer), Attribute.new(:artifacts_dependencies_count, Integer), Attribute.new(:root_caller_id, String), - Attribute.new(:merge_action_status, String) + Attribute.new(:merge_action_status, String), + Attribute.new(:bulk_import_entity_id, Integer) ].freeze private_constant :APPLICATION_ATTRIBUTES @@ -95,6 +97,7 @@ module Gitlab # rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/PerceivedComplexity + # rubocop: disable Metrics/AbcSize def to_lazy_hash {}.tap do |hash| assign_hash_if_value(hash, :caller_id) @@ -106,6 +109,7 @@ module Gitlab assign_hash_if_value(hash, :artifacts_dependencies_size) assign_hash_if_value(hash, :artifacts_dependencies_count) assign_hash_if_value(hash, :merge_action_status) + assign_hash_if_value(hash, :bulk_import_entity_id) hash[:user] = -> { username } if include_user? hash[:user_id] = -> { user_id } if include_user? @@ -115,10 +119,12 @@ module Gitlab hash[:pipeline_id] = -> { job&.pipeline_id } if set_values.include?(:job) hash[:job_id] = -> { job&.id } if set_values.include?(:job) hash[:artifact_size] = -> { artifact&.size } if set_values.include?(:artifact) + hash[:bulk_import_entity_id] = -> { bulk_import_entity_id } if set_values.include?(:bulk_import_entity_id) end end # rubocop: enable Metrics/CyclomaticComplexity # rubocop: enable Metrics/PerceivedComplexity + # rubocop: enable Metrics/AbcSize def use Labkit::Context.with_context(to_lazy_hash) { yield } diff --git a/lib/gitlab/usage/metrics/instrumentations/gitlab_config_metric.rb b/lib/gitlab/usage/metrics/instrumentations/gitlab_config_metric.rb new file mode 100644 index 00000000000..daeef06e6c5 --- /dev/null +++ b/lib/gitlab/usage/metrics/instrumentations/gitlab_config_metric.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module Gitlab + module Usage + module Metrics + module Instrumentations + class GitlabConfigMetric < GenericMetric + value do + method_name_array = config_hash_to_method_array(options[:config]) + + method_name_array.inject(Gitlab.config, :public_send) + end + + private + + def config_hash_to_method_array(object) + object.each_with_object([]) do |(key, value), result| + result.append(key) + + if value.is_a?(Hash) + result.concat(config_hash_to_method_array(value)) + else + result.append(value) + end + end + end + end + end + end + end +end diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb index 930a637cdd4..2b8b7aedeb2 100644 --- a/lib/gitlab/usage_data.rb +++ b/lib/gitlab/usage_data.rb @@ -163,11 +163,6 @@ module Gitlab def features_usage_data_ce { - container_registry_enabled: alt_usage_data(fallback: nil) { Gitlab.config.registry.enabled }, - dependency_proxy_enabled: Gitlab.config.try(:dependency_proxy)&.enabled, - gitlab_shared_runners_enabled: alt_usage_data(fallback: nil) { Gitlab.config.gitlab_ci.shared_runners_enabled }, - ldap_enabled: alt_usage_data(fallback: nil) { Gitlab.config.ldap.enabled }, - mattermost_enabled: alt_usage_data(fallback: nil) { Gitlab.config.mattermost.enabled }, omniauth_enabled: alt_usage_data(fallback: nil) { Gitlab::Auth.omniauth_enabled? }, prometheus_enabled: alt_usage_data(fallback: nil) { Gitlab::Prometheus::Internal.prometheus_enabled? }, prometheus_metrics_enabled: alt_usage_data(fallback: nil) { Gitlab::Metrics.prometheus_metrics_enabled? }, |