opentelemetry-instrumentation-sidekiq 0.12.0 → 0.17.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 +25 -0
- data/README.md +4 -4
- data/lib/opentelemetry/instrumentation/sidekiq.rb +2 -0
- data/lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb +32 -0
- data/lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb +27 -6
- data/lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb +27 -6
- data/lib/opentelemetry/instrumentation/sidekiq/patches/launcher.rb +36 -0
- data/lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb +44 -0
- data/lib/opentelemetry/instrumentation/sidekiq/patches/processor.rb +36 -0
- data/lib/opentelemetry/instrumentation/sidekiq/version.rb +1 -1
- metadata +39 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16931c87c910aace5d938407321eb6fc832d36b7436c2f8ac4721da5532bccea
|
4
|
+
data.tar.gz: da9d93ce6c105f7dcbb12a165dd0bc5a8fb9f8b73b2ed0362c7636c8e7aba0f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6d91a5b9d207640e9a50d5f9770831c7b8c61d28d29da75de83d3de40ed8054029f1538947afddda8001bfa1ccd02fd202f5fab015818aee5c92c56983b5a93
|
7
|
+
data.tar.gz: 1f9b9e0de5512199abf9ad29335e510920583bbb5ec37e7fba26e34a3f992d6b9758b260acd2ad01219a211168306a475776761a7d6d5d66994483b7c6c090a5
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,30 @@
|
|
1
1
|
# Release History: opentelemetry-instrumentation-sidekiq
|
2
2
|
|
3
|
+
### v0.17.0 / 2021-04-22
|
4
|
+
|
5
|
+
* ADDED: Accept config for sidekiq peer service attribute
|
6
|
+
|
7
|
+
### v0.16.0 / 2021-03-17
|
8
|
+
|
9
|
+
* FIXED: Example scripts now reference local common lib
|
10
|
+
* DOCS: Replace Gitter with GitHub Discussions
|
11
|
+
|
12
|
+
### v0.15.0 / 2021-02-18
|
13
|
+
|
14
|
+
* ADDED: Add instrumentation config validation
|
15
|
+
|
16
|
+
### v0.14.0 / 2021-02-03
|
17
|
+
|
18
|
+
* BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
|
19
|
+
|
20
|
+
* ADDED: Replace getter and setter callables and remove rack specific propagators
|
21
|
+
|
22
|
+
### v0.13.0 / 2021-01-29
|
23
|
+
|
24
|
+
* ADDED: Instrument sidekiq background work
|
25
|
+
* FIXED: Adjust Sidekiq middlewares to match semantic conventions
|
26
|
+
* FIXED: Set minimum compatible version and use untraced helper
|
27
|
+
|
3
28
|
### v0.12.0 / 2020-12-24
|
4
29
|
|
5
30
|
* (No significant changes)
|
data/README.md
CHANGED
@@ -31,13 +31,13 @@ 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
|
|
38
38
|
The `opentelemetry-instrumentation-sidekiq` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
|
39
39
|
|
40
|
-
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us
|
40
|
+
The OpenTelemetry Ruby gems are maintained by the OpenTelemetry-Ruby special interest group (SIG). You can get involved by joining us in [GitHub Discussions][discussions-url] or attending our weekly meeting. See the [meeting calendar][community-meetings] for dates and times. For more information on this and other language SIGs, see the OpenTelemetry [community page][ruby-sig].
|
41
41
|
|
42
42
|
## License
|
43
43
|
|
@@ -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
|
+
[discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
|
@@ -5,6 +5,7 @@
|
|
5
5
|
# SPDX-License-Identifier: Apache-2.0
|
6
6
|
|
7
7
|
require 'opentelemetry'
|
8
|
+
require 'opentelemetry-instrumentation-base'
|
8
9
|
|
9
10
|
module OpenTelemetry
|
10
11
|
module Instrumentation
|
@@ -16,3 +17,4 @@ end
|
|
16
17
|
|
17
18
|
require_relative './sidekiq/instrumentation'
|
18
19
|
require_relative './sidekiq/version'
|
20
|
+
require 'opentelemetry/common'
|
@@ -10,21 +10,53 @@ 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
|
+
|
30
|
+
option :enable_job_class_span_names, default: false, validate: :boolean
|
31
|
+
option :trace_launcher_heartbeat, default: false, validate: :boolean
|
32
|
+
option :trace_poller_enqueue, default: false, validate: :boolean
|
33
|
+
option :trace_poller_wait, default: false, validate: :boolean
|
34
|
+
option :trace_processor_process_one, default: false, validate: :boolean
|
35
|
+
option :peer_service, default: nil, validate: :string
|
36
|
+
|
23
37
|
private
|
24
38
|
|
39
|
+
def gem_version
|
40
|
+
Gem.loaded_specs['sidekiq'].version
|
41
|
+
end
|
42
|
+
|
25
43
|
def require_dependencies
|
26
44
|
require_relative 'middlewares/client/tracer_middleware'
|
27
45
|
require_relative 'middlewares/server/tracer_middleware'
|
46
|
+
|
47
|
+
require_relative 'patches/processor'
|
48
|
+
require_relative 'patches/launcher'
|
49
|
+
require_relative 'patches/poller'
|
50
|
+
end
|
51
|
+
|
52
|
+
def patch_on_startup
|
53
|
+
::Sidekiq.configure_server do |config|
|
54
|
+
config.on(:startup) do
|
55
|
+
::Sidekiq::Processor.prepend(Patches::Processor)
|
56
|
+
::Sidekiq::Launcher.prepend(Patches::Launcher)
|
57
|
+
::Sidekiq::Scheduled::Poller.prepend(Patches::Poller)
|
58
|
+
end
|
59
|
+
end
|
28
60
|
end
|
29
61
|
|
30
62
|
def add_client_middleware
|
@@ -14,14 +14,11 @@ module OpenTelemetry
|
|
14
14
|
class TracerMiddleware
|
15
15
|
def call(_worker_class, job, _queue, _redis_pool)
|
16
16
|
tracer.in_span(
|
17
|
-
job
|
18
|
-
attributes:
|
19
|
-
'messaging.message_id' => job['jid'],
|
20
|
-
'messaging.destination' => job['queue']
|
21
|
-
},
|
17
|
+
span_name(job),
|
18
|
+
attributes: build_attributes(job),
|
22
19
|
kind: :producer
|
23
20
|
) do |span|
|
24
|
-
OpenTelemetry.propagation.
|
21
|
+
OpenTelemetry.propagation.inject(job)
|
25
22
|
span.add_event('created_at', timestamp: job['created_at'])
|
26
23
|
yield
|
27
24
|
end
|
@@ -29,6 +26,30 @@ module OpenTelemetry
|
|
29
26
|
|
30
27
|
private
|
31
28
|
|
29
|
+
def build_attributes(job)
|
30
|
+
attributes = {
|
31
|
+
'messaging.system' => 'sidekiq',
|
32
|
+
'messaging.sidekiq.job_class' => job['wrapped']&.to_s || job['class'],
|
33
|
+
'messaging.message_id' => job['jid'],
|
34
|
+
'messaging.destination' => job['queue'],
|
35
|
+
'messaging.destination_kind' => 'queue'
|
36
|
+
}
|
37
|
+
attributes['peer.service'] = config[:peer_service] if config[:peer_service]
|
38
|
+
attributes
|
39
|
+
end
|
40
|
+
|
41
|
+
def span_name(job)
|
42
|
+
if config[:enable_job_class_span_names]
|
43
|
+
"#{job['wrapped']&.to_s || job['class']} enqueue"
|
44
|
+
else
|
45
|
+
"#{job['queue']} send"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def config
|
50
|
+
Sidekiq::Instrumentation.instance.config
|
51
|
+
end
|
52
|
+
|
32
53
|
def tracer
|
33
54
|
Sidekiq::Instrumentation.instance.tracer
|
34
55
|
end
|
@@ -13,13 +13,10 @@ module OpenTelemetry
|
|
13
13
|
# by way of its middleware system
|
14
14
|
class TracerMiddleware
|
15
15
|
def call(_worker, msg, _queue)
|
16
|
-
parent_context = OpenTelemetry.propagation.
|
16
|
+
parent_context = OpenTelemetry.propagation.extract(msg)
|
17
17
|
tracer.in_span(
|
18
|
-
msg
|
19
|
-
attributes:
|
20
|
-
'messaging.message_id' => msg['jid'],
|
21
|
-
'messaging.destination' => msg['queue']
|
22
|
-
},
|
18
|
+
span_name(msg),
|
19
|
+
attributes: build_attributes(msg),
|
23
20
|
with_parent: parent_context,
|
24
21
|
kind: :consumer
|
25
22
|
) do |span|
|
@@ -31,6 +28,30 @@ module OpenTelemetry
|
|
31
28
|
|
32
29
|
private
|
33
30
|
|
31
|
+
def build_attributes(msg)
|
32
|
+
attributes = {
|
33
|
+
'messaging.system' => 'sidekiq',
|
34
|
+
'messaging.sidekiq.job_class' => msg['wrapped']&.to_s || msg['class'],
|
35
|
+
'messaging.message_id' => msg['jid'],
|
36
|
+
'messaging.destination' => msg['queue'],
|
37
|
+
'messaging.destination_kind' => 'queue'
|
38
|
+
}
|
39
|
+
attributes['peer.service'] = config[:peer_service] if config[:peer_service]
|
40
|
+
attributes
|
41
|
+
end
|
42
|
+
|
43
|
+
def span_name(msg)
|
44
|
+
if config[:enable_job_class_span_names]
|
45
|
+
"#{msg['wrapped']&.to_s || msg['class']} process"
|
46
|
+
else
|
47
|
+
"#{msg['queue']} process"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def config
|
52
|
+
Sidekiq::Instrumentation.instance.config
|
53
|
+
end
|
54
|
+
|
34
55
|
def tracer
|
35
56
|
Sidekiq::Instrumentation.instance.tracer
|
36
57
|
end
|
@@ -0,0 +1,36 @@
|
|
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
|
+
attributes = {}
|
18
|
+
attributes['peer.service'] = config[:peer_service] if config[:peer_service]
|
19
|
+
tracer.in_span('Sidekiq::Launcher#heartbeat', attributes: attributes) { super }
|
20
|
+
else
|
21
|
+
OpenTelemetry::Common::Utilities.untraced { super }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def tracer
|
26
|
+
Sidekiq::Instrumentation.instance.tracer
|
27
|
+
end
|
28
|
+
|
29
|
+
def config
|
30
|
+
Sidekiq::Instrumentation.instance.config
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,44 @@
|
|
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
|
+
attributes = {}
|
16
|
+
attributes['peer.service'] = config[:peer_service] if config[:peer_service]
|
17
|
+
tracer.in_span('Sidekiq::Scheduled::Poller#enqueue', attributes: attributes) { super }
|
18
|
+
else
|
19
|
+
OpenTelemetry::Common::Utilities.untraced { super }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def wait
|
26
|
+
if config[:trace_poller_wait]
|
27
|
+
tracer.in_span('Sidekiq::Scheduled::Poller#wait') { super }
|
28
|
+
else
|
29
|
+
OpenTelemetry::Common::Utilities.untraced { super }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def tracer
|
34
|
+
Sidekiq::Instrumentation.instance.tracer
|
35
|
+
end
|
36
|
+
|
37
|
+
def config
|
38
|
+
Sidekiq::Instrumentation.instance.config
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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 instrumentation for the process_one method
|
12
|
+
module Processor
|
13
|
+
private
|
14
|
+
|
15
|
+
def process_one
|
16
|
+
if config[:trace_processor_process_one]
|
17
|
+
attributes = {}
|
18
|
+
attributes['peer.service'] = config[:peer_service] if config[:peer_service]
|
19
|
+
tracer.in_span('Sidekiq::Processor#process_one', attributes: attributes) { super }
|
20
|
+
else
|
21
|
+
OpenTelemetry::Common::Utilities.untraced { super }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def tracer
|
26
|
+
Sidekiq::Instrumentation.instance.tracer
|
27
|
+
end
|
28
|
+
|
29
|
+
def config
|
30
|
+
Sidekiq::Instrumentation.instance.config
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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.17.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-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opentelemetry-api
|
@@ -16,14 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.17.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.17.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.17.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.17.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: opentelemetry-instrumentation-base
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.17.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.17.0
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: appraisal
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -167,15 +195,18 @@ files:
|
|
167
195
|
- lib/opentelemetry/instrumentation/sidekiq/instrumentation.rb
|
168
196
|
- lib/opentelemetry/instrumentation/sidekiq/middlewares/client/tracer_middleware.rb
|
169
197
|
- lib/opentelemetry/instrumentation/sidekiq/middlewares/server/tracer_middleware.rb
|
198
|
+
- lib/opentelemetry/instrumentation/sidekiq/patches/launcher.rb
|
199
|
+
- lib/opentelemetry/instrumentation/sidekiq/patches/poller.rb
|
200
|
+
- lib/opentelemetry/instrumentation/sidekiq/patches/processor.rb
|
170
201
|
- lib/opentelemetry/instrumentation/sidekiq/version.rb
|
171
202
|
homepage: https://github.com/open-telemetry/opentelemetry-ruby
|
172
203
|
licenses:
|
173
204
|
- Apache-2.0
|
174
205
|
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/
|
206
|
+
changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.17.0/file.CHANGELOG.html
|
207
|
+
source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/sidekiq
|
177
208
|
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.
|
209
|
+
documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.17.0
|
179
210
|
post_install_message:
|
180
211
|
rdoc_options: []
|
181
212
|
require_paths:
|
@@ -191,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
222
|
- !ruby/object:Gem::Version
|
192
223
|
version: '0'
|
193
224
|
requirements: []
|
194
|
-
rubygems_version: 3.1.
|
225
|
+
rubygems_version: 3.1.6
|
195
226
|
signing_key:
|
196
227
|
specification_version: 4
|
197
228
|
summary: Sidekiq instrumentation for the OpenTelemetry framework
|