Commit fc4b8356 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '208502-add-app-server-type-to-usage-ping' into 'master'

Add app server type to usage ping

Closes #208502

See merge request gitlab-org/gitlab!28189
parents f143d46a f5d7b6a8
---
title: Add app server type to usage ping
merge_request: 28189
author:
type: added
......@@ -174,10 +174,19 @@ module Gitlab
git: { version: Gitlab::Git.version },
gitaly: { version: Gitaly::Server.all.first.server_version, servers: Gitaly::Server.count, filesystems: Gitaly::Server.filesystems },
gitlab_pages: { enabled: Gitlab.config.pages.enabled, version: Gitlab::Pages::VERSION },
database: { adapter: Gitlab::Database.adapter_name, version: Gitlab::Database.version }
database: { adapter: Gitlab::Database.adapter_name, version: Gitlab::Database.version },
app_server: { type: app_server_type }
}
end
def app_server_type
Gitlab::Runtime.identify.to_s
rescue Gitlab::Runtime::IdentificationError => e
Gitlab::AppLogger.error(e.message)
Gitlab::ErrorTracking.track_exception(e)
'unknown_app_server_type'
end
def ingress_modsecurity_usage
::Clusters::Applications::IngressModsecurityUsageService.new.execute
end
......
......@@ -147,6 +147,8 @@ describe Gitlab::UsageData, :aggregate_failures do
subject { described_class.components_usage_data }
it 'gathers components usage data' do
expect(Gitlab::UsageData).to receive(:app_server_type).and_return('server_type')
expect(subject[:app_server][:type]).to eq('server_type')
expect(subject[:gitlab_pages][:enabled]).to eq(Gitlab.config.pages.enabled)
expect(subject[:gitlab_pages][:version]).to eq(Gitlab::Pages::VERSION)
expect(subject[:git][:version]).to eq(Gitlab::Git.version)
......@@ -159,6 +161,28 @@ describe Gitlab::UsageData, :aggregate_failures do
end
end
describe '#app_server_type' do
subject { described_class.app_server_type }
it 'successfully identifies runtime and returns the identifier' do
expect(Gitlab::Runtime).to receive(:identify).and_return(:runtime_identifier)
is_expected.to eq('runtime_identifier')
end
context 'when runtime is not identified' do
let(:exception) { Gitlab::Runtime::IdentificationError.new('exception message from runtime identify') }
it 'logs the exception and returns unknown app server type' do
expect(Gitlab::Runtime).to receive(:identify).and_raise(exception)
expect(Gitlab::AppLogger).to receive(:error).with(exception.message)
expect(Gitlab::ErrorTracking).to receive(:track_exception).with(exception)
expect(subject).to eq('unknown_app_server_type')
end
end
end
describe '#cycle_analytics_usage_data' do
subject { described_class.cycle_analytics_usage_data }
......
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