Commit 350289e5 authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch '237793-code-intelligence-usage-ping' into 'master'

Track projects using code intelligence

See merge request gitlab-org/gitlab!41881
parents 23a90108 88b6b83b
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
module Ci module Ci
class CreateJobArtifactsService < ::BaseService class CreateJobArtifactsService < ::BaseService
include Gitlab::Utils::UsageData
ArtifactsExistError = Class.new(StandardError) ArtifactsExistError = Class.new(StandardError)
LSIF_ARTIFACT_TYPE = 'lsif' LSIF_ARTIFACT_TYPE = 'lsif'
...@@ -22,7 +24,11 @@ module Ci ...@@ -22,7 +24,11 @@ module Ci
return result unless result[:status] == :success return result unless result[:status] == :success
headers = JobArtifactUploader.workhorse_authorize(has_length: false, maximum_size: max_size(artifact_type)) headers = JobArtifactUploader.workhorse_authorize(has_length: false, maximum_size: max_size(artifact_type))
headers[:ProcessLsif] = lsif?(artifact_type)
if lsif?(artifact_type)
headers[:ProcessLsif] = true
track_usage_event('i_source_code_code_intelligence', project)
end
success(headers: headers) success(headers: headers)
end end
......
---
title: Track projects using code intelligence
merge_request: 41881
author:
type: added
...@@ -120,6 +120,10 @@ ...@@ -120,6 +120,10 @@
- name: merge_request_action - name: merge_request_action
category: source_code category: source_code
aggregation: daily aggregation: daily
- name: i_source_code_code_intelligence
redis_slot: source_code
category: source_code
aggregation: daily
# Incident management # Incident management
- name: incident_management_alert_status_changed - name: incident_management_alert_status_changed
redis_slot: incident_management redis_slot: incident_management
......
...@@ -238,9 +238,24 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -238,9 +238,24 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
expect(json_response['ProcessLsif']).to be_truthy expect(json_response['ProcessLsif']).to be_truthy
end end
it 'tracks code_intelligence usage ping' do
tracking_params = {
event_names: 'i_source_code_code_intelligence',
start_date: Date.yesterday,
end_date: Date.today
}
expect { authorize_artifacts_with_token_in_headers(artifact_type: :lsif) }
.to change { Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(tracking_params) }
.by(1)
end
context 'code_navigation feature flag is disabled' do context 'code_navigation feature flag is disabled' do
it 'responds with a forbidden error' do before do
stub_feature_flags(code_navigation: false) stub_feature_flags(code_navigation: false)
end
it 'responds with a forbidden error' do
authorize_artifacts_with_token_in_headers(artifact_type: :lsif) authorize_artifacts_with_token_in_headers(artifact_type: :lsif)
aggregate_failures do aggregate_failures do
...@@ -248,6 +263,17 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -248,6 +263,17 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
expect(json_response['ProcessLsif']).to be_falsy expect(json_response['ProcessLsif']).to be_falsy
end end
end end
it 'does not track code_intelligence usage ping' do
tracking_params = {
event_names: 'i_source_code_code_intelligence',
start_date: Date.yesterday,
end_date: Date.today
}
expect { authorize_artifacts_with_token_in_headers(artifact_type: :lsif) }
.not_to change { Gitlab::UsageDataCounters::HLLRedisCounter.unique_events(tracking_params) }
end
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