opentelemetry-instrumentation-sidekiq 0.11.0 → 0.16.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: bfffce04ec1a2f15237f46d6768838d699905fce9843e879b945e514f34ffa80
4
- data.tar.gz: cf1daa9b7fee84e1ea033577166089335daca01be0bf57bbdbbfa4a01aedf58e
3
+ metadata.gz: d779ad028fa986d96d8fedbb6581e7ad2063825be89ef787eea19619391ea146
4
+ data.tar.gz: 6164415d7a74c9b0434bda0c62884ccd44bdd84cdc6ea0cf91f4f38d51631b30
5
5
  SHA512:
6
- metadata.gz: 8646fc300eb7355bfe74a66a1573efe6095672fe63d55de3dfc35b6725a4493d2ccfc8136ee7e122703d8f65371335b0087494db60552741133c0fb4507161a5
7
- data.tar.gz: a6f51ef920b463e42b733d330e48d5c47bef5225e3a6f81d742b24830f229edb13fe634e4fd1daa5867e792fe64f0c59240ab4e45716f99ee93f8b9b118c3e5b
6
+ metadata.gz: 3591cffe3495f539bf38010579f91ee9b37489e5ea14b77d20dc0c173653c2eb25db14143ea47b2a0cd25e315296f67cad3d02469a91cb3eeefec0e969814c2a
7
+ data.tar.gz: a4c8b87b71de42f7588fcf947c4b27671060ba9046879ee4ba4be193b2ef10ea65bfec9374df6744f8d01e8d000306517a6774d5ebfbaf14bda376a8d3762bb9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # Release History: opentelemetry-instrumentation-sidekiq
2
2
 
3
+ ### v0.16.0 / 2021-03-17
4
+
5
+ * FIXED: Example scripts now reference local common lib
6
+ * DOCS: Replace Gitter with GitHub Discussions
7
+
8
+ ### v0.15.0 / 2021-02-18
9
+
10
+ * ADDED: Add instrumentation config validation
11
+
12
+ ### v0.14.0 / 2021-02-03
13
+
14
+ * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
15
+
16
+ * ADDED: Replace getter and setter callables and remove rack specific propagators
17
+
18
+ ### v0.13.0 / 2021-01-29
19
+
20
+ * ADDED: Instrument sidekiq background work
21
+ * FIXED: Adjust Sidekiq middlewares to match semantic conventions
22
+ * FIXED: Set minimum compatible version and use untraced helper
23
+
24
+ ### v0.12.0 / 2020-12-24
25
+
26
+ * (No significant changes)
27
+
3
28
  ### v0.11.0 / 2020-12-11
4
29
 
5
30
  * FIXED: Copyright comments to not reference year
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/master/instrumentation/sidekiq/example/sidekiq.rb)
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 on our [gitter channel][ruby-gitter] 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].
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/master/LICENSE
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
- [ruby-gitter]: https://gitter.im/open-telemetry/opentelemetry-ruby
52
+ [discussions-url]: https://github.com/open-telemetry/opentelemetry-ruby/discussions
@@ -16,3 +16,4 @@ end
16
16
 
17
17
  require_relative './sidekiq/instrumentation'
18
18
  require_relative './sidekiq/version'
19
+ require 'opentelemetry/common'
@@ -10,21 +10,52 @@ 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
+
23
36
  private
24
37
 
38
+ def gem_version
39
+ Gem.loaded_specs['sidekiq'].version
40
+ end
41
+
25
42
  def require_dependencies
26
43
  require_relative 'middlewares/client/tracer_middleware'
27
44
  require_relative 'middlewares/server/tracer_middleware'
45
+
46
+ require_relative 'patches/processor'
47
+ require_relative 'patches/launcher'
48
+ require_relative 'patches/poller'
49
+ end
50
+
51
+ def patch_on_startup
52
+ ::Sidekiq.configure_server do |config|
53
+ config.on(:startup) do
54
+ ::Sidekiq::Processor.prepend(Patches::Processor)
55
+ ::Sidekiq::Launcher.prepend(Patches::Launcher)
56
+ ::Sidekiq::Scheduled::Poller.prepend(Patches::Poller)
57
+ end
58
+ end
28
59
  end
29
60
 
30
61
  def add_client_middleware
@@ -14,14 +14,17 @@ module OpenTelemetry
14
14
  class TracerMiddleware
15
15
  def call(_worker_class, job, _queue, _redis_pool)
16
16
  tracer.in_span(
17
- job['wrapped']&.to_s || job['class'],
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|
24
- OpenTelemetry.propagation.text.inject(job)
27
+ OpenTelemetry.propagation.inject(job)
25
28
  span.add_event('created_at', timestamp: job['created_at'])
26
29
  yield
27
30
  end
@@ -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
@@ -13,12 +13,15 @@ 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.text.extract(msg)
16
+ parent_context = OpenTelemetry.propagation.extract(msg)
17
17
  tracer.in_span(
18
- msg['wrapped']&.to_s || msg['class'],
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
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Sidekiq
10
- VERSION = '0.11.0'
10
+ VERSION = '0.16.0'
11
11
  end
12
12
  end
13
13
  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.11.0
4
+ version: 0.16.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: 2020-12-11 00:00:00.000000000 Z
11
+ date: 2021-03-22 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.11.0
19
+ version: 0.16.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.11.0
26
+ version: 0.16.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.16.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.16.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.11.0/file.CHANGELOG.html
176
- source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/master/instrumentation/sidekiq
192
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.16.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.11.0
195
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.16.0
179
196
  post_install_message:
180
197
  rdoc_options: []
181
198
  require_paths: