Commit ea795837 authored by Stan Hu's avatar Stan Hu

Merge branch 'zj-gitaly-usage-data' into 'master'

Add Gitaly data to the usage ping

See merge request gitlab-org/gitlab-ce!29893
parents 2b587125 44528f6c
---
title: Add Gitaly data to the usage ping
merge_request:
author:
type: added
...@@ -2,10 +2,20 @@ ...@@ -2,10 +2,20 @@
module Gitaly module Gitaly
class Server class Server
def self.all class << self
def all
Gitlab.config.repositories.storages.keys.map { |s| Gitaly::Server.new(s) } Gitlab.config.repositories.storages.keys.map { |s| Gitaly::Server.new(s) }
end end
def count
all.size
end
def filesystems
all.map(&:filesystem_type).compact.uniq
end
end
attr_reader :storage attr_reader :storage
def initialize(storage) def initialize(storage)
...@@ -36,6 +46,10 @@ module Gitaly ...@@ -36,6 +46,10 @@ module Gitaly
storage_status&.writeable storage_status&.writeable
end end
def filesystem_type
storage_status&.fs_type
end
def address def address
Gitlab::GitalyClient.address(@storage) Gitlab::GitalyClient.address(@storage)
rescue RuntimeError => e rescue RuntimeError => e
......
...@@ -136,8 +136,9 @@ module Gitlab ...@@ -136,8 +136,9 @@ module Gitlab
def components_usage_data def components_usage_data
{ {
gitlab_pages: { enabled: Gitlab.config.pages.enabled, version: Gitlab::Pages::VERSION },
git: { version: Gitlab::Git.version }, 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 }
} }
end end
......
...@@ -47,6 +47,12 @@ describe Gitaly::Server do ...@@ -47,6 +47,12 @@ describe Gitaly::Server do
end end
end end
describe "#filesystem_type" do
subject { server.filesystem_type }
it { is_expected.to be_present }
end
describe 'request memoization' do describe 'request memoization' do
context 'when requesting multiple properties', :request_store do context 'when requesting multiple properties', :request_store do
it 'uses memoization for the info request' do it 'uses memoization for the info request' do
......
...@@ -54,6 +54,7 @@ describe Gitlab::UsageData do ...@@ -54,6 +54,7 @@ describe Gitlab::UsageData do
gitlab_shared_runners_enabled gitlab_shared_runners_enabled
gitlab_pages gitlab_pages
git git
gitaly
database database
avg_cycle_analytics avg_cycle_analytics
web_ide_commits web_ide_commits
...@@ -205,6 +206,10 @@ describe Gitlab::UsageData do ...@@ -205,6 +206,10 @@ describe Gitlab::UsageData do
expect(subject[:git][:version]).to eq(Gitlab::Git.version) expect(subject[:git][:version]).to eq(Gitlab::Git.version)
expect(subject[:database][:adapter]).to eq(Gitlab::Database.adapter_name) expect(subject[:database][:adapter]).to eq(Gitlab::Database.adapter_name)
expect(subject[:database][:version]).to eq(Gitlab::Database.version) expect(subject[:database][:version]).to eq(Gitlab::Database.version)
expect(subject[:gitaly][:version]).to be_present
expect(subject[:gitaly][:servers]).to be >= 1
expect(subject[:gitaly][:filesystems]).to be_an(Array)
expect(subject[:gitaly][:filesystems].first).to be_a(String)
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