gitlab-labkit 0.15.0 → 0.18.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: 26359f4fec97f64445df7d373d67cd7344e415d4b8db5adedce24d02f03228ec
4
- data.tar.gz: 11f8e6195ec18d7a3ea81b2b533609ae68f76f50f55ae32fb5b3c4b41434ebaf
3
+ metadata.gz: 2d1b3569e3032ab75917a5fccc48dc4d29a7f8bb7ce25bd94b07552693cde66f
4
+ data.tar.gz: 521050774784e77217b6ac86e9faa4c82455802b10d9a33d263849e65c91be62
5
5
  SHA512:
6
- metadata.gz: 2fb683c423ec1e34fc92b5dda0e2973b2259768a6dccf5fca9c6f3d7089d3130bf8e820ca8e751f27c325399b0739a73ae145667702f395e98e09dd58ff18fac
7
- data.tar.gz: 1dbab7f8469391b9d6105aef90d3cc0af93ac87622a49052780ce843be941f592f4174fa5bff493cf528c8e1aceef1aad0352b992215309935e6f1edbd5bacfd
6
+ metadata.gz: c7956a088be110af584ebc8f5e4979e6edd154cf8f13dc587b413afb1247feb9ed5712e5f76625bf48c800d5d36e896f58b62de909d212d4292235d02d57b9d6
7
+ data.tar.gz: 9dbc20edb7bf500cc30317c5c4f385de32cf03980907e993802850710f3d797ee05cc086e74948df4110c4a0f63a511e5c8857cb3aeb93288e9fe47acce0011e
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.
@@ -22,9 +25,11 @@ test:2.6:
22
25
  image: ruby:2.6
23
26
  <<: *test_definition
24
27
 
25
- test:2.5:
26
- image: ruby:2.5
27
- <<: *test_definition
28
+ static-analysis:
29
+ before_script:
30
+ - bundle install
31
+ script:
32
+ - rake verify
28
33
 
29
34
  deploy:
30
35
  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
@@ -9,7 +9,9 @@ begin
9
9
  end
10
10
 
11
11
  require "rubocop/rake_task"
12
- RuboCop::RakeTask.new
12
+ RuboCop::RakeTask.new(:rubocop) do |task|
13
+ task.options = %w[--parallel]
14
+ end
13
15
 
14
16
  desc "Alias for `rake rufo:run`"
15
17
  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 "gitlab-pg_query", "~> 2.0"
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,8 @@ 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"
46
45
  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,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support/core_ext/module/delegation"
4
+ require "active_support/core_ext/string/starts_ends_with"
5
+
3
6
  module Labkit
4
7
  # A context can be used to provide structured information on what resources
5
8
  # GitLab is working on within a service.
@@ -23,7 +26,7 @@ module Labkit
23
26
  RAW_KEYS = [CORRELATION_ID_KEY].freeze
24
27
  HEADER_PREFIX = "X-Gitlab-"
25
28
  KNOWN_KEYS = %w[user project root_namespace subscription_plan caller_id
26
- remote_ip related_class feature_category].freeze
29
+ remote_ip related_class feature_category client_id].freeze
27
30
 
28
31
  class << self
29
32
  def with_context(attributes = {})
@@ -106,6 +109,12 @@ module Labkit
106
109
  end
107
110
  end
108
111
 
112
+ def get_attribute(attribute)
113
+ raw = call_or_value(data[log_key(attribute)])
114
+
115
+ call_or_value(raw)
116
+ end
117
+
109
118
  protected
110
119
 
111
120
  def assign_attributes(attributes)
@@ -130,9 +139,13 @@ module Labkit
130
139
 
131
140
  attr_reader :data
132
141
 
142
+ def call_or_value(value)
143
+ value.respond_to?(:call) ? value.call : value
144
+ end
145
+
133
146
  def expand_data
134
147
  data.transform_values do |value|
135
- value = value.respond_to?(:call) ? value.call : value
148
+ value = call_or_value(value)
136
149
 
137
150
  value.presence
138
151
  end.compact
@@ -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
 
@@ -77,7 +79,10 @@ module Labkit
77
79
  time: Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%LZ"),
78
80
  )
79
81
 
80
- message["exception"] = ex.message if ex
82
+ if ex
83
+ message["exception"] = ex.message
84
+ message["exception_backtrace"] = ex.backtrace[0..5] if ex.backtrace
85
+ end
81
86
 
82
87
  @log_file.puts(JSON.dump(message))
83
88
  end
@@ -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)
@@ -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
@@ -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.15.0
4
+ version: 0.18.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-02-10 00:00:00.000000000 Z
11
+ date: 2021-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -93,19 +93,19 @@ dependencies:
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0.4'
95
95
  - !ruby/object:Gem::Dependency
96
- name: pg_query
96
+ name: gitlab-pg_query
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '1.3'
101
+ version: '2.0'
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.0'
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
@@ -280,34 +294,6 @@ dependencies:
280
294
  - - "~>"
281
295
  - !ruby/object:Gem::Version
282
296
  version: '0.4'
283
- - !ruby/object:Gem::Dependency
284
- name: rubocop
285
- requirement: !ruby/object:Gem::Requirement
286
- requirements:
287
- - - "~>"
288
- - !ruby/object:Gem::Version
289
- version: 0.65.0
290
- type: :development
291
- prerelease: false
292
- version_requirements: !ruby/object:Gem::Requirement
293
- requirements:
294
- - - "~>"
295
- - !ruby/object:Gem::Version
296
- version: 0.65.0
297
- - !ruby/object:Gem::Dependency
298
- name: rubocop-rspec
299
- requirement: !ruby/object:Gem::Requirement
300
- requirements:
301
- - - "~>"
302
- - !ruby/object:Gem::Version
303
- version: 1.22.1
304
- type: :development
305
- prerelease: false
306
- version_requirements: !ruby/object:Gem::Requirement
307
- requirements:
308
- - - "~>"
309
- - !ruby/object:Gem::Version
310
- version: 1.22.1
311
297
  - !ruby/object:Gem::Dependency
312
298
  name: rufo
313
299
  requirement: !ruby/object:Gem::Requirement
@@ -348,6 +334,7 @@ files:
348
334
  - ".gitlab/CODEOWNERS"
349
335
  - ".rspec"
350
336
  - ".rubocop.yml"
337
+ - ".rubocop_todo.yml"
351
338
  - ".ruby-version"
352
339
  - ".rufo"
353
340
  - Gemfile
@@ -428,14 +415,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
428
415
  requirements:
429
416
  - - ">="
430
417
  - !ruby/object:Gem::Version
431
- version: 2.4.0
418
+ version: 2.6.0
432
419
  required_rubygems_version: !ruby/object:Gem::Requirement
433
420
  requirements:
434
421
  - - ">="
435
422
  - !ruby/object:Gem::Version
436
423
  version: '0'
437
424
  requirements: []
438
- rubygems_version: 3.0.3
425
+ rubygems_version: 3.1.6
439
426
  signing_key:
440
427
  specification_version: 4
441
428
  summary: Instrumentation for GitLab