Commit 837fae86 authored by James Fargher's avatar James Fargher

Merge branch '218299-alt_usage_data-failing-undefined-method-values-for-1-integer' into 'master'

Alt_usage_data failing undefined method `values' for -1:Integer

Closes #218299

See merge request gitlab-org/gitlab!32938
parents 9a11d189 d496c4b3
......@@ -60,9 +60,9 @@ module EE
def features_usage_data_ee
{
elasticsearch_enabled: alt_usage_data { ::Gitlab::CurrentSettings.elasticsearch_search? },
license_trial_ends_on: alt_usage_data { License.trial_ends_on },
geo_enabled: alt_usage_data { ::Gitlab::Geo.enabled? }
elasticsearch_enabled: alt_usage_data(fallback: nil) { ::Gitlab::CurrentSettings.elasticsearch_search? },
license_trial_ends_on: alt_usage_data(fallback: nil) { License.trial_ends_on },
geo_enabled: alt_usage_data(fallback: nil) { ::Gitlab::Geo.enabled? }
}
end
......
......@@ -174,19 +174,19 @@ module Gitlab
def features_usage_data_ce
{
container_registry_enabled: alt_usage_data { Gitlab.config.registry.enabled },
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 { Gitlab.config.gitlab_ci.shared_runners_enabled },
gravatar_enabled: alt_usage_data { Gitlab::CurrentSettings.gravatar_enabled? },
ldap_enabled: alt_usage_data { Gitlab.config.ldap.enabled },
mattermost_enabled: alt_usage_data { Gitlab.config.mattermost.enabled },
omniauth_enabled: alt_usage_data { Gitlab::Auth.omniauth_enabled? },
prometheus_metrics_enabled: alt_usage_data { Gitlab::Metrics.prometheus_metrics_enabled? },
reply_by_email_enabled: alt_usage_data { Gitlab::IncomingEmail.enabled? },
signup_enabled: alt_usage_data { Gitlab::CurrentSettings.allow_signup? },
web_ide_clientside_preview_enabled: alt_usage_data { Gitlab::CurrentSettings.web_ide_clientside_preview_enabled? },
gitlab_shared_runners_enabled: alt_usage_data(fallback: nil) { Gitlab.config.gitlab_ci.shared_runners_enabled },
gravatar_enabled: alt_usage_data(fallback: nil) { Gitlab::CurrentSettings.gravatar_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_metrics_enabled: alt_usage_data(fallback: nil) { Gitlab::Metrics.prometheus_metrics_enabled? },
reply_by_email_enabled: alt_usage_data(fallback: nil) { Gitlab::IncomingEmail.enabled? },
signup_enabled: alt_usage_data(fallback: nil) { Gitlab::CurrentSettings.allow_signup? },
web_ide_clientside_preview_enabled: alt_usage_data(fallback: nil) { Gitlab::CurrentSettings.web_ide_clientside_preview_enabled? },
ingress_modsecurity_enabled: Feature.enabled?(:ingress_modsecurity),
grafana_link_enabled: alt_usage_data { Gitlab::CurrentSettings.grafana_enabled? }
grafana_link_enabled: alt_usage_data(fallback: nil) { Gitlab::CurrentSettings.grafana_enabled? }
}
end
......@@ -213,14 +213,14 @@ module Gitlab
def components_usage_data
{
git: { version: alt_usage_data { Gitlab::Git.version } },
git: { version: alt_usage_data(fallback: { major: -1 }) { Gitlab::Git.version } },
gitaly: {
version: alt_usage_data { Gitaly::Server.all.first.server_version },
servers: alt_usage_data { Gitaly::Server.count },
filesystems: alt_usage_data { Gitaly::Server.filesystems }
filesystems: alt_usage_data(fallback: ["-1"]) { Gitaly::Server.filesystems }
},
gitlab_pages: {
enabled: alt_usage_data { Gitlab.config.pages.enabled },
enabled: alt_usage_data(fallback: nil) { Gitlab.config.pages.enabled },
version: alt_usage_data { Gitlab::Pages::VERSION }
},
database: {
......
......@@ -15,11 +15,13 @@
# active_user_count: count(User.active)
#
# * alt_usage_data method
# handles StandardError and fallbacks into -1 this way not all measures fail if we encounter one exception
# handles StandardError and fallbacks by default into -1 this way not all measures fail if we encounter one exception
# there might be cases where we need to set a specific fallback in order to be aligned wih what version app is expecting as a type
#
# Examples:
# alt_usage_data { Gitlab::VERSION }
# alt_usage_data { Gitlab::CurrentSettings.uuid }
# alt_usage_data(fallback: nil) { Gitlab.config.registry.enabled }
#
# * redis_usage_data method
# handles ::Redis::CommandError, Gitlab::UsageDataCounters::BaseCounter::UnknownEvent
......
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