opentelemetry-instrumentation-sidekiq 0.16.0 → 0.19.1

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: d779ad028fa986d96d8fedbb6581e7ad2063825be89ef787eea19619391ea146
4
- data.tar.gz: 6164415d7a74c9b0434bda0c62884ccd44bdd84cdc6ea0cf91f4f38d51631b30
3
+ metadata.gz: 25750e9750af614c5ea01314b28883f55b2aeb80c75fc528b78edcdde4a2a52a
4
+ data.tar.gz: 7fbccb9f9f65e70cc8ce58d82de2d782aaa530f981b926b36d6c9a152b3be257
5
5
  SHA512:
6
- metadata.gz: 3591cffe3495f539bf38010579f91ee9b37489e5ea14b77d20dc0c173653c2eb25db14143ea47b2a0cd25e315296f67cad3d02469a91cb3eeefec0e969814c2a
7
- data.tar.gz: a4c8b87b71de42f7588fcf947c4b27671060ba9046879ee4ba4be193b2ef10ea65bfec9374df6744f8d01e8d000306517a6774d5ebfbaf14bda376a8d3762bb9
6
+ metadata.gz: 04bcc7073435d289e77a730078b6efd8e5f2b253ffeffd5cca98ea59f3b253e94b545245e693c691d7fdf5f5e124563b9baaee3e674d7cf3ded3ba2a91b183c2
7
+ data.tar.gz: 0abaf82efeb93446100a6682af61dfb26f018b31b100c4a36016356714cc49992f08f7926c7b5858906915d2adfa720353ce0b417b28061d878ea95eef1f3488
data/CHANGELOG.md CHANGED
@@ -1,25 +1,52 @@
1
1
  # Release History: opentelemetry-instrumentation-sidekiq
2
2
 
3
+ ### v0.19.1 / 2021-08-12
4
+
5
+ * (No significant changes)
6
+
7
+ ### v0.19.0 / 2021-06-23
8
+
9
+ * BREAKING CHANGE: Sidekiq propagation config
10
+ - Config option enable_job_class_span_names renamed to span_naming and now expects a symbol of value :job_class, or :queue
11
+ - The default behaviour is no longer to have one continuous trace for the enqueue and process spans, using links is the new default. To maintain the previous behaviour the config option propagation_style must be set to :child.
12
+ * BREAKING CHANGE: Total order constraint on span.status=
13
+
14
+ * FIXED: Sidekiq propagation config
15
+ * FIXED: Total order constraint on span.status=
16
+
17
+ ### v0.18.0 / 2021-05-21
18
+
19
+ * ADDED: Updated API depedency for 1.0.0.rc1
20
+ * TEST: update test for redis instrumentation refactor [#760](https://github.com/open-telemetry/opentelemetry-ruby/pull/760)
21
+ * BREAKING CHANGE: Remove optional parent_context from in_span
22
+
23
+ * FIXED: Remove optional parent_context from in_span
24
+ * FIXED: Instrument Redis more thoroughly by patching Client#process.
25
+
26
+ ### v0.17.0 / 2021-04-22
27
+
28
+ * ADDED: Accept config for sidekiq peer service attribute
29
+
3
30
  ### v0.16.0 / 2021-03-17
4
31
 
5
- * FIXED: Example scripts now reference local common lib
6
- * DOCS: Replace Gitter with GitHub Discussions
32
+ * FIXED: Example scripts now reference local common lib
33
+ * DOCS: Replace Gitter with GitHub Discussions
7
34
 
8
35
  ### v0.15.0 / 2021-02-18
9
36
 
10
- * ADDED: Add instrumentation config validation
37
+ * ADDED: Add instrumentation config validation
11
38
 
12
39
  ### v0.14.0 / 2021-02-03
13
40
 
14
- * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
41
+ * BREAKING CHANGE: Replace getter and setter callables and remove rack specific propagators
15
42
 
16
- * ADDED: Replace getter and setter callables and remove rack specific propagators
43
+ * ADDED: Replace getter and setter callables and remove rack specific propagators
17
44
 
18
45
  ### v0.13.0 / 2021-01-29
19
46
 
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
47
+ * ADDED: Instrument sidekiq background work
48
+ * FIXED: Adjust Sidekiq middlewares to match semantic conventions
49
+ * FIXED: Set minimum compatible version and use untraced helper
23
50
 
24
51
  ### v0.12.0 / 2020-12-24
25
52
 
@@ -27,7 +54,7 @@
27
54
 
28
55
  ### v0.11.0 / 2020-12-11
29
56
 
30
- * FIXED: Copyright comments to not reference year
57
+ * FIXED: Copyright comments to not reference year
31
58
 
32
59
  ### v0.10.0 / 2020-12-03
33
60
 
@@ -35,9 +62,9 @@
35
62
 
36
63
  ### v0.9.0 / 2020-11-27
37
64
 
38
- * BREAKING CHANGE: Add timeout for force_flush and shutdown
65
+ * BREAKING CHANGE: Add timeout for force_flush and shutdown
39
66
 
40
- * ADDED: Add timeout for force_flush and shutdown
67
+ * ADDED: Add timeout for force_flush and shutdown
41
68
 
42
69
  ### v0.8.0 / 2020-10-27
43
70
 
@@ -45,9 +72,9 @@
45
72
 
46
73
  ### v0.7.0 / 2020-10-07
47
74
 
48
- * DOCS: Adding README for Sidekiq instrumentation
49
- * DOCS: Remove duplicate reference in Sidekiq README
50
- * DOCS: Standardize toplevel docs structure and readme
75
+ * DOCS: Adding README for Sidekiq instrumentation
76
+ * DOCS: Remove duplicate reference in Sidekiq README
77
+ * DOCS: Standardize toplevel docs structure and readme
51
78
 
52
79
  ### v0.6.0 / 2020-09-10
53
80
 
data/README.md CHANGED
@@ -33,7 +33,16 @@ end
33
33
 
34
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
- ## How can I get invovled?
36
+ ## Development
37
+
38
+ You'll need Redis installed locally to run the test suite. Once you've
39
+ installed it, it will start and stop automatically when you run `rake`.
40
+
41
+ ```
42
+ redis-server test/redis.conf
43
+ ```
44
+
45
+ ## How can I get involved?
37
46
 
38
47
  The `opentelemetry-instrumentation-sidekiq` gem source is [on github][repo-github], along with related gems including `opentelemetry-api` and `opentelemetry-sdk`.
39
48
 
@@ -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
@@ -27,11 +27,13 @@ module OpenTelemetry
27
27
  gem_version >= MINIMUM_VERSION
28
28
  end
29
29
 
30
- option :enable_job_class_span_names, default: false, validate: :boolean
30
+ option :span_naming, default: :queue, validate: ->(opt) { %I[job_class queue].include?(opt) }
31
+ option :propagation_style, default: :link, validate: ->(opt) { %i[link child none].include?(opt) }
31
32
  option :trace_launcher_heartbeat, default: false, validate: :boolean
32
33
  option :trace_poller_enqueue, default: false, validate: :boolean
33
34
  option :trace_poller_wait, default: false, validate: :boolean
34
35
  option :trace_processor_process_one, default: false, validate: :boolean
36
+ option :peer_service, default: nil, validate: :string
35
37
 
36
38
  private
37
39
 
@@ -12,18 +12,22 @@ module OpenTelemetry
12
12
  # TracerMiddleware propagates context and instruments Sidekiq client
13
13
  # by way of its middleware system
14
14
  class TracerMiddleware
15
- def call(_worker_class, job, _queue, _redis_pool)
16
- tracer.in_span(
17
- span_name(job),
18
- attributes: {
19
- 'messaging.system' => 'sidekiq',
20
- 'messaging.sidekiq.job_class' => job['wrapped']&.to_s || job['class'],
21
- 'messaging.message_id' => job['jid'],
22
- 'messaging.destination' => job['queue'],
23
- 'messaging.destination_kind' => 'queue'
24
- },
25
- kind: :producer
26
- ) do |span|
15
+ def call(_worker_class, job, _queue, _redis_pool) # rubocop:disable Metrics/AbcSize
16
+ attributes = {
17
+ 'messaging.system' => 'sidekiq',
18
+ 'messaging.sidekiq.job_class' => job['wrapped']&.to_s || job['class'],
19
+ 'messaging.message_id' => job['jid'],
20
+ 'messaging.destination' => job['queue'],
21
+ 'messaging.destination_kind' => 'queue'
22
+ }
23
+ attributes['peer.service'] = config[:peer_service] if config[:peer_service]
24
+
25
+ span_name = case config[:span_naming]
26
+ when :job_class then "#{job['wrapped']&.to_s || job['class']} send"
27
+ else "#{job['queue']} send"
28
+ end
29
+
30
+ tracer.in_span(span_name, attributes: attributes, kind: :producer) do |span|
27
31
  OpenTelemetry.propagation.inject(job)
28
32
  span.add_event('created_at', timestamp: job['created_at'])
29
33
  yield
@@ -32,14 +36,6 @@ module OpenTelemetry
32
36
 
33
37
  private
34
38
 
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
39
  def config
44
40
  Sidekiq::Instrumentation.instance.config
45
41
  end
@@ -12,36 +12,51 @@ module OpenTelemetry
12
12
  # TracerMiddleware propagates context and instruments Sidekiq requests
13
13
  # by way of its middleware system
14
14
  class TracerMiddleware
15
- def call(_worker, msg, _queue)
16
- parent_context = OpenTelemetry.propagation.extract(msg)
17
- tracer.in_span(
18
- span_name(msg),
19
- attributes: {
20
- 'messaging.system' => 'sidekiq',
21
- 'messaging.sidekiq.job_class' => msg['wrapped']&.to_s || msg['class'],
22
- 'messaging.message_id' => msg['jid'],
23
- 'messaging.destination' => msg['queue'],
24
- 'messaging.destination_kind' => 'queue'
25
- },
26
- with_parent: parent_context,
27
- kind: :consumer
28
- ) do |span|
29
- span.add_event('created_at', timestamp: msg['created_at'])
30
- span.add_event('enqueued_at', timestamp: msg['enqueued_at'])
31
- yield
32
- end
33
- end
15
+ def call(_worker, msg, _queue) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
16
+ attributes = {
17
+ 'messaging.system' => 'sidekiq',
18
+ 'messaging.sidekiq.job_class' => msg['wrapped']&.to_s || msg['class'],
19
+ 'messaging.message_id' => msg['jid'],
20
+ 'messaging.destination' => msg['queue'],
21
+ 'messaging.destination_kind' => 'queue'
22
+ }
23
+ attributes['peer.service'] = config[:peer_service] if config[:peer_service]
34
24
 
35
- private
25
+ span_name = case config[:span_naming]
26
+ when :job_class then "#{msg['wrapped']&.to_s || msg['class']} process"
27
+ else "#{msg['queue']} process"
28
+ end
36
29
 
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"
30
+ extracted_context = OpenTelemetry.propagation.extract(msg)
31
+ OpenTelemetry::Context.with_current(extracted_context) do
32
+ if config[:propagation_style] == :child
33
+ tracer.in_span(span_name, attributes: attributes, kind: :consumer) do |span|
34
+ span.add_event('created_at', timestamp: msg['created_at'])
35
+ span.add_event('enqueued_at', timestamp: msg['enqueued_at'])
36
+ yield
37
+ end
38
+ else
39
+ links = []
40
+ span_context = OpenTelemetry::Trace.current_span(extracted_context).context
41
+ links << OpenTelemetry::Trace::Link.new(span_context) if config[:propagation_style] == :link && span_context.valid?
42
+ span = tracer.start_root_span(span_name, attributes: attributes, links: links, kind: :consumer)
43
+ OpenTelemetry::Trace.with_span(span) do
44
+ span.add_event('created_at', timestamp: msg['created_at'])
45
+ span.add_event('enqueued_at', timestamp: msg['enqueued_at'])
46
+ yield
47
+ rescue Exception => e # rubocop:disable Lint/RescueException
48
+ span.record_exception(e)
49
+ span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{e.class}")
50
+ raise e
51
+ ensure
52
+ span.finish
53
+ end
54
+ end
42
55
  end
43
56
  end
44
57
 
58
+ private
59
+
45
60
  def config
46
61
  Sidekiq::Instrumentation.instance.config
47
62
  end
@@ -14,7 +14,9 @@ module OpenTelemetry
14
14
 
15
15
  def ❤ # rubocop:disable Naming/MethodName
16
16
  if config[:trace_launcher_heartbeat]
17
- tracer.in_span('Sidekiq::Launcher#heartbeat') { super }
17
+ attributes = {}
18
+ attributes['peer.service'] = config[:peer_service] if config[:peer_service]
19
+ tracer.in_span('Sidekiq::Launcher#heartbeat', attributes: attributes) { super }
18
20
  else
19
21
  OpenTelemetry::Common::Utilities.untraced { super }
20
22
  end
@@ -12,7 +12,9 @@ module OpenTelemetry
12
12
  module Poller
13
13
  def enqueue
14
14
  if config[:trace_poller_enqueue]
15
- tracer.in_span('Sidekiq::Scheduled::Poller#enqueue') { super }
15
+ attributes = {}
16
+ attributes['peer.service'] = config[:peer_service] if config[:peer_service]
17
+ tracer.in_span('Sidekiq::Scheduled::Poller#enqueue', attributes: attributes) { super }
16
18
  else
17
19
  OpenTelemetry::Common::Utilities.untraced { super }
18
20
  end
@@ -8,13 +8,15 @@ module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Sidekiq
10
10
  module Patches
11
- # The Processor module contains the insturmentation for the process_one method
11
+ # The Processor module contains the instrumentation for the process_one method
12
12
  module Processor
13
13
  private
14
14
 
15
15
  def process_one
16
16
  if config[:trace_processor_process_one]
17
- tracer.in_span('Sidekiq::Processor#process_one') { super }
17
+ attributes = {}
18
+ attributes['peer.service'] = config[:peer_service] if config[:peer_service]
19
+ tracer.in_span('Sidekiq::Processor#process_one', attributes: attributes) { super }
18
20
  else
19
21
  OpenTelemetry::Common::Utilities.untraced { super }
20
22
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module Sidekiq
10
- VERSION = '0.16.0'
10
+ VERSION = '0.19.1'
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.16.0
4
+ version: 0.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - OpenTelemetry Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-22 00:00:00.000000000 Z
11
+ date: 2021-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -16,28 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.16.0
19
+ version: 1.0.0.rc3
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.16.0
26
+ version: 1.0.0.rc3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opentelemetry-common
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.16.0
33
+ version: 0.19.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.16.0
40
+ version: 0.19.1
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.18.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.18.2
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: appraisal
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +100,14 @@ dependencies:
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '0.0'
103
+ version: 1.0.0.rc1
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '0.0'
110
+ version: 1.0.0.rc1
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rubocop
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -189,10 +203,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
189
203
  licenses:
190
204
  - Apache-2.0
191
205
  metadata:
192
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.16.0/file.CHANGELOG.html
206
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.19.1/file.CHANGELOG.html
193
207
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/sidekiq
194
208
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
195
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.16.0
209
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-sidekiq/v0.19.1
196
210
  post_install_message:
197
211
  rdoc_options: []
198
212
  require_paths:
@@ -208,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
222
  - !ruby/object:Gem::Version
209
223
  version: '0'
210
224
  requirements: []
211
- rubygems_version: 3.1.4
225
+ rubygems_version: 3.1.6
212
226
  signing_key:
213
227
  specification_version: 4
214
228
  summary: Sidekiq instrumentation for the OpenTelemetry framework