gitlab-labkit 0.14.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +8 -3
- data/.rubocop.yml +13 -127
- data/.rubocop_todo.yml +238 -0
- data/Rakefile +3 -1
- data/gitlab-labkit.gemspec +4 -5
- data/lib/gitlab-labkit.rb +0 -2
- data/lib/labkit/context.rb +15 -2
- data/lib/labkit/correlation/grpc/client_interceptor.rb +1 -4
- data/lib/labkit/correlation/grpc/server_interceptor.rb +0 -3
- data/lib/labkit/excon_publisher.rb +25 -5
- data/lib/labkit/logging/grpc/server_interceptor.rb +7 -0
- data/lib/labkit/logging/sanitizer.rb +1 -3
- data/lib/labkit/middleware/sidekiq/context/server.rb +2 -1
- data/lib/labkit/tracing.rb +0 -2
- data/lib/labkit/tracing/abstract_instrumenter.rb +0 -1
- data/lib/labkit/tracing/external_http/request_instrumenter.rb +2 -0
- data/lib/labkit/tracing/grpc/client_interceptor.rb +1 -3
- data/lib/labkit/tracing/grpc/server_interceptor.rb +0 -3
- data/lib/labkit/tracing/rack_middleware.rb +0 -1
- data/lib/labkit/tracing/tracing_common.rb +2 -1
- data/lib/labkit/tracing/tracing_utils.rb +1 -0
- metadata +33 -46
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 235f0b00e0d08d7ee809ae43736e0ce5c900c0c75d402028bfb1247df868f9ac
|
|
4
|
+
data.tar.gz: 759c4d7bd91c75aeb7bc2b737f55558c6426b32940a399cca982efebb7b1740f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 42c83bbcdcb9c588a703400bd5d1830e426680e9d433a223026566d1417a7eb8000dec99530e2e9887935686938e6e2128c8953f44540ead950447c3a3d2b564
|
|
7
|
+
data.tar.gz: 9cd740e3bd04db453cf812b1efc71a6d5b516c875cfce4cfb0837660390c8457b86679c775f2d23b1dd373b59183255268340d710215d1f1bac5864fdf03c2f6
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
2
|
-
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
|
2
|
+
|
|
3
|
+
inherit_gem:
|
|
4
|
+
gitlab-styles:
|
|
5
|
+
- rubocop-default.yml
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
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/
|
|
34
|
+
Style/Lambda:
|
|
32
35
|
Enabled: false
|
|
33
36
|
|
|
34
|
-
Layout/
|
|
35
|
-
Enabled:
|
|
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
|
-
|
|
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
|
-
|
|
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
data/gitlab-labkit.gemspec
CHANGED
|
@@ -16,20 +16,21 @@ 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.
|
|
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"
|
|
23
23
|
spec.add_runtime_dependency "activesupport", ">= 5.0.0", "< 7.0.0"
|
|
24
|
-
spec.add_runtime_dependency "gitlab-pg_query", "~> 1.3"
|
|
25
24
|
spec.add_runtime_dependency "grpc", "~> 1.19" # Be sure to update the "grpc-tools" dev_depenency too
|
|
26
25
|
spec.add_runtime_dependency "jaeger-client", "~> 1.1"
|
|
27
26
|
spec.add_runtime_dependency "opentracing", "~> 0.4"
|
|
27
|
+
spec.add_runtime_dependency "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.
|
|
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
data/lib/labkit/context.rb
CHANGED
|
@@ -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
|
|
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
|
|
@@ -92,17 +92,19 @@ module Labkit
|
|
|
92
92
|
def start_payload(datum)
|
|
93
93
|
payload = {
|
|
94
94
|
method: datum[:method].to_s.upcase,
|
|
95
|
-
host: datum[:host],
|
|
96
|
-
path: datum[:path],
|
|
97
|
-
port: datum[:port],
|
|
98
|
-
scheme: datum[:scheme],
|
|
99
|
-
query: datum[:query],
|
|
95
|
+
host: nil_or_string(datum[:host]),
|
|
96
|
+
path: nil_or_string(datum[:path]),
|
|
97
|
+
port: nil_or_int(datum[:port]),
|
|
98
|
+
scheme: nil_or_string(datum[:scheme]),
|
|
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
|
|
|
@@ -126,5 +128,23 @@ module Labkit
|
|
|
126
128
|
def remove_connection_payload(datum)
|
|
127
129
|
connection_payload.delete(datum[:connection])
|
|
128
130
|
end
|
|
131
|
+
|
|
132
|
+
def nil_or_string(str)
|
|
133
|
+
str&.to_s
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
def nil_or_int(int)
|
|
137
|
+
int&.to_i
|
|
138
|
+
rescue StandardError
|
|
139
|
+
nil
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def generate_query_string(query)
|
|
143
|
+
if query.is_a?(Hash)
|
|
144
|
+
query.to_query
|
|
145
|
+
else
|
|
146
|
+
nil_or_string(query)
|
|
147
|
+
end
|
|
148
|
+
end
|
|
129
149
|
end
|
|
130
150
|
end
|
|
@@ -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,6 +79,11 @@ module Labkit
|
|
|
77
79
|
time: Time.now.utc.strftime("%Y-%m-%dT%H:%M:%S.%LZ"),
|
|
78
80
|
)
|
|
79
81
|
|
|
82
|
+
if ex
|
|
83
|
+
message["exception"] = ex.message
|
|
84
|
+
message["exception_backtrace"] = ex.backtrace[0..5] if ex.backtrace
|
|
85
|
+
end
|
|
86
|
+
|
|
80
87
|
@log_file.puts(JSON.dump(message))
|
|
81
88
|
end
|
|
82
89
|
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
|
|
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
|
-
|
|
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
|
data/lib/labkit/tracing.rb
CHANGED
|
@@ -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
|
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.
|
|
4
|
+
version: 0.17.1
|
|
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-
|
|
11
|
+
date: 2021-04-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: actionpack
|
|
@@ -51,61 +51,61 @@ dependencies:
|
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
52
|
version: 7.0.0
|
|
53
53
|
- !ruby/object:Gem::Dependency
|
|
54
|
-
name:
|
|
54
|
+
name: grpc
|
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
|
57
57
|
- - "~>"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '1.
|
|
59
|
+
version: '1.19'
|
|
60
60
|
type: :runtime
|
|
61
61
|
prerelease: false
|
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements:
|
|
64
64
|
- - "~>"
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: '1.
|
|
66
|
+
version: '1.19'
|
|
67
67
|
- !ruby/object:Gem::Dependency
|
|
68
|
-
name:
|
|
68
|
+
name: jaeger-client
|
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
|
71
71
|
- - "~>"
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: '1.
|
|
73
|
+
version: '1.1'
|
|
74
74
|
type: :runtime
|
|
75
75
|
prerelease: false
|
|
76
76
|
version_requirements: !ruby/object:Gem::Requirement
|
|
77
77
|
requirements:
|
|
78
78
|
- - "~>"
|
|
79
79
|
- !ruby/object:Gem::Version
|
|
80
|
-
version: '1.
|
|
80
|
+
version: '1.1'
|
|
81
81
|
- !ruby/object:Gem::Dependency
|
|
82
|
-
name:
|
|
82
|
+
name: opentracing
|
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
|
84
84
|
requirements:
|
|
85
85
|
- - "~>"
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '
|
|
87
|
+
version: '0.4'
|
|
88
88
|
type: :runtime
|
|
89
89
|
prerelease: false
|
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
|
91
91
|
requirements:
|
|
92
92
|
- - "~>"
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '
|
|
94
|
+
version: '0.4'
|
|
95
95
|
- !ruby/object:Gem::Dependency
|
|
96
|
-
name:
|
|
96
|
+
name: pg_query
|
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
|
99
99
|
- - "~>"
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '0
|
|
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: '0
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
425
|
+
rubygems_version: 3.1.6
|
|
439
426
|
signing_key:
|
|
440
427
|
specification_version: 4
|
|
441
428
|
summary: Instrumentation for GitLab
|