gitlab-exporter 8.0.0 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +1 -1
- data/.rubocop.yml +7 -5
- data/.rubocop_todo.yml +64 -0
- data/.ruby-version +1 -0
- data/Gemfile.lock +21 -14
- data/bin/gitlab-exporter +1 -1
- data/gitlab-exporter.gemspec +4 -4
- data/lib/gitlab_exporter/cli.rb +1 -2
- data/lib/gitlab_exporter/database/base.rb +5 -7
- data/lib/gitlab_exporter/database/bloat.rb +2 -2
- data/lib/gitlab_exporter/database/ci_builds.rb +4 -3
- data/lib/gitlab_exporter/database/row_count.rb +6 -6
- data/lib/gitlab_exporter/database/tuple_stats.rb +4 -2
- data/lib/gitlab_exporter/git.rb +4 -1
- data/lib/gitlab_exporter/memstats.rb +1 -1
- data/lib/gitlab_exporter/memstats/mapping.rb +1 -1
- data/lib/gitlab_exporter/process.rb +1 -3
- data/lib/gitlab_exporter/sidekiq.rb +9 -10
- data/lib/gitlab_exporter/util.rb +1 -1
- data/lib/gitlab_exporter/version.rb +1 -1
- data/lib/gitlab_exporter/web_exporter.rb +1 -1
- data/spec/database/bloat_spec.rb +1 -1
- data/spec/database/ci_builds_spec.rb +23 -23
- data/spec/git_process_proper_spec.rb +1 -1
- data/spec/memstats_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -4
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3fb1c9119047242e695cb956c7a68f7c19f564f7a274c8d503b7d4b984eed03
|
4
|
+
data.tar.gz: fb77e078e08dbc9f8f81a1a82dc070944fbf49af3944c90a8e30eac59ca1c39a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c75097275454229a38f351618bc7eef530534726fa16d3d06b1c8fb95d5fdacc43a84d4d9781963bf27b8afc7700699bfe32d5f0f8516403edf7d5fa5a6555a
|
7
|
+
data.tar.gz: 1eb96b35d5a80166dc5f587dce7de896d7533cf5822d5a17b220c0d09d858b01e5d02cfc7bbd8710b6002591efd9181cfab063b8fa8bfee698beca672536e83a
|
data/.gitlab-ci.yml
CHANGED
@@ -7,7 +7,7 @@ include:
|
|
7
7
|
- template: Security/Secret-Detection.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab-foss/-/blob/master/lib/gitlab/ci/templates/Security/Secret-Detection.gitlab-ci.yml
|
8
8
|
|
9
9
|
default:
|
10
|
-
image:
|
10
|
+
image: ruby:2.7
|
11
11
|
cache:
|
12
12
|
paths:
|
13
13
|
- vendor
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
1
3
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.7
|
3
5
|
DisplayCopNames: true
|
4
6
|
|
5
7
|
# Just use double quotes please
|
@@ -20,15 +22,15 @@ Style/RaiseArgs:
|
|
20
22
|
Style/FrozenStringLiteralComment:
|
21
23
|
Enabled: false
|
22
24
|
|
25
|
+
# Commonly used screens these days easily fit more than 80 characters.
|
26
|
+
Layout/LineLength:
|
27
|
+
Max: 120
|
28
|
+
|
23
29
|
Metrics/MethodLength:
|
24
30
|
Max: 15
|
25
31
|
|
26
32
|
Metrics/AbcSize:
|
27
33
|
Enabled: false
|
28
34
|
|
29
|
-
# Commonly used screens these days easily fit more than 80 characters.
|
30
|
-
Metrics/LineLength:
|
31
|
-
Max: 120
|
32
|
-
|
33
35
|
Metrics/ClassLength:
|
34
36
|
Max: 150
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2021-01-11 12:24:03 UTC using RuboCop version 0.93.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: Include.
|
11
|
+
# Include: **/*.gemspec
|
12
|
+
Gemspec/RequiredRubyVersion:
|
13
|
+
Exclude:
|
14
|
+
- 'gitlab-exporter.gemspec'
|
15
|
+
|
16
|
+
# Offense count: 3
|
17
|
+
Lint/AmbiguousBlockAssociation:
|
18
|
+
Exclude:
|
19
|
+
- 'spec/git_spec.rb'
|
20
|
+
- 'spec/util_spec.rb'
|
21
|
+
|
22
|
+
# Offense count: 2
|
23
|
+
# Configuration parameters: MaximumRangeSize.
|
24
|
+
Lint/MissingCopEnableDirective:
|
25
|
+
Exclude:
|
26
|
+
- 'spec/database/ci_builds_spec.rb'
|
27
|
+
- 'spec/git_process_proper_spec.rb'
|
28
|
+
|
29
|
+
# Offense count: 1
|
30
|
+
# Cop supports --auto-correct.
|
31
|
+
Lint/NonDeterministicRequireOrder:
|
32
|
+
Exclude:
|
33
|
+
- 'spec/spec_helper.rb'
|
34
|
+
|
35
|
+
# Offense count: 16
|
36
|
+
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
|
37
|
+
# ExcludedMethods: refine
|
38
|
+
Metrics/BlockLength:
|
39
|
+
Max: 349
|
40
|
+
|
41
|
+
# Offense count: 1
|
42
|
+
# Configuration parameters: IgnoredMethods.
|
43
|
+
Metrics/CyclomaticComplexity:
|
44
|
+
Max: 8
|
45
|
+
|
46
|
+
# Offense count: 1
|
47
|
+
# Configuration parameters: IgnoredMethods.
|
48
|
+
Metrics/PerceivedComplexity:
|
49
|
+
Max: 9
|
50
|
+
|
51
|
+
# Offense count: 1
|
52
|
+
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols.
|
53
|
+
# SupportedStyles: inline, group
|
54
|
+
Style/AccessModifierDeclarations:
|
55
|
+
Exclude:
|
56
|
+
- 'lib/gitlab_exporter/util.rb'
|
57
|
+
|
58
|
+
# Offense count: 2
|
59
|
+
# Cop supports --auto-correct.
|
60
|
+
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods.
|
61
|
+
# AllowedMethods: present?, blank?, presence, try, try!
|
62
|
+
Style/SafeNavigation:
|
63
|
+
Exclude:
|
64
|
+
- 'lib/gitlab_exporter/database/base.rb'
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.2
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gitlab-exporter (
|
4
|
+
gitlab-exporter (9.0.0)
|
5
5
|
connection_pool (~> 2.2.1)
|
6
6
|
pg (~> 1.1)
|
7
7
|
quantile (~> 0.2.0)
|
@@ -13,23 +13,25 @@ PATH
|
|
13
13
|
GEM
|
14
14
|
remote: https://rubygems.org/
|
15
15
|
specs:
|
16
|
-
ast (2.4.
|
16
|
+
ast (2.4.1)
|
17
17
|
connection_pool (2.2.3)
|
18
18
|
diff-lcs (1.3)
|
19
19
|
mustermann (1.1.1)
|
20
20
|
ruby2_keywords (~> 0.0.1)
|
21
|
-
|
22
|
-
|
21
|
+
parallel (1.20.1)
|
22
|
+
parser (3.0.0.0)
|
23
|
+
ast (~> 2.4.1)
|
23
24
|
pg (1.2.3)
|
24
|
-
powerpack (0.1.1)
|
25
25
|
quantile (0.2.1)
|
26
26
|
rack (2.2.3)
|
27
27
|
rack-protection (2.0.8.1)
|
28
28
|
rack
|
29
|
-
rainbow (
|
29
|
+
rainbow (3.0.0)
|
30
30
|
redis (4.1.4)
|
31
31
|
redis-namespace (1.6.0)
|
32
32
|
redis (>= 3.0.4)
|
33
|
+
regexp_parser (2.0.3)
|
34
|
+
rexml (3.2.4)
|
33
35
|
rspec (3.7.0)
|
34
36
|
rspec-core (~> 3.7.0)
|
35
37
|
rspec-expectations (~> 3.7.0)
|
@@ -43,13 +45,18 @@ GEM
|
|
43
45
|
diff-lcs (>= 1.2.0, < 2.0)
|
44
46
|
rspec-support (~> 3.7.0)
|
45
47
|
rspec-support (3.7.1)
|
46
|
-
rubocop (0.
|
47
|
-
|
48
|
-
|
49
|
-
rainbow (>=
|
48
|
+
rubocop (0.93.1)
|
49
|
+
parallel (~> 1.10)
|
50
|
+
parser (>= 2.7.1.5)
|
51
|
+
rainbow (>= 2.2.2, < 4.0)
|
52
|
+
regexp_parser (>= 1.8)
|
53
|
+
rexml
|
54
|
+
rubocop-ast (>= 0.6.0)
|
50
55
|
ruby-progressbar (~> 1.7)
|
51
|
-
unicode-display_width (
|
52
|
-
|
56
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
57
|
+
rubocop-ast (1.4.0)
|
58
|
+
parser (>= 2.7.1.5)
|
59
|
+
ruby-progressbar (1.11.0)
|
53
60
|
ruby2_keywords (0.0.2)
|
54
61
|
sidekiq (5.2.9)
|
55
62
|
connection_pool (~> 2.2, >= 2.2.2)
|
@@ -62,7 +69,7 @@ GEM
|
|
62
69
|
rack-protection (= 2.0.8.1)
|
63
70
|
tilt (~> 2.0)
|
64
71
|
tilt (2.0.10)
|
65
|
-
unicode-display_width (1.
|
72
|
+
unicode-display_width (1.7.0)
|
66
73
|
|
67
74
|
PLATFORMS
|
68
75
|
ruby
|
@@ -74,4 +81,4 @@ DEPENDENCIES
|
|
74
81
|
rubocop (~> 0.42)
|
75
82
|
|
76
83
|
BUNDLED WITH
|
77
|
-
1.
|
84
|
+
2.1.4
|
data/bin/gitlab-exporter
CHANGED
data/gitlab-exporter.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
lib = File.expand_path("
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
3
|
require "gitlab_exporter/version"
|
4
4
|
|
@@ -20,13 +20,13 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.homepage = "http://gitlab.com"
|
21
21
|
s.license = "MIT"
|
22
22
|
|
23
|
+
s.add_runtime_dependency "connection_pool", "~> 2.2.1"
|
23
24
|
s.add_runtime_dependency "pg", "~> 1.1"
|
24
|
-
s.add_runtime_dependency "sinatra", "~> 2.0.4"
|
25
25
|
s.add_runtime_dependency "quantile", "~> 0.2.0"
|
26
|
-
s.add_runtime_dependency "sidekiq", "~> 5.2.1"
|
27
26
|
s.add_runtime_dependency "redis", "~> 4.1.2"
|
28
27
|
s.add_runtime_dependency "redis-namespace", "~> 1.6.0"
|
29
|
-
s.add_runtime_dependency "
|
28
|
+
s.add_runtime_dependency "sidekiq", "~> 5.2.1"
|
29
|
+
s.add_runtime_dependency "sinatra", "~> 2.0.4"
|
30
30
|
|
31
31
|
s.add_development_dependency "rspec", "~> 3.7.0"
|
32
32
|
s.add_development_dependency "rspec-expectations", "~> 3.7.0"
|
data/lib/gitlab_exporter/cli.rb
CHANGED
@@ -19,8 +19,7 @@ module GitLab
|
|
19
19
|
# Empty runner that will raise an InvalidCLICommand when executed to provide the usage
|
20
20
|
# in the exception message
|
21
21
|
class NullRunner
|
22
|
-
def initialize(args)
|
23
|
-
end
|
22
|
+
def initialize(args); end
|
24
23
|
|
25
24
|
def run
|
26
25
|
fail InvalidCLICommand.new("Usage: #{EXECUTABLE_NAME} <command> [options] [arguments...]\n\n"\
|
@@ -31,13 +31,11 @@ module GitLab
|
|
31
31
|
|
32
32
|
def with_connection_pool
|
33
33
|
connection_pool.with do |conn|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
raise e
|
40
|
-
end
|
34
|
+
yield conn
|
35
|
+
rescue PG::UnableToSend => e
|
36
|
+
@logger.warn "Error sending to the database: #{e}" if @logger
|
37
|
+
conn.reset
|
38
|
+
raise e
|
41
39
|
end
|
42
40
|
rescue PG::Error => e
|
43
41
|
@logger.error "Error connecting to the database: #{e}" if @logger
|
@@ -35,7 +35,7 @@ module GitLab
|
|
35
35
|
|
36
36
|
# Prober class to gather bloat metrics
|
37
37
|
class BloatProber
|
38
|
-
METRIC_KEYS = %w
|
38
|
+
METRIC_KEYS = %w[bloat_ratio bloat_size extra_size real_size].freeze
|
39
39
|
|
40
40
|
attr_reader :metrics, :collector, :bloat_types
|
41
41
|
|
@@ -46,7 +46,7 @@ module GitLab
|
|
46
46
|
@metrics = metrics
|
47
47
|
@collector = collector
|
48
48
|
@collector.logger = logger
|
49
|
-
@bloat_types = opts[:bloat_types] || %i
|
49
|
+
@bloat_types = opts[:bloat_types] || %i[btree table]
|
50
50
|
end
|
51
51
|
|
52
52
|
def probe_db
|
@@ -391,6 +391,7 @@ module GitLab
|
|
391
391
|
|
392
392
|
def include_bool_if_row_defined(row, field)
|
393
393
|
return {} unless row[field.to_s]
|
394
|
+
|
394
395
|
{ field => row[field.to_s] == "t" ? "yes" : "no" }
|
395
396
|
end
|
396
397
|
|
@@ -470,7 +471,7 @@ module GitLab
|
|
470
471
|
|
471
472
|
def add_ci_created_pending_builds(metric_name, value, labels)
|
472
473
|
add_metric_with_namespace_label(metric_name,
|
473
|
-
[
|
474
|
+
%i[namespace shared_runners has_minutes],
|
474
475
|
value,
|
475
476
|
labels)
|
476
477
|
end
|
@@ -505,8 +506,8 @@ module GitLab
|
|
505
506
|
def add_ci_running_builds(value, labels)
|
506
507
|
add_metric_with_namespace_label(
|
507
508
|
"ci_running_builds",
|
508
|
-
[
|
509
|
-
|
509
|
+
%i[runner namespace runner_type scheduled
|
510
|
+
triggered mirror mirror_trigger_builds has_minutes],
|
510
511
|
value,
|
511
512
|
labels
|
512
513
|
)
|
@@ -29,7 +29,7 @@ module GitLab
|
|
29
29
|
|
30
30
|
MIRROR_QUERY = {
|
31
31
|
select: :projects,
|
32
|
-
joins:
|
32
|
+
joins: <<~SQL,
|
33
33
|
INNER JOIN project_mirror_data ON project_mirror_data.project_id = projects.id
|
34
34
|
INNER JOIN namespaces AS root_namespaces ON root_namespaces.id = (
|
35
35
|
WITH RECURSIVE "base_and_ancestors" AS (
|
@@ -112,9 +112,9 @@ module GitLab
|
|
112
112
|
ON users.id = u.user_id",
|
113
113
|
where: "user_type IS NULL",
|
114
114
|
fields: {
|
115
|
-
admin:
|
116
|
-
external:
|
117
|
-
state:
|
115
|
+
admin: {},
|
116
|
+
external: {},
|
117
|
+
state: {},
|
118
118
|
access_level: { definition: "COALESCE(u.access_level, 0)" }
|
119
119
|
}
|
120
120
|
},
|
@@ -122,14 +122,14 @@ module GitLab
|
|
122
122
|
select: :projects,
|
123
123
|
fields: {
|
124
124
|
visibility_level: {},
|
125
|
-
archived:
|
125
|
+
archived: {}
|
126
126
|
}
|
127
127
|
},
|
128
128
|
groups: {
|
129
129
|
select: :namespaces,
|
130
130
|
fields: {
|
131
131
|
visibility_level: {},
|
132
|
-
root:
|
132
|
+
root: { definition: "(parent_id IS NULL)" }
|
133
133
|
}
|
134
134
|
}
|
135
135
|
}.freeze
|
@@ -5,7 +5,7 @@ module GitLab
|
|
5
5
|
#
|
6
6
|
# It takes a connection string (e.g. "dbname=test port=5432")
|
7
7
|
class TupleStatsCollector < Base
|
8
|
-
COLUMNS = %w
|
8
|
+
COLUMNS = %w[relname seq_tup_read idx_tup_fetch n_tup_ins n_tup_upd n_tup_del n_tup_hot_upd n_dead_tup seq_scan]
|
9
9
|
.join(",")
|
10
10
|
QUERY = <<-SQL.freeze
|
11
11
|
SELECT #{COLUMNS}
|
@@ -35,9 +35,11 @@ module GitLab
|
|
35
35
|
|
36
36
|
result.each do |table_name, tuple_stats|
|
37
37
|
tuple_stats.each do |column_name, value|
|
38
|
+
next if value.is_a?(Numeric)
|
39
|
+
|
38
40
|
@metrics.add("gitlab_database_stat_table_#{column_name}",
|
39
41
|
value.to_f,
|
40
|
-
table_name: table_name)
|
42
|
+
table_name: table_name)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
data/lib/gitlab_exporter/git.rb
CHANGED
@@ -13,6 +13,7 @@ module GitLab
|
|
13
13
|
class Git
|
14
14
|
def initialize(repo)
|
15
15
|
fail "Repository #{repo} does not exists" unless Dir.exist? repo
|
16
|
+
|
16
17
|
@repo = repo
|
17
18
|
@tracker = TimeTracker.new
|
18
19
|
end
|
@@ -35,6 +36,7 @@ module GitLab
|
|
35
36
|
def execute(command)
|
36
37
|
result = CommandResult.new(*Open3.capture2e(command, chdir: @repo))
|
37
38
|
fail "Command #{command} failed with status #{result.status}\n#{result.stdout}" if result.failed?
|
39
|
+
|
38
40
|
result
|
39
41
|
end
|
40
42
|
end
|
@@ -96,7 +98,7 @@ module GitLab
|
|
96
98
|
Utils.pgrep("^git ").each do |pid|
|
97
99
|
process_cmd = begin
|
98
100
|
File.read("/proc/#{pid}/cmdline")
|
99
|
-
rescue
|
101
|
+
rescue StandardError
|
100
102
|
"" # Process file is gone (race condition)
|
101
103
|
end
|
102
104
|
subcommand = self.class.extract_subcommand(process_cmd)
|
@@ -131,6 +133,7 @@ module GitLab
|
|
131
133
|
|
132
134
|
def self.extract_subcommand(cmd)
|
133
135
|
return if cmd.empty?
|
136
|
+
|
134
137
|
cmd_splitted = cmd.split("\u0000") # cmdline does not return it space-separated
|
135
138
|
|
136
139
|
cmd_splitted.shift # Because it's "git"
|
@@ -25,7 +25,7 @@ module GitLab
|
|
25
25
|
# Locked: 0 kB
|
26
26
|
# VmFlags: rd ex mr mw me dw sd
|
27
27
|
class Mapping
|
28
|
-
FIELDS = %w
|
28
|
+
FIELDS = %w[size rss shared_clean shared_dirty private_clean private_dirty swap pss].freeze
|
29
29
|
|
30
30
|
attr_reader :address_start
|
31
31
|
attr_reader :address_end
|
@@ -105,9 +105,7 @@ module GitLab
|
|
105
105
|
::GitLab::Exporter::MemStats::Mapping::FIELDS.each do |field|
|
106
106
|
value = stats.totals[field]
|
107
107
|
|
108
|
-
if value >= 0
|
109
|
-
@metrics.add("process_smaps_#{field}_bytes", value * 1024, @use_quantiles, **labels)
|
110
|
-
end
|
108
|
+
@metrics.add("process_smaps_#{field}_bytes", value * 1024, @use_quantiles, **labels) if value >= 0
|
111
109
|
end
|
112
110
|
end
|
113
111
|
|
@@ -53,21 +53,19 @@ module GitLab
|
|
53
53
|
self
|
54
54
|
end
|
55
55
|
|
56
|
-
def probe_jobs
|
56
|
+
def probe_jobs
|
57
57
|
return self unless connected?
|
58
58
|
|
59
59
|
job_stats = {}
|
60
60
|
|
61
61
|
Sidekiq::Queue.all.each do |queue|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
job_stats.merge!(stats.to_h)
|
66
|
-
end
|
67
|
-
rescue Redis::CommandError # Could happen if the script exceeded the maximum run time (5 seconds by default)
|
68
|
-
# FIXME: Should we call SCRIPT KILL?
|
69
|
-
return self
|
62
|
+
Sidekiq.redis do |conn|
|
63
|
+
stats = conn.evalsha(QUEUE_JOB_STATS_SHA, ["queue:#{queue.name}"])
|
64
|
+
job_stats.merge!(stats.to_h)
|
70
65
|
end
|
66
|
+
rescue Redis::CommandError # Could happen if the script exceeded the maximum run time (5 seconds by default)
|
67
|
+
# FIXME: Should we call SCRIPT KILL?
|
68
|
+
return self
|
71
69
|
end
|
72
70
|
|
73
71
|
job_stats.each do |class_name, count|
|
@@ -153,7 +151,7 @@ module GitLab
|
|
153
151
|
end
|
154
152
|
true
|
155
153
|
end
|
156
|
-
rescue Redis::CannotConnectError, Redis::TimeoutError
|
154
|
+
rescue Redis::CannotConnectError, Redis::TimeoutError
|
157
155
|
# Maybe we're trying connecting to a slave
|
158
156
|
end
|
159
157
|
|
@@ -164,6 +162,7 @@ module GitLab
|
|
164
162
|
# Using administrative commands on conn directly (which is a Redis::Namespace)
|
165
163
|
# will be removed in redis-namespace 2.0.
|
166
164
|
next if conn.redis.script(:exists, QUEUE_JOB_STATS_SHA)
|
165
|
+
|
167
166
|
conn.redis.script(:load, QUEUE_JOB_STATS_SCRIPT)
|
168
167
|
end
|
169
168
|
end
|
data/lib/gitlab_exporter/util.rb
CHANGED
@@ -24,7 +24,7 @@ module GitLab
|
|
24
24
|
# Helper methods, some stuff was copied from ActiveSupport
|
25
25
|
module Utils
|
26
26
|
def camel_case_string(str)
|
27
|
-
str.gsub(/(?:_|^)([a-z\d]*)/i) { $1.capitalize } # rubocop:disable PerlBackrefs
|
27
|
+
str.gsub(/(?:_|^)([a-z\d]*)/i) { $1.capitalize } # rubocop:disable Style/PerlBackrefs
|
28
28
|
end
|
29
29
|
module_function :camel_case_string
|
30
30
|
|
data/spec/database/bloat_spec.rb
CHANGED
@@ -26,7 +26,7 @@ describe GitLab::Exporter::Database::BloatCollector do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
describe GitLab::Exporter::Database::BloatProber do
|
29
|
-
let(:opts) { { bloat_types: %i
|
29
|
+
let(:opts) { { bloat_types: %i[btree table] } }
|
30
30
|
let(:metrics) { double("PrometheusMetrics", add: nil) }
|
31
31
|
let(:collector) { double("BloatCollector", run: data) }
|
32
32
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require "gitlab_exporter/database/ci_builds"
|
3
3
|
|
4
|
-
# rubocop:disable
|
4
|
+
# rubocop:disable Layout/LineLength
|
5
5
|
describe GitLab::Exporter::Database do
|
6
6
|
let(:set_random_page_cost_query) { "SET random_page_cost" }
|
7
7
|
let(:builds_query_ee) { "SELECT BUILDS EE" }
|
@@ -100,35 +100,35 @@ describe GitLab::Exporter::Database do
|
|
100
100
|
allow(Time).to receive(:now).and_return(time_now)
|
101
101
|
|
102
102
|
allow(connection).to receive(:exec).with(builds_query_ee)
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
103
|
+
.and_return([builds_query_row_ee("f", "created", "1", "f", 10),
|
104
|
+
builds_query_row_ee("t", "pending", "1", "t", 30),
|
105
|
+
builds_query_row_ee("f", "created", "2", "f", 20),
|
106
|
+
builds_query_row_ee("t", "pending", "2", "t", 50),
|
107
|
+
builds_query_row_ee("t", "pending", "3", "f", 1),
|
108
|
+
builds_query_row_ee("t", "pending", "4", "t", 2),
|
109
|
+
builds_query_row_ee("f", "pending", "5", "f", 2)])
|
110
110
|
allow(connection).to receive(:exec).with(builds_query_ce)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
111
|
+
.and_return([builds_query_row_ce("f", "created", "1", 10),
|
112
|
+
builds_query_row_ce("t", "pending", "1", 30),
|
113
|
+
builds_query_row_ce("f", "created", "2", 20),
|
114
|
+
builds_query_row_ce("t", "pending", "2", 50),
|
115
|
+
builds_query_row_ce("t", "pending", "3", 1),
|
116
|
+
builds_query_row_ce("t", "pending", "4", 2),
|
117
|
+
builds_query_row_ce("f", "pending", "5", 2)])
|
118
118
|
|
119
119
|
allow(connection).to receive(:exec).with(stale_builds_query).and_return([{ "count" => 2 }])
|
120
120
|
|
121
121
|
allow(connection).to receive(:exec).with(per_runner_query_ee)
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
122
|
+
.and_return([per_runner_query_row_ee(1, "instance_type", 1, "f", "f", 1, nil, "t", 15),
|
123
|
+
per_runner_query_row_ee(2, "project_type", 2, "t", "t", nil, 3, "f", 5),
|
124
|
+
per_runner_query_row_ee(2, "project_type", 3, "t", "t", nil, 3, "t", 5),
|
125
|
+
per_runner_query_row_ee(3, "project_type", 4, "t", "t", nil, 3, "f", 5)])
|
126
126
|
|
127
127
|
allow(connection).to receive(:exec).with(per_runner_query_ce)
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
.and_return([per_runner_query_row_ce(1, "instance_type", 1, 1, nil, 15),
|
129
|
+
per_runner_query_row_ce(2, "project_type", 2, nil, 3, 5),
|
130
|
+
per_runner_query_row_ce(2, "project_type", 3, nil, 3, 5),
|
131
|
+
per_runner_query_row_ce(3, "project_type", 4, nil, 3, 5)])
|
132
132
|
|
133
133
|
# rubocop:disable Style/FormatString
|
134
134
|
repeated_commands_query_ee_with_limit = repeated_commands_query_ee % [allowed_repeated_commands_count]
|
data/spec/memstats_spec.rb
CHANGED
@@ -14,11 +14,11 @@ describe GitLab::Exporter::MemStats do
|
|
14
14
|
it "parses the data properly" do
|
15
15
|
expect(subject.valid?).to be_truthy
|
16
16
|
|
17
|
-
nonzero_fields = %w
|
18
|
-
zero_fields = %w
|
17
|
+
nonzero_fields = %w[size rss shared_clean shared_dirty private_dirty pss]
|
18
|
+
zero_fields = %w[private_clean swap]
|
19
19
|
|
20
20
|
nonzero_fields.each do |field|
|
21
|
-
expect(subject.totals[field]).to be > 0
|
21
|
+
expect(subject.totals[field]).to be > 0
|
22
22
|
end
|
23
23
|
|
24
24
|
zero_fields.each do |field|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-exporter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Carranza
|
@@ -11,33 +11,33 @@ cert_chain: []
|
|
11
11
|
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: connection_pool
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.2.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: pg
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: '1.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: quantile
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,61 +53,61 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.2.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: redis
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 4.1.2
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 4.1.2
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: redis
|
70
|
+
name: redis-namespace
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.6.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.6.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: sidekiq
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 5.2.1
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 5.2.1
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: sinatra
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 2.
|
103
|
+
version: 2.0.4
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
110
|
+
version: 2.0.4
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,6 +146,8 @@ files:
|
|
146
146
|
- ".gitignore"
|
147
147
|
- ".gitlab-ci.yml"
|
148
148
|
- ".rubocop.yml"
|
149
|
+
- ".rubocop_todo.yml"
|
150
|
+
- ".ruby-version"
|
149
151
|
- CONTRIBUTING.md
|
150
152
|
- Gemfile
|
151
153
|
- Gemfile.lock
|
@@ -206,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
208
|
- !ruby/object:Gem::Version
|
207
209
|
version: '0'
|
208
210
|
requirements: []
|
209
|
-
rubygems_version: 3.
|
211
|
+
rubygems_version: 3.1.4
|
210
212
|
signing_key:
|
211
213
|
specification_version: 4
|
212
214
|
summary: GitLab metrics exporter
|