sidekiq-instrumentation 1.2.0.pre2 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -2
- data/Gemfile.lock +2 -2
- data/lib/sidekiq/tracer.rb +7 -7
- data/lib/sidekiq/tracer/server_middleware.rb +20 -19
- data/lib/sidekiq/tracer/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efa08e01af2293de61c9273900ad7f1fce8202b5ab7a7f3f1c36a53283bbeeaa
|
4
|
+
data.tar.gz: 872499d82c73764390ce913edbadaf6480c40b5d0baeb8c298644c0a4550d8f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 030a00859186218ca81ebb9072f700f87fe77d0a7b03b0d4d7c702c5a62168848d6a9fb0153653082be93cdc55dfa903dede74062f4266d09508316107ac168d
|
7
|
+
data.tar.gz: df571ab4bba110d64fd267819c3eaecc6d30b02337e94433cacbdbcf8f89ddd722254bc8c9917a064494a21a3e0d23455d20830324f26077ed5379e1bbf8df0e
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
|
2
2
|
Changelog
|
3
3
|
=========
|
4
|
-
|
4
|
+
|
5
|
+
## 1.2.2 09/08/2020
|
6
|
+
* Add optional after_trace hook to ClientMiddleware
|
7
|
+
|
8
|
+
## 1.2.1 07/09/2020
|
9
|
+
* Ensure child spans are nested under the root Sidekiq span in the trace
|
10
|
+
|
11
|
+
## 1.2.0 05/28/2020
|
5
12
|
* Ignore active scope in consumers
|
6
13
|
|
7
14
|
## 1.1.0 05/27/2020
|
8
15
|
* Set up build pipeline with circleci and gem-publisher
|
9
16
|
* Fixed linting issues
|
10
|
-
* Renamed gem to `sidekiq-instrumentation`
|
17
|
+
* Renamed gem to `sidekiq-instrumentation`
|
data/Gemfile.lock
CHANGED
data/lib/sidekiq/tracer.rb
CHANGED
@@ -11,9 +11,9 @@ require "sidekiq/tracer/server_middleware"
|
|
11
11
|
module Sidekiq
|
12
12
|
module Tracer
|
13
13
|
class << self
|
14
|
-
def instrument(tracer: OpenTracing.global_tracer, active_span: nil)
|
14
|
+
def instrument(tracer: OpenTracing.global_tracer, active_span: nil, after_trace: nil)
|
15
15
|
instrument_client(tracer: tracer, active_span: active_span)
|
16
|
-
instrument_server(tracer: tracer, active_span: active_span)
|
16
|
+
instrument_server(tracer: tracer, active_span: active_span, after_trace: after_trace)
|
17
17
|
end
|
18
18
|
|
19
19
|
def instrument_client(tracer: OpenTracing.global_tracer, active_span: nil)
|
@@ -22,23 +22,23 @@ module Sidekiq
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def instrument_server(tracer: OpenTracing.global_tracer, active_span: nil)
|
25
|
+
def instrument_server(tracer: OpenTracing.global_tracer, active_span: nil, after_trace: nil)
|
26
26
|
Sidekiq.configure_server do |config|
|
27
27
|
config.client_middleware { |chain| add_client_middleware(chain, tracer, active_span) }
|
28
|
-
config.server_middleware { |chain| add_server_middleware(chain, tracer, active_span) }
|
28
|
+
config.server_middleware { |chain| add_server_middleware(chain, tracer, active_span, after_trace) }
|
29
29
|
end
|
30
30
|
|
31
31
|
return unless defined?(Sidekiq::Testing)
|
32
32
|
|
33
|
-
Sidekiq::Testing.server_middleware { |chain| add_server_middleware(chain, tracer, active_span) }
|
33
|
+
Sidekiq::Testing.server_middleware { |chain| add_server_middleware(chain, tracer, active_span, after_trace) }
|
34
34
|
end
|
35
35
|
|
36
36
|
def add_client_middleware(chain, tracer, active_span)
|
37
37
|
chain.add Sidekiq::Tracer::ClientMiddleware, tracer: tracer, active_span: active_span
|
38
38
|
end
|
39
39
|
|
40
|
-
def add_server_middleware(chain, tracer, active_span)
|
41
|
-
chain.add Sidekiq::Tracer::ServerMiddleware, tracer: tracer, active_span: active_span
|
40
|
+
def add_server_middleware(chain, tracer, active_span, after_trace)
|
41
|
+
chain.add Sidekiq::Tracer::ServerMiddleware, tracer: tracer, active_span: active_span, after_trace: after_trace
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -5,36 +5,37 @@ module Sidekiq
|
|
5
5
|
class ServerMiddleware
|
6
6
|
include Commons
|
7
7
|
|
8
|
-
attr_reader :tracer, :active_span
|
8
|
+
attr_reader :tracer, :active_span, :after_trace
|
9
9
|
|
10
|
-
def initialize(tracer:, active_span:)
|
10
|
+
def initialize(tracer:, active_span:, after_trace:)
|
11
11
|
@tracer = tracer
|
12
12
|
@active_span = active_span
|
13
|
+
@after_trace = after_trace
|
13
14
|
end
|
14
15
|
|
16
|
+
# rubocop:disable Metrics/MethodLength
|
15
17
|
def call(_worker, job, _queue)
|
16
|
-
span = build_span(job)
|
17
|
-
|
18
|
-
yield
|
19
|
-
rescue StandardError => e
|
20
|
-
tag_errors(span, e) if span
|
21
|
-
raise
|
22
|
-
ensure
|
23
|
-
span&.finish
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def build_span(job)
|
29
18
|
parent_span_context = extract(job)
|
30
19
|
|
31
20
|
follows_from = OpenTracing::Reference.follows_from(parent_span_context)
|
32
21
|
|
33
|
-
tracer.
|
34
|
-
|
35
|
-
|
36
|
-
|
22
|
+
tracer.start_active_span(operation_name(job),
|
23
|
+
references: [follows_from],
|
24
|
+
ignore_active_scope: true,
|
25
|
+
tags: tags(job, "consumer")) do |scope|
|
26
|
+
begin
|
27
|
+
yield
|
28
|
+
rescue StandardError => e
|
29
|
+
tag_errors(scope.span, e) if scope.span
|
30
|
+
raise
|
31
|
+
ensure
|
32
|
+
after_trace&.call(scope.span) if scope.span
|
33
|
+
end
|
34
|
+
end
|
37
35
|
end
|
36
|
+
# rubocop:enable Metrics/MethodLength
|
37
|
+
|
38
|
+
private
|
38
39
|
|
39
40
|
def tag_errors(span, error)
|
40
41
|
span.set_tag("error", true)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-instrumentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- iaintshine
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-09-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: opentracing
|
@@ -204,9 +204,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
204
|
version: '0'
|
205
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
206
206
|
requirements:
|
207
|
-
- - "
|
207
|
+
- - ">="
|
208
208
|
- !ruby/object:Gem::Version
|
209
|
-
version:
|
209
|
+
version: '0'
|
210
210
|
requirements: []
|
211
211
|
rubygems_version: 3.1.2
|
212
212
|
signing_key:
|