Commit d496c4b3 authored by alinamihaila's avatar alinamihaila

Add specific fallbacks for alt_usage_data

parent 6984d66c
...@@ -60,9 +60,9 @@ module EE ...@@ -60,9 +60,9 @@ module EE
def features_usage_data_ee def features_usage_data_ee
{ {
elasticsearch_enabled: alt_usage_data { ::Gitlab::CurrentSettings.elasticsearch_search? }, elasticsearch_enabled: alt_usage_data(fallback: nil) { ::Gitlab::CurrentSettings.elasticsearch_search? },
license_trial_ends_on: alt_usage_data { License.trial_ends_on }, license_trial_ends_on: alt_usage_data(fallback: nil) { License.trial_ends_on },
geo_enabled: alt_usage_data { ::Gitlab::Geo.enabled? } geo_enabled: alt_usage_data(fallback: nil) { ::Gitlab::Geo.enabled? }
} }
end end
......
...@@ -41,10 +41,10 @@ module Gitlab ...@@ -41,10 +41,10 @@ module Gitlab
def license_usage_data def license_usage_data
{ {
recorded_at: Time.now, # should be calculated very first recorded_at: Time.now, # should be calculated very first
uuid: Gitlab::CurrentSettings.uuid, uuid: alt_usage_data { Gitlab::CurrentSettings.uuid },
hostname: Gitlab.config.gitlab.host, hostname: alt_usage_data { Gitlab.config.gitlab.host },
version: Gitlab::VERSION, version: alt_usage_data { Gitlab::VERSION },
installation_type: installation_type, installation_type: alt_usage_data { installation_type },
active_user_count: count(User.active), active_user_count: count(User.active),
edition: 'CE' edition: 'CE'
} }
...@@ -174,19 +174,19 @@ module Gitlab ...@@ -174,19 +174,19 @@ module Gitlab
def features_usage_data_ce def features_usage_data_ce
{ {
container_registry_enabled: 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, dependency_proxy_enabled: Gitlab.config.try(:dependency_proxy)&.enabled,
gitlab_shared_runners_enabled: Gitlab.config.gitlab_ci.shared_runners_enabled, gitlab_shared_runners_enabled: alt_usage_data(fallback: nil) { Gitlab.config.gitlab_ci.shared_runners_enabled },
gravatar_enabled: Gitlab::CurrentSettings.gravatar_enabled?, gravatar_enabled: alt_usage_data(fallback: nil) { Gitlab::CurrentSettings.gravatar_enabled? },
ldap_enabled: Gitlab.config.ldap.enabled, ldap_enabled: alt_usage_data(fallback: nil) { Gitlab.config.ldap.enabled },
mattermost_enabled: Gitlab.config.mattermost.enabled, mattermost_enabled: alt_usage_data(fallback: nil) { Gitlab.config.mattermost.enabled },
omniauth_enabled: Gitlab::Auth.omniauth_enabled?, omniauth_enabled: alt_usage_data(fallback: nil) { Gitlab::Auth.omniauth_enabled? },
prometheus_metrics_enabled: Gitlab::Metrics.prometheus_metrics_enabled?, prometheus_metrics_enabled: alt_usage_data(fallback: nil) { Gitlab::Metrics.prometheus_metrics_enabled? },
reply_by_email_enabled: Gitlab::IncomingEmail.enabled?, reply_by_email_enabled: alt_usage_data(fallback: nil) { Gitlab::IncomingEmail.enabled? },
signup_enabled: Gitlab::CurrentSettings.allow_signup?, signup_enabled: alt_usage_data(fallback: nil) { Gitlab::CurrentSettings.allow_signup? },
web_ide_clientside_preview_enabled: Gitlab::CurrentSettings.web_ide_clientside_preview_enabled?, web_ide_clientside_preview_enabled: alt_usage_data(fallback: nil) { Gitlab::CurrentSettings.web_ide_clientside_preview_enabled? },
ingress_modsecurity_enabled: Feature.enabled?(:ingress_modsecurity), ingress_modsecurity_enabled: Feature.enabled?(:ingress_modsecurity),
grafana_link_enabled: Gitlab::CurrentSettings.grafana_enabled? grafana_link_enabled: alt_usage_data(fallback: nil) { Gitlab::CurrentSettings.grafana_enabled? }
} }
end end
...@@ -213,19 +213,19 @@ module Gitlab ...@@ -213,19 +213,19 @@ module Gitlab
def components_usage_data def components_usage_data
{ {
git: { version: Gitlab::Git.version }, git: { version: alt_usage_data(fallback: { major: -1 }) { Gitlab::Git.version } },
gitaly: { gitaly: {
version: Gitaly::Server.all.first.server_version, version: alt_usage_data { Gitaly::Server.all.first.server_version },
servers: alt_usage_data { Gitaly::Server.count }, servers: alt_usage_data { Gitaly::Server.count },
filesystems: Gitaly::Server.filesystems filesystems: alt_usage_data(fallback: ["-1"]) { Gitaly::Server.filesystems }
}, },
gitlab_pages: { gitlab_pages: {
enabled: Gitlab.config.pages.enabled, enabled: alt_usage_data(fallback: nil) { Gitlab.config.pages.enabled },
version: Gitlab::Pages::VERSION version: alt_usage_data { Gitlab::Pages::VERSION }
}, },
database: { database: {
adapter: Gitlab::Database.adapter_name, adapter: alt_usage_data { Gitlab::Database.adapter_name },
version: Gitlab::Database.version version: alt_usage_data { Gitlab::Database.version }
}, },
app_server: { type: app_server_type } app_server: { type: app_server_type }
} }
......
...@@ -15,11 +15,13 @@ ...@@ -15,11 +15,13 @@
# active_user_count: count(User.active) # active_user_count: count(User.active)
# #
# * alt_usage_data method # * 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: # Examples:
# alt_usage_data { Gitlab::VERSION } # alt_usage_data { Gitlab::VERSION }
# alt_usage_data { Gitlab::CurrentSettings.uuid } # alt_usage_data { Gitlab::CurrentSettings.uuid }
# alt_usage_data(fallback: nil) { Gitlab.config.registry.enabled }
# #
# * redis_usage_data method # * redis_usage_data method
# handles ::Redis::CommandError, Gitlab::UsageDataCounters::BaseCounter::UnknownEvent # 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