diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /lib/gitlab/tracking | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'lib/gitlab/tracking')
-rw-r--r-- | lib/gitlab/tracking/destinations/database_events_snowplow.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/tracking/service_ping_context.rb | 21 | ||||
-rw-r--r-- | lib/gitlab/tracking/standard_context.rb | 8 |
3 files changed, 17 insertions, 14 deletions
diff --git a/lib/gitlab/tracking/destinations/database_events_snowplow.rb b/lib/gitlab/tracking/destinations/database_events_snowplow.rb index e3512bc4916..458d7f0c129 100644 --- a/lib/gitlab/tracking/destinations/database_events_snowplow.rb +++ b/lib/gitlab/tracking/destinations/database_events_snowplow.rb @@ -16,7 +16,7 @@ module Gitlab override :hostname def hostname - return HOSTNAME if ::Gitlab.com? + return Gitlab::CurrentSettings.snowplow_database_collector_hostname || HOSTNAME if ::Gitlab.com? 'localhost:9091' end diff --git a/lib/gitlab/tracking/service_ping_context.rb b/lib/gitlab/tracking/service_ping_context.rb index d31ca69a10c..2135101e0e3 100644 --- a/lib/gitlab/tracking/service_ping_context.rb +++ b/lib/gitlab/tracking/service_ping_context.rb @@ -3,19 +3,18 @@ module Gitlab module Tracking class ServicePingContext - SCHEMA_URL = 'iglu:com.gitlab/gitlab_service_ping/jsonschema/1-0-0' + SCHEMA_URL = 'iglu:com.gitlab/gitlab_service_ping/jsonschema/1-0-1' REDISHLL_SOURCE = :redis_hll REDIS_SOURCE = :redis ALLOWED_SOURCES = [REDISHLL_SOURCE, REDIS_SOURCE].freeze - def initialize(data_source:, event: nil, key_path: nil) - check_configuration(data_source, event, key_path) + def initialize(data_source:, event: nil) + check_configuration(data_source, event) @payload = { data_source: data_source } - payload[:event_name] = event if data_source.eql? REDISHLL_SOURCE - payload[:key_path] = key_path if data_source.eql? REDIS_SOURCE + payload[:event_name] = event end def to_context @@ -33,18 +32,14 @@ module Gitlab attr_reader :payload - def check_configuration(data_source, event, key_path) - unless ALLOWED_SOURCES.include?(data_source) + def check_configuration(data_source, event) + unless ALLOWED_SOURCES.include?(data_source.to_sym) configuration_error("#{data_source} is not acceptable data source for ServicePingContext") end - if REDISHLL_SOURCE.eql?(data_source) && event.nil? - configuration_error("event attribute can not be missing for #{REDISHLL_SOURCE} data source") - end - - return unless REDIS_SOURCE.eql?(data_source) && key_path.nil? + return unless event.nil? - configuration_error("key_path attribute can not be missing for #{REDIS_SOURCE} data source") + configuration_error("event attribute is required") end def configuration_error(message) diff --git a/lib/gitlab/tracking/standard_context.rb b/lib/gitlab/tracking/standard_context.rb index 61d6fdc6dca..4c04fa7d525 100644 --- a/lib/gitlab/tracking/standard_context.rb +++ b/lib/gitlab/tracking/standard_context.rb @@ -50,6 +50,7 @@ module Gitlab plan: plan_name, extra: extra, user_id: user_id, + is_gitlab_team_member: gitlab_team_member?(user_id), namespace_id: namespace_id, project_id: project_id, context_generated_at: Time.current @@ -63,6 +64,13 @@ module Gitlab " Should be one of #{allowed_classes.map(&:to_s)}" Gitlab::ErrorTracking.track_and_raise_for_dev_exception(ArgumentError.new(exception)) end + + # Overridden in EE + def gitlab_team_member?(_user_id) + nil + end end end end + +Gitlab::Tracking::StandardContext.prepend_mod |