2023-06-20 00:43:36 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Tracking
|
|
|
|
module Destinations
|
|
|
|
class DatabaseEventsSnowplow < Snowplow
|
|
|
|
extend ::Gitlab::Utils::Override
|
|
|
|
|
2023-07-09 08:55:56 +05:30
|
|
|
HOSTNAME = 'db-snowplow.trx.gitlab.net'
|
2023-06-20 00:43:36 +05:30
|
|
|
|
|
|
|
override :enabled?
|
|
|
|
# database events are only collected for SaaS instance
|
|
|
|
def enabled?
|
|
|
|
::Gitlab.dev_or_test_env? || ::Gitlab.com?
|
|
|
|
end
|
|
|
|
|
|
|
|
override :hostname
|
|
|
|
def hostname
|
2023-07-09 08:55:56 +05:30
|
|
|
return HOSTNAME if ::Gitlab.com?
|
|
|
|
|
|
|
|
'localhost:9091'
|
2023-06-20 00:43:36 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
override :increment_failed_events_emissions
|
|
|
|
def increment_failed_events_emissions(value)
|
|
|
|
Gitlab::Metrics.counter(
|
|
|
|
:gitlab_db_events_snowplow_failed_events_total,
|
|
|
|
'Number of failed Snowplow events emissions'
|
|
|
|
).increment({}, value.to_i)
|
|
|
|
end
|
|
|
|
|
|
|
|
override :increment_successful_events_emissions
|
|
|
|
def increment_successful_events_emissions(value)
|
|
|
|
Gitlab::Metrics.counter(
|
|
|
|
:gitlab_db_events_snowplow_successful_events_total,
|
|
|
|
'Number of successful Snowplow events emissions'
|
|
|
|
).increment({}, value.to_i)
|
|
|
|
end
|
|
|
|
|
|
|
|
override :increment_total_events_counter
|
|
|
|
def increment_total_events_counter
|
|
|
|
Gitlab::Metrics.counter(
|
|
|
|
:gitlab_db_events_snowplow_events_total,
|
|
|
|
'Number of Snowplow events'
|
|
|
|
).increment
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|