gitlab-labkit 0.16.1 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1af5bacbedb8ce602015ad3de86ac23ddd28e2e17e78fac4dfb9d232ebe164f
4
- data.tar.gz: caa3cb59ed0f1521530b7edfaa17234dcee23f7cdfca628d6aa2aac183fb3b4e
3
+ metadata.gz: 2ffa08defed93e465326a1f5db11670aacc69f3ebf2382d25459e4a9db3834b0
4
+ data.tar.gz: 81e98feb830a7247ecfb21b227d0b8f9bd632a1e7d3a90b95e4563d7a6ccfb6c
5
5
  SHA512:
6
- metadata.gz: 36c847453715c4e1206839927383371369cfca346e1c2736f28b37a1425530047ea6d6c16bb5a7b732c7aa5d29eb2ab7a86f443b316d2abfbeae22828dcf04a9
7
- data.tar.gz: f6c53e51b35f5e504f8f01d5b38578cc9ebdf41b34239385df4c7c0b8499be7ddfb375614e922297cff52affff96d8287477681153e854bf2fd86aa7ade9a425
6
+ metadata.gz: 8132d375526e57b7afa78b4edcc93268cfffbe9b3c1cf5db9de0f18e6f4c8ac22b934d7e2deed413caf13583e483a896584acd8e56fa1318a748fedf19cd98a0
7
+ data.tar.gz: 1f18c8ab7c8bacf6f8549d741c8ed500eebbca0e3fc4a47bed3fc5d239fc19eac9316c43ddfefdc771eb58ef11adc52e1a358ef46502bf4de0c7a6bca2e08207
data/.gitlab-ci.yml CHANGED
@@ -1,3 +1,6 @@
1
+ default:
2
+ image: ruby:2.7
3
+
1
4
  workflow:
2
5
  rules:
3
6
  # For merge requests, create a pipeline.
@@ -14,6 +17,10 @@ workflow:
14
17
  - bundle install
15
18
  - bundle exec rake verify build install
16
19
 
20
+ test:3.0:
21
+ image: ruby:3.0
22
+ <<: *test_definition
23
+
17
24
  test:2.7:
18
25
  image: ruby:2.7
19
26
  <<: *test_definition
@@ -22,9 +29,11 @@ test:2.6:
22
29
  image: ruby:2.6
23
30
  <<: *test_definition
24
31
 
25
- test:2.5:
26
- image: ruby:2.5
27
- <<: *test_definition
32
+ static-analysis:
33
+ before_script:
34
+ - bundle install
35
+ script:
36
+ - rake verify
28
37
 
29
38
  deploy:
30
39
  stage: deploy
data/.rubocop.yml CHANGED
@@ -1,8 +1,11 @@
1
- AllCops:
2
- TargetRubyVersion: 2.4
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ inherit_gem:
4
+ gitlab-styles:
5
+ - rubocop-default.yml
3
6
 
4
- require:
5
- - rubocop-rspec
7
+ AllCops:
8
+ TargetRubyVersion: 2.7
6
9
 
7
10
  Style/HashSyntax:
8
11
  EnforcedStyle: no_mixed_keys
@@ -28,11 +31,11 @@ Style/StringLiterals:
28
31
  Style/StringLiteralsInInterpolation:
29
32
  EnforcedStyle: double_quotes
30
33
 
31
- Style/UseLambda:
34
+ Style/Lambda:
32
35
  Enabled: false
33
36
 
34
- Layout/MultilineMethodCallIndentation:
35
- Enabled: No
37
+ Layout/LineLength:
38
+ Enabled: false
36
39
 
37
40
  Layout/SpaceInLambdaLiteral:
38
41
  Enabled: No
@@ -43,69 +46,6 @@ Layout/SpaceInsideBlockBraces:
43
46
  Layout/FirstParameterIndentation:
44
47
  Enabled: No
45
48
 
46
- Metrics/AbcSize:
47
- Enabled: true
48
- Max: 54.28
49
-
50
- Metrics/BlockLength:
51
- Enabled: false
52
-
53
- Metrics/BlockNesting:
54
- Enabled: true
55
- Max: 4
56
-
57
- Metrics/ClassLength:
58
- Enabled: false
59
-
60
- Metrics/CyclomaticComplexity:
61
- Enabled: true
62
- Max: 13
63
-
64
- Metrics/LineLength:
65
- Enabled: false
66
-
67
- Metrics/MethodLength:
68
- Enabled: false
69
-
70
- Metrics/ModuleLength:
71
- Enabled: false
72
-
73
- Metrics/ParameterLists:
74
- Enabled: true
75
- Max: 8
76
-
77
- Metrics/PerceivedComplexity:
78
- Enabled: true
79
- Max: 14
80
-
81
- RSpec/AnyInstance:
82
- Enabled: false
83
-
84
- RSpec/BeEql:
85
- Enabled: true
86
-
87
- RSpec/BeforeAfterAll:
88
- Enabled: false
89
-
90
- RSpec/DescribeClass:
91
- Enabled: false
92
-
93
- RSpec/DescribeMethod:
94
- Enabled: false
95
-
96
- RSpec/DescribeSymbol:
97
- Enabled: true
98
-
99
- RSpec/DescribedClass:
100
- Enabled: true
101
-
102
- RSpec/EmptyExampleGroup:
103
- Enabled: true
104
-
105
- RSpec/ExampleLength:
106
- Enabled: false
107
- Max: 5
108
-
109
49
  RSpec/ExampleWording:
110
50
  Enabled: false
111
51
  CustomTransform:
@@ -114,63 +54,9 @@ RSpec/ExampleWording:
114
54
  not: does not
115
55
  IgnoredWords: []
116
56
 
117
- RSpec/ExpectActual:
118
- Enabled: true
119
-
120
- RSpec/ExpectOutput:
57
+ Lint/HashCompareByIdentity: # (new in 0.93)
121
58
  Enabled: true
122
-
123
- RSpec/FilePath:
59
+ Lint/RedundantSafeNavigation: # (new in 0.93)
124
60
  Enabled: true
125
- IgnoreMethods: true
126
-
127
- RSpec/Focus:
128
- Enabled: true
129
-
130
- RSpec/HookArgument:
131
- Enabled: true
132
- EnforcedStyle: implicit
133
-
134
- RSpec/ImplicitExpect:
135
- Enabled: true
136
- EnforcedStyle: is_expected
137
-
138
- RSpec/InstanceVariable:
139
- Enabled: false
140
-
141
- RSpec/LeadingSubject:
142
- Enabled: false
143
-
144
- RSpec/LetSetup:
145
- Enabled: false
146
-
147
- RSpec/MessageChain:
148
- Enabled: false
149
-
150
- RSpec/MessageSpies:
151
- Enabled: false
152
-
153
- RSpec/MultipleDescribes:
154
- Enabled: false
155
-
156
- RSpec/MultipleExpectations:
157
- Enabled: false
158
-
159
- RSpec/NamedSubject:
160
- Enabled: false
161
-
162
- RSpec/NestedGroups:
163
- Enabled: false
164
-
165
- RSpec/NotToNot:
166
- EnforcedStyle: not_to
61
+ Style/ClassEqualityComparison: # (new in 0.93)
167
62
  Enabled: true
168
-
169
- RSpec/RepeatedDescription:
170
- Enabled: false
171
-
172
- RSpec/SubjectStub:
173
- Enabled: false
174
-
175
- RSpec/VerifiedDoubles:
176
- Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,238 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2021-04-18 00:00:00 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: 51
10
+ # Cop supports --auto-correct.
11
+ CodeReuse/ActiveRecord:
12
+ Exclude:
13
+ - 'spec/labkit/correlation/grpc/client_interceptor_spec.rb'
14
+ - 'spec/labkit/correlation/grpc/server_interceptor_spec.rb'
15
+ - 'spec/labkit/middleware/rack_spec.rb'
16
+ - 'spec/labkit/middleware/sidekiq/client_spec.rb'
17
+ - 'spec/labkit/middleware/sidekiq/context/server_spec.rb'
18
+ - 'spec/labkit/middleware/sidekiq/server_spec.rb'
19
+ - 'spec/labkit/middleware/sidekiq/tracing/client_spec.rb'
20
+ - 'spec/labkit/middleware/sidekiq/tracing/server_spec.rb'
21
+ - 'spec/labkit/tracing/factory_spec.rb'
22
+ - 'spec/labkit/tracing/grpc/client_interceptor_spec.rb'
23
+ - 'spec/labkit/tracing/grpc/server_interceptor_spec.rb'
24
+ - 'spec/labkit/tracing_spec.rb'
25
+ - 'spec/support/tracing/shared_examples.rb'
26
+
27
+ # Offense count: 1
28
+ # Configuration parameters: Include.
29
+ # Include: **/*.gemspec
30
+ Gemspec/RequiredRubyVersion:
31
+ Exclude:
32
+ - 'gitlab-labkit.gemspec'
33
+
34
+ # Offense count: 1
35
+ # Cop supports --auto-correct.
36
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
37
+ # SupportedHashRocketStyles: key, separator, table
38
+ # SupportedColonStyles: key, separator, table
39
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
40
+ Layout/HashAlignment:
41
+ Exclude:
42
+ - 'spec/labkit/context_spec.rb'
43
+
44
+ # Offense count: 1
45
+ Lint/BinaryOperatorWithIdenticalOperands:
46
+ Exclude:
47
+ - 'spec/labkit/tracing/redis/redis_interceptor_helper_spec.rb'
48
+
49
+ # Offense count: 4
50
+ Lint/ConstantDefinitionInBlock:
51
+ Exclude:
52
+ - 'spec/labkit/middleware/sidekiq/client_spec.rb'
53
+ - 'spec/labkit/middleware/sidekiq/context/client_spec.rb'
54
+ - 'spec/labkit/middleware/sidekiq/context/server_spec.rb'
55
+ - 'spec/labkit/middleware/sidekiq/server_spec.rb'
56
+
57
+ # Offense count: 1
58
+ # Cop supports --auto-correct.
59
+ # Configuration parameters: AllowedMethods.
60
+ # AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal?
61
+ Lint/RedundantSafeNavigation:
62
+ Exclude:
63
+ - 'lib/labkit/tracing.rb'
64
+
65
+ # Offense count: 1
66
+ # Cop supports --auto-correct.
67
+ # Configuration parameters: PreferredName.
68
+ Naming/RescuedExceptionsVariableName:
69
+ Exclude:
70
+ - 'lib/labkit/logging/grpc/server_interceptor.rb'
71
+
72
+ # Offense count: 2
73
+ Performance/MethodObjectAsBlock:
74
+ Exclude:
75
+ - 'lib/labkit/context.rb'
76
+
77
+ # Offense count: 1
78
+ # Configuration parameters: Prefixes.
79
+ # Prefixes: when, with, without
80
+ RSpec/ContextWording:
81
+ Exclude:
82
+ - 'spec/labkit/middleware/sidekiq/server_spec.rb'
83
+
84
+ # Offense count: 3
85
+ # Cop supports --auto-correct.
86
+ # Configuration parameters: SkipBlocks, EnforcedStyle.
87
+ # SupportedStyles: described_class, explicit
88
+ RSpec/DescribedClass:
89
+ Exclude:
90
+ - 'spec/labkit/tracing_spec.rb'
91
+
92
+ # Offense count: 2
93
+ # Configuration parameters: CustomTransform, IgnoreMethods, SpecSuffixOnly.
94
+ RSpec/FilePath:
95
+ Exclude:
96
+ - 'spec/labkit/httpclient_publisher_spec.rb'
97
+ - 'spec/logging/sanitizer_spec.rb'
98
+
99
+ # Offense count: 3
100
+ # Cop supports --auto-correct.
101
+ # Configuration parameters: EnforcedStyle.
102
+ # SupportedStyles: single_line_only, single_statement_only, disallow
103
+ RSpec/ImplicitSubject:
104
+ Exclude:
105
+ - 'spec/labkit/correlation/correlation_id_spec.rb'
106
+
107
+ # Offense count: 4
108
+ RSpec/LeakyConstantDeclaration:
109
+ Exclude:
110
+ - 'spec/labkit/middleware/sidekiq/client_spec.rb'
111
+ - 'spec/labkit/middleware/sidekiq/context/client_spec.rb'
112
+ - 'spec/labkit/middleware/sidekiq/context/server_spec.rb'
113
+ - 'spec/labkit/middleware/sidekiq/server_spec.rb'
114
+
115
+ # Offense count: 2
116
+ # Cop supports --auto-correct.
117
+ RSpec/LetBeforeExamples:
118
+ Exclude:
119
+ - 'spec/labkit/tracing_spec.rb'
120
+
121
+ # Offense count: 18
122
+ # Configuration parameters: AllowSubject.
123
+ RSpec/MultipleMemoizedHelpers:
124
+ Max: 7
125
+
126
+ # Offense count: 15
127
+ # Cop supports --auto-correct.
128
+ RSpec/ScatteredLet:
129
+ Exclude:
130
+ - 'spec/labkit/excon_publisher_spec.rb'
131
+ - 'spec/labkit/httpclient_publisher_spec.rb'
132
+ - 'spec/labkit/net_http_publisher_spec.rb'
133
+
134
+ # Offense count: 1
135
+ # Cop supports --auto-correct.
136
+ Rails/NegateInclude:
137
+ Exclude:
138
+ - 'spec/labkit/correlation/grpc/client_interceptor_spec.rb'
139
+
140
+ # Offense count: 3
141
+ # Cop supports --auto-correct.
142
+ # Configuration parameters: Include.
143
+ # Include: **/Rakefile, **/*.rake
144
+ Rails/RakeEnvironment:
145
+ Exclude:
146
+ - 'lib/capistrano/tasks/**/*.rake'
147
+ - 'Rakefile'
148
+
149
+ # Offense count: 1
150
+ # Configuration parameters: AllowedChars.
151
+ Style/AsciiComments:
152
+ Exclude:
153
+ - 'spec/support/grpc_service/test_service_impl.rb'
154
+
155
+ # Offense count: 1
156
+ # Cop supports --auto-correct.
157
+ Style/CaseLikeIf:
158
+ Exclude:
159
+ - 'lib/labkit/excon_publisher.rb'
160
+
161
+ # Offense count: 23
162
+ # Cop supports --auto-correct.
163
+ Style/ExplicitBlockArgument:
164
+ Exclude:
165
+ - 'lib/labkit/correlation/grpc/server_interceptor.rb'
166
+ - 'lib/labkit/logging/grpc/server_interceptor.rb'
167
+ - 'lib/labkit/middleware/sidekiq/client.rb'
168
+ - 'lib/labkit/middleware/sidekiq/context/server.rb'
169
+ - 'lib/labkit/middleware/sidekiq/server.rb'
170
+ - 'lib/labkit/middleware/sidekiq/tracing/server.rb'
171
+ - 'lib/labkit/tracing/grpc/client_interceptor.rb'
172
+ - 'lib/labkit/tracing/grpc/server_interceptor.rb'
173
+ - 'lib/labkit/tracing/redis/redis_interceptor_helper.rb'
174
+
175
+ # Offense count: 8
176
+ # Cop supports --auto-correct.
177
+ # Configuration parameters: EnforcedStyle.
178
+ # SupportedStyles: always, always_true, never
179
+ Style/FrozenStringLiteralComment:
180
+ Exclude:
181
+ - 'spec/labkit/tracing/rails/active_record/sql_instrumenter_spec.rb'
182
+ - 'spec/labkit/tracing/rails/active_support/cache_delete_instrumenter_spec.rb'
183
+ - 'spec/labkit/tracing/rails/active_support/cache_fetch_hit_instrumenter_spec.rb'
184
+ - 'spec/labkit/tracing/rails/active_support/cache_generate_instrumenter_spec.rb'
185
+ - 'spec/labkit/tracing/rails/active_support/cache_read_instrumenter_spec.rb'
186
+ - 'spec/labkit/tracing/rails/active_support/cache_write_instrumenter_spec.rb'
187
+ - 'spec/support/grpc_service/test_pb.rb'
188
+ - 'tools/update-changelog.rb'
189
+
190
+ # Offense count: 2
191
+ # Cop supports --auto-correct.
192
+ Style/GlobalStdStream:
193
+ Exclude:
194
+ - 'lib/labkit/tracing/jaeger_factory.rb'
195
+
196
+ # Offense count: 3
197
+ # Cop supports --auto-correct.
198
+ # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols.
199
+ # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys
200
+ Style/HashSyntax:
201
+ Exclude:
202
+ - 'spec/labkit/excon_publisher_spec.rb'
203
+
204
+ # Offense count: 16
205
+ # Cop supports --auto-correct.
206
+ # Configuration parameters: PreferredDelimiters.
207
+ Style/PercentLiteralDelimiters:
208
+ Exclude:
209
+ - 'spec/labkit/tracing/redis/redis_interceptor_helper_spec.rb'
210
+
211
+ # Offense count: 2
212
+ # Cop supports --auto-correct.
213
+ Style/RedundantBegin:
214
+ Exclude:
215
+ - 'Rakefile'
216
+ - 'spec/labkit/net_http_publisher_spec.rb'
217
+
218
+ # Offense count: 1
219
+ # Cop supports --auto-correct.
220
+ Style/RedundantRegexpEscape:
221
+ Exclude:
222
+ - 'lib/labkit/logging/sanitizer.rb'
223
+
224
+ # Offense count: 1
225
+ # Cop supports --auto-correct.
226
+ Style/StringConcatenation:
227
+ Exclude:
228
+ - 'lib/labkit/tracing/redis/redis_interceptor_helper.rb'
229
+
230
+ # Offense count: 28
231
+ # Cop supports --auto-correct.
232
+ # Configuration parameters: EnforcedStyleForMultiline.
233
+ # SupportedStylesForMultiline: comma, consistent_comma, no_comma
234
+ Style/TrailingCommaInArrayLiteral:
235
+ Exclude:
236
+ - 'spec/labkit/excon_publisher_spec.rb'
237
+ - 'spec/labkit/httpclient_publisher_spec.rb'
238
+ - 'spec/labkit/net_http_publisher_spec.rb'
data/Rakefile CHANGED
@@ -3,13 +3,13 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rufo"
5
5
 
6
- begin
7
- require "rspec/core/rake_task"
8
- RSpec::Core::RakeTask.new(:spec)
9
- end
6
+ require "rspec/core/rake_task"
7
+ RSpec::Core::RakeTask.new(:spec)
10
8
 
11
9
  require "rubocop/rake_task"
12
- RuboCop::RakeTask.new
10
+ RuboCop::RakeTask.new(:rubocop) do |task|
11
+ task.options = %w[--parallel]
12
+ end
13
13
 
14
14
  desc "Alias for `rake rufo:run`"
15
15
  task :format => ["rufo:run"]
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec|tools)/}) }
18
18
  spec.require_paths = ["lib"]
19
- spec.required_ruby_version = ">= 2.4.0"
19
+ spec.required_ruby_version = ">= 2.6.0"
20
20
 
21
21
  # Please maintain alphabetical order for dependencies
22
22
  spec.add_runtime_dependency "actionpack", ">= 5.0.0", "< 7.0.0"
@@ -24,12 +24,13 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency "grpc", "~> 1.19" # Be sure to update the "grpc-tools" dev_depenency too
25
25
  spec.add_runtime_dependency "jaeger-client", "~> 1.1"
26
26
  spec.add_runtime_dependency "opentracing", "~> 0.4"
27
- spec.add_runtime_dependency "pg_query", "~> 1.3"
27
+ spec.add_runtime_dependency "pg_query", "~> 2.1"
28
28
  spec.add_runtime_dependency "redis", ">3.0.0", "<5.0.0"
29
29
 
30
30
  # Please maintain alphabetical order for dev dependencies
31
31
  spec.add_development_dependency "excon", "~> 0.78.1"
32
32
  spec.add_development_dependency "faraday", "~> 1.2.0"
33
+ spec.add_development_dependency "gitlab-styles", "~> 6.2.0"
33
34
  spec.add_development_dependency "grpc-tools", "~> 1.19"
34
35
  spec.add_development_dependency "httparty", "~> 0.17.3"
35
36
  spec.add_development_dependency "httpclient", "~> 2.8.3"
@@ -37,10 +38,9 @@ Gem::Specification.new do |spec|
37
38
  spec.add_development_dependency "rack", "~> 2.0"
38
39
  spec.add_development_dependency "rake", "~> 12.3"
39
40
  spec.add_development_dependency "rest-client", "~> 2.1.0"
40
- spec.add_development_dependency "rspec", "~> 3.8.0"
41
+ spec.add_development_dependency "rspec", "~> 3.10.0"
41
42
  spec.add_development_dependency "rspec-parameterized", "~> 0.4"
42
- spec.add_development_dependency "rubocop", "~> 0.65.0"
43
- spec.add_development_dependency "rubocop-rspec", "~> 1.22.1"
44
43
  spec.add_development_dependency "rufo", "0.9.0"
45
44
  spec.add_development_dependency "sidekiq", "~> 5.2.7"
45
+ spec.add_development_dependency "webrick", "~> 1.7.0"
46
46
  end
data/lib/gitlab-labkit.rb CHANGED
@@ -1,8 +1,6 @@
1
1
  # rubocop:disable Naming/FileName
2
2
  # frozen_string_literal: true
3
3
 
4
- require "active_support/all"
5
-
6
4
  # LabKit is a module for handling cross-project
7
5
  # infrastructural concerns, partcularly related to
8
6
  # observability.
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "securerandom"
4
+
5
+ require "active_support/core_ext/module/delegation"
6
+ require "active_support/core_ext/string/starts_ends_with"
7
+ require "active_support/core_ext/string/inflections"
8
+
3
9
  module Labkit
4
10
  # A context can be used to provide structured information on what resources
5
11
  # GitLab is working on within a service.
@@ -2,9 +2,8 @@
2
2
 
3
3
  # Disable the UnusedMethodArgument linter, since we need to declare the kwargs
4
4
  # in the methods, but we don't actually use them.
5
- # rubocop:disable Lint/UnusedMethodArgument
6
-
7
5
  require "grpc"
6
+ require "singleton"
8
7
 
9
8
  module Labkit
10
9
  module Correlation
@@ -48,5 +47,3 @@ module Labkit
48
47
  end
49
48
  end
50
49
  end
51
-
52
- # rubocop:enable Lint/UnusedMethodArgument
@@ -2,7 +2,6 @@
2
2
 
3
3
  # Disable the UnusedMethodArgument linter, since we need to declare the kwargs
4
4
  # in the methods, but we don't actually use them.
5
- # rubocop:disable Lint/UnusedMethodArgument
6
5
 
7
6
  require "grpc"
8
7
 
@@ -51,5 +50,3 @@ module Labkit
51
50
  end
52
51
  end
53
52
  end
54
-
55
- # rubocop:enable Lint/UnusedMethodArgument
@@ -99,10 +99,12 @@ module Labkit
99
99
  query: generate_query_string(datum[:query]),
100
100
  start_time: ::Labkit::System.monotonic_time,
101
101
  }
102
+
102
103
  unless datum[:proxy].nil?
103
104
  payload[:proxy_host] = datum[:proxy][:host]
104
105
  payload[:proxy_port] = datum[:proxy][:port]
105
106
  end
107
+
106
108
  payload
107
109
  end
108
110
 
@@ -133,7 +135,7 @@ module Labkit
133
135
 
134
136
  def nil_or_int(int)
135
137
  int&.to_i
136
- rescue
138
+ rescue StandardError
137
139
  nil
138
140
  end
139
141
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support/time_with_zone"
4
+ require "active_support/values/time_zone"
3
5
  require "grpc"
4
6
  require "json"
5
7
 
@@ -19,9 +19,7 @@ module Labkit
19
19
 
20
20
  def self.sanitize_field(content)
21
21
  content = content.gsub(URL_REGEXP) { |url| mask_url(url) }
22
- content = content.gsub(SCP_URL_REGEXP) { |scp_url| mask_scp_url(scp_url) }
23
-
24
- content
22
+ content.gsub(SCP_URL_REGEXP) { |scp_url| mask_scp_url(scp_url) }
25
23
  end
26
24
 
27
25
  def self.sanitize_sql(sql)
@@ -30,6 +28,12 @@ module Labkit
30
28
  ""
31
29
  end
32
30
 
31
+ def self.sql_fingerprint(normalized_sql)
32
+ PgQuery.parse(normalized_sql)&.fingerprint
33
+ rescue PgQuery::ParseError
34
+ ""
35
+ end
36
+
33
37
  # Ensures that URLS are sanitized to hide credentials
34
38
  def self.mask_url(url)
35
39
  url = url.to_s.strip
@@ -8,7 +8,8 @@ module Labkit
8
8
  # reinstantiate a context in which the job will run.
9
9
  class Server
10
10
  def call(_worker_class, job, _queue)
11
- data = job.merge(Labkit::Context.log_key(:caller_id) => job["class"])
11
+ worker_name = (job["wrapped"].presence || job["class"]).to_s
12
+ data = job.merge(Labkit::Context.log_key(:caller_id) => worker_name)
12
13
 
13
14
  Labkit::Context.with_context(data) do |_context|
14
15
  yield
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/all"
4
-
5
3
  module Labkit
6
4
  # Tracing provides distributed tracing functionality
7
5
  module Tracing
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "opentracing"
4
- require "active_support/all"
5
4
 
6
5
  module Labkit
7
6
  module Tracing
@@ -21,10 +21,12 @@ module Labkit
21
21
  "path" => payload[:path],
22
22
  "scheme" => payload[:scheme],
23
23
  }
24
+
24
25
  unless payload[:proxy_host].nil?
25
26
  tags["proxy_host"] = payload[:proxy_host]
26
27
  tags["proxy_port"] = payload[:proxy_port]
27
28
  end
29
+
28
30
  tags
29
31
  end
30
32
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  # Disable the UnusedMethodArgument linter, since we need to declare the kwargs
4
4
  # in the methods, but we don't actually use them.
5
- # rubocop:disable Lint/UnusedMethodArgument
6
5
  require "opentracing"
7
6
  require "grpc"
7
+ require "singleton"
8
8
 
9
9
  module Labkit
10
10
  module Tracing
@@ -45,5 +45,3 @@ module Labkit
45
45
  end
46
46
  end
47
47
  end
48
-
49
- # rubocop:enable Lint/UnusedMethodArgument
@@ -2,7 +2,6 @@
2
2
 
3
3
  # Disable the UnusedMethodArgument linter, since we need to declare the kwargs
4
4
  # in the methods, but we don't actually use them.
5
- # rubocop:disable Lint/UnusedMethodArgument
6
5
 
7
6
  require "opentracing"
8
7
  require "grpc"
@@ -60,5 +59,3 @@ module Labkit
60
59
  end
61
60
  end
62
61
  end
63
-
64
- # rubocop:enable Lint/UnusedMethodArgument
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "opentracing"
4
- require "active_support/all"
5
4
  require "action_dispatch"
6
5
 
7
6
  module Labkit
@@ -14,7 +14,11 @@ module Labkit
14
14
  end
15
15
 
16
16
  def tags(payload)
17
- sql = Labkit::Logging::Sanitizer.sanitize_sql(payload[:sql]) if Labkit::Tracing.sampled? && payload[:sql]
17
+ if Labkit::Tracing.sampled? && payload[:sql]
18
+ sql = Labkit::Logging::Sanitizer.sanitize_sql(payload[:sql])
19
+ fingerprint = Labkit::Logging::Sanitizer.sql_fingerprint(sql)
20
+ end
21
+
18
22
  {
19
23
  "component" => COMPONENT_TAG,
20
24
  "span.kind" => "client",
@@ -22,6 +26,7 @@ module Labkit
22
26
  "db.connection_id" => payload[:connection_id],
23
27
  "db.cached" => payload[:cached] || false,
24
28
  "db.statement" => sql,
29
+ "db.statement_fingerprint" => fingerprint,
25
30
  }
26
31
  end
27
32
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "active_support/all"
3
+ require "active_support/concern"
4
+ require "active_support/notifications"
4
5
 
5
6
  module Labkit
6
7
  module Tracing
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support/core_ext/string/starts_ends_with"
3
4
  require "opentracing"
4
5
 
5
6
  module Labkit
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-labkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Newdigate
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-04 00:00:00.000000000 Z
11
+ date: 2021-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -98,14 +98,14 @@ dependencies:
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '1.3'
101
+ version: '2.1'
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: '1.3'
108
+ version: '2.1'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: redis
111
111
  requirement: !ruby/object:Gem::Requirement
@@ -154,6 +154,20 @@ dependencies:
154
154
  - - "~>"
155
155
  - !ruby/object:Gem::Version
156
156
  version: 1.2.0
157
+ - !ruby/object:Gem::Dependency
158
+ name: gitlab-styles
159
+ requirement: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - "~>"
162
+ - !ruby/object:Gem::Version
163
+ version: 6.2.0
164
+ type: :development
165
+ prerelease: false
166
+ version_requirements: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - "~>"
169
+ - !ruby/object:Gem::Version
170
+ version: 6.2.0
157
171
  - !ruby/object:Gem::Dependency
158
172
  name: grpc-tools
159
173
  requirement: !ruby/object:Gem::Requirement
@@ -258,14 +272,14 @@ dependencies:
258
272
  requirements:
259
273
  - - "~>"
260
274
  - !ruby/object:Gem::Version
261
- version: 3.8.0
275
+ version: 3.10.0
262
276
  type: :development
263
277
  prerelease: false
264
278
  version_requirements: !ruby/object:Gem::Requirement
265
279
  requirements:
266
280
  - - "~>"
267
281
  - !ruby/object:Gem::Version
268
- version: 3.8.0
282
+ version: 3.10.0
269
283
  - !ruby/object:Gem::Dependency
270
284
  name: rspec-parameterized
271
285
  requirement: !ruby/object:Gem::Requirement
@@ -281,61 +295,47 @@ dependencies:
281
295
  - !ruby/object:Gem::Version
282
296
  version: '0.4'
283
297
  - !ruby/object:Gem::Dependency
284
- name: rubocop
298
+ name: rufo
285
299
  requirement: !ruby/object:Gem::Requirement
286
300
  requirements:
287
- - - "~>"
301
+ - - '='
288
302
  - !ruby/object:Gem::Version
289
- version: 0.65.0
303
+ version: 0.9.0
290
304
  type: :development
291
305
  prerelease: false
292
306
  version_requirements: !ruby/object:Gem::Requirement
293
307
  requirements:
294
- - - "~>"
308
+ - - '='
295
309
  - !ruby/object:Gem::Version
296
- version: 0.65.0
310
+ version: 0.9.0
297
311
  - !ruby/object:Gem::Dependency
298
- name: rubocop-rspec
312
+ name: sidekiq
299
313
  requirement: !ruby/object:Gem::Requirement
300
314
  requirements:
301
315
  - - "~>"
302
316
  - !ruby/object:Gem::Version
303
- version: 1.22.1
317
+ version: 5.2.7
304
318
  type: :development
305
319
  prerelease: false
306
320
  version_requirements: !ruby/object:Gem::Requirement
307
321
  requirements:
308
322
  - - "~>"
309
323
  - !ruby/object:Gem::Version
310
- version: 1.22.1
311
- - !ruby/object:Gem::Dependency
312
- name: rufo
313
- requirement: !ruby/object:Gem::Requirement
314
- requirements:
315
- - - '='
316
- - !ruby/object:Gem::Version
317
- version: 0.9.0
318
- type: :development
319
- prerelease: false
320
- version_requirements: !ruby/object:Gem::Requirement
321
- requirements:
322
- - - '='
323
- - !ruby/object:Gem::Version
324
- version: 0.9.0
324
+ version: 5.2.7
325
325
  - !ruby/object:Gem::Dependency
326
- name: sidekiq
326
+ name: webrick
327
327
  requirement: !ruby/object:Gem::Requirement
328
328
  requirements:
329
329
  - - "~>"
330
330
  - !ruby/object:Gem::Version
331
- version: 5.2.7
331
+ version: 1.7.0
332
332
  type: :development
333
333
  prerelease: false
334
334
  version_requirements: !ruby/object:Gem::Requirement
335
335
  requirements:
336
336
  - - "~>"
337
337
  - !ruby/object:Gem::Version
338
- version: 5.2.7
338
+ version: 1.7.0
339
339
  description:
340
340
  email:
341
341
  - andrew@gitlab.com
@@ -348,6 +348,7 @@ files:
348
348
  - ".gitlab/CODEOWNERS"
349
349
  - ".rspec"
350
350
  - ".rubocop.yml"
351
+ - ".rubocop_todo.yml"
351
352
  - ".ruby-version"
352
353
  - ".rufo"
353
354
  - Gemfile
@@ -428,14 +429,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
428
429
  requirements:
429
430
  - - ">="
430
431
  - !ruby/object:Gem::Version
431
- version: 2.4.0
432
+ version: 2.6.0
432
433
  required_rubygems_version: !ruby/object:Gem::Requirement
433
434
  requirements:
434
435
  - - ">="
435
436
  - !ruby/object:Gem::Version
436
437
  version: '0'
437
438
  requirements: []
438
- rubygems_version: 3.0.3
439
+ rubygems_version: 3.1.6
439
440
  signing_key:
440
441
  specification_version: 4
441
442
  summary: Instrumentation for GitLab