Commit 54514133 authored by Nick Thomas's avatar Nick Thomas

Merge branch '34157-apm_snowplow_events' into 'master'

Add snowplow events for APM

Closes #34157

See merge request gitlab-org/gitlab!19463
parents 7b35eb13 1d7ab307
......@@ -22,6 +22,8 @@ class PrometheusService < MonitoringService
after_save :clear_reactive_cache!
after_commit :track_events
def initialize_properties
if properties.nil?
self.properties = {}
......@@ -116,4 +118,22 @@ class PrometheusService < MonitoringService
true
end
def track_events
if enabled_manual_prometheus?
Gitlab::Tracking.event('cluster:services:prometheus', 'enabled_manual_prometheus')
elsif disabled_manual_prometheus?
Gitlab::Tracking.event('cluster:services:prometheus', 'disabled_manual_prometheus')
end
true
end
def enabled_manual_prometheus?
manual_configuration_changed? && manual_configuration?
end
def disabled_manual_prometheus?
manual_configuration_changed? && !manual_configuration?
end
end
---
title: Add snowplow events for APM
merge_request: 19463
author:
type: added
......@@ -53,6 +53,14 @@ module EE
def incident_management_available?
project.feature_available?(:incident_management, current_user)
end
def track_tracing_external_url
external_url_previous_change = project&.tracing_setting&.external_url_previous_change
return unless external_url_previous_change
return unless external_url_previous_change[0].blank? && external_url_previous_change[1].present?
::Gitlab::Tracking.event('project:operations:tracing', "external_url_populated")
end
end
override :permitted_project_params
......@@ -91,6 +99,8 @@ module EE
::Gitlab::Tracking::IncidentManagement.track_from_params(
update_params[:incident_management_setting_attributes]
)
track_tracing_external_url
end
end
end
......
......@@ -408,6 +408,20 @@ describe Projects::Settings::OperationsController do
it_behaves_like 'a gitlab tracking event', { send_email: '1' }, 'enabled_sending_emails'
it_behaves_like 'a gitlab tracking event', { send_email: '0' }, 'disabled_sending_emails'
end
context 'updating tracing settings' do
let(:project) { create(:project) }
let(:new_tracing_settings) { {} }
before do
project.add_maintainer(user)
end
it 'creates a gitlab tracking event' do
expect(Gitlab::Tracking).to receive(:event).with('project:operations:tracing', 'external_url_populated')
update_project(project, tracing_params: { external_url: "http://example.com" } )
end
end
end
context 'without a license' do
......
......@@ -29,10 +29,11 @@ module Gitlab
def execute!
result = execute_steps
if result[:status] == :success
::Gitlab::Tracking.event("self_monitoring", "project_created")
result
elsif STEPS_ALLOWED_TO_FAIL.include?(result[:last_step])
::Gitlab::Tracking.event("self_monitoring", "project_created")
success
else
raise StandardError, result[:message]
......
......@@ -279,5 +279,11 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do
end
end
end
it "tracks successful install" do
expect(Gitlab::Tracking).to receive(:event).with("self_monitoring", "project_created")
result
end
end
end
......@@ -262,4 +262,28 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
end
end
end
describe '#track_events after_commit callback' do
before do
allow(service).to receive(:prometheus_available?).and_return(true)
end
context "enabling manual_configuration" do
it "tracks enable event" do
service.update!(manual_configuration: false)
expect(Gitlab::Tracking).to receive(:event).with('cluster:services:prometheus', 'enabled_manual_prometheus')
service.update!(manual_configuration: true)
end
it "tracks disable event" do
service.update!(manual_configuration: true)
expect(Gitlab::Tracking).to receive(:event).with('cluster:services:prometheus', 'disabled_manual_prometheus')
service.update!(manual_configuration: false)
end
end
end
end
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