opentelemetry-instrumentation-sidekiq 0.12.0 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +2 -2
- data/lib/opentelemetry/instrumentation/sidekiq.rb +1 -0
- data/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb +25 -0
- data/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb +17 -2
- data/lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb +17 -2
- data/lib/opentelemetry/instrumentation/sidekiq/patches/launcher.rb +34 -0
- data/lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb +42 -0
- data/lib/opentelemetry/instrumentation/sidekiq/patches/processor.rb +34 -0
- data/lib/opentelemetry/instrumentation/sidekiq/version.rb +1 -1
- metadata +24 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06105b13c70190b459d650fff91f1f3052cb1e655cd744100aeee6475bbb5b8f
|
4
|
+
data.tar.gz: 4b7142a06febd442ac3184270c0e73562a47ec252d5b7dc829d12d9863d7009f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5efbba5397bff170c7f8c1cf8deee5d3c7ecdd9e6b2fde14e8fffe6cff0f88f777c91b5dfed4bd96895af188015d4e18a581376f7cc52851a9ec7ab22821d21
|
7
|
+
data.tar.gz: 422779d862bee296be58b695c11614bf5778648b9b009495ff9a3aea5f4b37e214f092b2a6d53072f6a89f2397dc069decc35031a4a18c55ce7fcd4690e20775
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-sidekiq
|
2
2
|
|
3
|
+
### v0.13.0 / 2021-01-29
|
4
|
+
|
5
|
+
* ADDED: Instrument sidekiq background work
|
6
|
+
* FIXED: Adjust Sidekiq middlewares to match semantic conventions
|
7
|
+
* FIXED: Set minimum compatible version and use untraced helper
|
8
|
+
|
3
9
|
### v0.12.0 / 2020-12-24
|
4
10
|
|
5
11
|
* (No significant changes)
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ end
|
|
31
31
|
```
|
32
32
|
## Examples
|
33
33
|
|
34
|
-
Example usage can be seen in the `./example/sidekiq.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/
|
34
|
+
Example usage can be seen in the `./example/sidekiq.rb` file [here](https://github.com/open-telemetry/opentelemetry-ruby/blob/main/instrumentation/sidekiq/example/sidekiq.rb)
|
35
35
|
|
36
36
|
## How can I get invovled?
|
37
37
|
|
@@ -46,7 +46,7 @@ The `opentelemetry-instrumentation-sidekiq` gem is distributed under the Apache
|
|
46
46
|
[sidekiq-home]: https://github.com/mperham/sidekiq
|
47
47
|
[bundler-home]: https://bundler.io
|
48
48
|
[repo-github]: https://github.com/open-telemetry/opentelemetry-ruby
|
49
|
-
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/
|
49
|
+
[license-github]: https://github.com/open-telemetry/opentelemetry-ruby/blob/main/LICENSE
|
50
50
|
[ruby-sig]: https://github.com/open-telemetry/community#ruby-sig
|
51
51
|
[community-meetings]: https://github.com/open-telemetry/community#community-meetings
|
52
52
|
[ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
|
@@ -10,21 +10,46 @@ module OpenTelemetry
|
|
10
10
|
# The Instrumentation class contains logic to detect and install the Sidekiq
|
11
11
|
# instrumentation
|
12
12
|
class Instrumentation < OpenTelemetry::Instrumentation::Base
|
13
|
+
MINIMUM_VERSION = Gem::Version.new('4.2.10')
|
14
|
+
|
13
15
|
install do |_config|
|
14
16
|
require_dependencies
|
15
17
|
add_client_middleware
|
16
18
|
add_server_middleware
|
19
|
+
patch_on_startup
|
17
20
|
end
|
18
21
|
|
19
22
|
present do
|
20
23
|
defined?(::Sidekiq)
|
21
24
|
end
|
22
25
|
|
26
|
+
compatible do
|
27
|
+
gem_version >= MINIMUM_VERSION
|
28
|
+
end
|
29
|
+
|
23
30
|
private
|
24
31
|
|
32
|
+
def gem_version
|
33
|
+
Gem.loaded_specs['sidekiq'].version
|
34
|
+
end
|
35
|
+
|
25
36
|
def require_dependencies
|
26
37
|
require_relative 'middlewares/client/tracer_middleware'
|
27
38
|
require_relative 'middlewares/server/tracer_middleware'
|
39
|
+
|
40
|
+
require_relative 'patches/processor'
|
41
|
+
require_relative 'patches/launcher'
|
42
|
+
require_relative 'patches/poller'
|
43
|
+
end
|
44
|
+
|
45
|
+
def patch_on_startup
|
46
|
+
::Sidekiq.configure_server do |config|
|
47
|
+
config.on(:startup) do
|
48
|
+
::Sidekiq::Processor.prepend(Patches::Processor)
|
49
|
+
::Sidekiq::Launcher.prepend(Patches::Launcher)
|
50
|
+
::Sidekiq::Scheduled::Poller.prepend(Patches::Poller)
|
51
|
+
end
|
52
|
+
end
|
28
53
|
end
|
29
54
|
|
30
55
|
def add_client_middleware
|
@@ -14,10 +14,13 @@ module OpenTelemetry
|
|
14
14
|
class TracerMiddleware
|
15
15
|
def call(_worker_class, job, _queue, _redis_pool)
|
16
16
|
tracer.in_span(
|
17
|
-
job
|
17
|
+
span_name(job),
|
18
18
|
attributes: {
|
19
|
+
'messaging.system' => 'sidekiq',
|
20
|
+
'messaging.sidekiq.job_class' => job['wrapped']&.to_s || job['class'],
|
19
21
|
'messaging.message_id' => job['jid'],
|
20
|
-
'messaging.destination' => job['queue']
|
22
|
+
'messaging.destination' => job['queue'],
|
23
|
+
'messaging.destination_kind' => 'queue'
|
21
24
|
},
|
22
25
|
kind: :producer
|
23
26
|
) do |span|
|
@@ -29,6 +32,18 @@ module OpenTelemetry
|
|
29
32
|
|
30
33
|
private
|
31
34
|
|
35
|
+
def span_name(job)
|
36
|
+
if config[:enable_job_class_span_names]
|
37
|
+
"#{job['wrapped']&.to_s || job['class']} enqueue"
|
38
|
+
else
|
39
|
+
"#{job['queue']} send"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def config
|
44
|
+
Sidekiq::Instrumentation.instance.config
|
45
|
+
end
|
46
|
+
|
32
47
|
def tracer
|
33
48
|
Sidekiq::Instrumentation.instance.tracer
|
34
49
|
end
|
@@ -15,10 +15,13 @@ module OpenTelemetry
|
|
15
15
|
def call(_worker, msg, _queue)
|
16
16
|
parent_context = OpenTelemetry.propagation.text.extract(msg)
|
17
17
|
tracer.in_span(
|
18
|
-
msg
|
18
|
+
span_name(msg),
|
19
19
|
attributes: {
|
20
|
+
'messaging.system' => 'sidekiq',
|
21
|
+
'messaging.sidekiq.job_class' => msg['wrapped']&.to_s || msg['class'],
|
20
22
|
'messaging.message_id' => msg['jid'],
|
21
|
-
'messaging.destination' => msg['queue']
|
23
|
+
'messaging.destination' => msg['queue'],
|
24
|
+
'messaging.destination_kind' => 'queue'
|
22
25
|
},
|
23
26
|
with_parent: parent_context,
|
24
27
|
kind: :consumer
|
@@ -31,6 +34,18 @@ module OpenTelemetry
|
|
31
34
|
|
32
35
|
private
|
33
36
|
|
37
|
+
def span_name(msg)
|
38
|
+
if config[:enable_job_class_span_names]
|
39
|
+
"#{msg['wrapped']&.to_s || msg['class']} process"
|
40
|
+
else
|
41
|
+
"#{msg['queue']} process"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def config
|
46
|
+
Sidekiq::Instrumentation.instance.config
|
47
|
+
end
|
48
|
+
|
34
49
|
def tracer
|
35
50
|
Sidekiq::Instrumentation.instance.tracer
|
36
51
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
module OpenTelemetry
|
8
|
+
module Instrumentation
|
9
|
+
module Sidekiq
|
10
|
+
module Patches
|
11
|
+
# The Launcher module contains the instrumentation for the Sidekiq heartbeat
|
12
|
+
module Launcher
|
13
|
+
private
|
14
|
+
|
15
|
+
def ❤ # rubocop:disable Naming/MethodName
|
16
|
+
if config[:trace_launcher_heartbeat]
|
17
|
+
tracer.in_span('Sidekiq::Launcher#heartbeat') { super }
|
18
|
+
else
|
19
|
+
OpenTelemetry::Common::Utilities.untraced { super }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def tracer
|
24
|
+
Sidekiq::Instrumentation.instance.tracer
|
25
|
+
end
|
26
|
+
|
27
|
+
def config
|
28
|
+
Sidekiq::Instrumentation.instance.config
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
module OpenTelemetry
|
8
|
+
module Instrumentation
|
9
|
+
module Sidekiq
|
10
|
+
module Patches
|
11
|
+
# The Poller module contains instrumentation for the enqueue and wait methods
|
12
|
+
module Poller
|
13
|
+
def enqueue
|
14
|
+
if config[:trace_poller_enqueue]
|
15
|
+
tracer.in_span('Sidekiq::Scheduled::Poller#enqueue') { super }
|
16
|
+
else
|
17
|
+
OpenTelemetry::Common::Utilities.untraced { super }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def wait
|
24
|
+
if config[:trace_poller_wait]
|
25
|
+
tracer.in_span('Sidekiq::Scheduled::Poller#wait') { super }
|
26
|
+
else
|
27
|
+
OpenTelemetry::Common::Utilities.untraced { super }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def tracer
|
32
|
+
Sidekiq::Instrumentation.instance.tracer
|
33
|
+
end
|
34
|
+
|
35
|
+
def config
|
36
|
+
Sidekiq::Instrumentation.instance.config
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright The OpenTelemetry Authors
|
4
|
+
#
|
5
|
+
# SPDX-License-Identifier: Apache-2.0
|
6
|
+
|
7
|
+
module OpenTelemetry
|
8
|
+
module Instrumentation
|
9
|
+
module Sidekiq
|
10
|
+
module Patches
|
11
|
+
# The Processor module contains the insturmentation for the process_one method
|
12
|
+
module Processor
|
13
|
+
private
|
14
|
+
|
15
|
+
def process_one
|
16
|
+
if config[:trace_processor_process_one]
|
17
|
+
tracer.in_span('Sidekiq::Processor#process_one') { super }
|
18
|
+
else
|
19
|
+
OpenTelemetry::Common::Utilities.untraced { super }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def tracer
|
24
|
+
Sidekiq::Instrumentation.instance.tracer
|
25
|
+
end
|
26
|
+
|
27
|
+
def config
|
28
|
+
Sidekiq::Instrumentation.instance.config
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentelemetry-instrumentation-sidekiq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- OpenTelemetry Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.13.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.13.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: opentelemetry-common
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.13.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.13.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: appraisal
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,15 +181,18 @@ files:
|
|
167
181
|
- lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb
|
168
182
|
- lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb
|
169
183
|
- lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb
|
184
|
+
- lib/opentelemetry/instrumentation/sidekiq/patches/launcher.rb
|
185
|
+
- lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
|
186
|
+
- lib/opentelemetry/instrumentation/sidekiq/patches/processor.rb
|
170
187
|
- lib/opentelemetry/instrumentation/sidekiq/version.rb
|
171
188
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
172
189
|
licenses:
|
173
190
|
- Apache-2.0
|
174
191
|
metadata:
|
175
|
-
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.
|
176
|
-
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/
|
192
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.13.0/file.CHANGELOG.html
|
193
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/sidekiq
|
177
194
|
bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
|
178
|
-
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.
|
195
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.13.0
|
179
196
|
post_install_message:
|
180
197
|
rdoc_options: []
|
181
198
|
require_paths:
|