opentelemetry-instrumentation-active_job 0.1.4 → 0.3.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: b014d1f37a55288b8b529fa5c6cd79b4fd81202d40b07d99defcf4eb15fa8296
4
- data.tar.gz: 9f84b67271cb784270e037c8e1b33340873fa9e5fb0a14d34c3b4beb8d17da1a
3
+ metadata.gz: 8e1e9794b086e48e52136a217c91defe4fc158d09b330d9307a1f0fad5a2f3f6
4
+ data.tar.gz: f6c4d7e4c4f4aea2b29df2735430756c649a534b3195b6c114dfe7bf47980bde
5
5
  SHA512:
6
- metadata.gz: 35ab58159d1b3836bdf500625be88f512f672a5a6f299684cfcad436c854cbdf5f0d51824ae68891aa27fffc6ccf6fb0ae2413dad59243242a430a82dcb4a7a7
7
- data.tar.gz: 884b16b4c12fefd56466b76e49cfeeb26314e2e76909a2fff29b59c43e5f5a6ba49264575af536fb3860ad982ec773e2123d5b0f84464b9843836aaff84bed52
6
+ metadata.gz: c176c6461a7af9fdde516b99d1038eae28cebedfd7d8ba64e4447654c496bed0e5b5a0270befe712e49128b2253c820caaa057e5ce1e3aee5550f18ad37a1bef
7
+ data.tar.gz: 9384415b42d18d14caf9cf4a00f6cd05b3e0047332de4ed8fc9116a70df22d7313df375d4f3ca8a92ce41687a313a47491004705f5cb55d19e66af0a83712312
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Release History: opentelemetry-instrumentation-active_job
2
2
 
3
+ ### v0.3.0 / 2022-06-09
4
+
5
+ * Upgrading Base dependency version
6
+ * FIXED: Broken test file requirements
7
+
8
+ ### v0.2.0 / 2022-05-02
9
+
10
+ * ADDED: Validate Using Enums
11
+ * ADDED: Make the context available in ActiveJob notifications
12
+ * FIXED: Fix deserialization of jobs that are missing metadata
13
+ * FIXED: RubyGems Fallback
14
+
15
+ ### v0.1.5 / 2021-12-02
16
+
17
+ * (No significant changes)
18
+
3
19
  ### v0.1.4 / 2021-09-29
4
20
 
5
21
  * (No significant changes)
@@ -21,7 +21,7 @@ module OpenTelemetry
21
21
  end
22
22
 
23
23
  compatible do
24
- Gem.loaded_specs['activejob'].version >= MINIMUM_VERSION
24
+ gem_version >= MINIMUM_VERSION
25
25
  end
26
26
 
27
27
  ## Supported configuration keys for the install config hash:
@@ -52,12 +52,16 @@ module OpenTelemetry
52
52
  # spans will always be children of the enqueueing spans. This is due to the way
53
53
  # ActiveJob immediately executes jobs during the process of "enqueueing" jobs when
54
54
  # using the `:inline` adapter.
55
- option :propagation_style, default: :link, validate: ->(opt) { %i[link child none].include?(opt) }
55
+ option :propagation_style, default: :link, validate: %i[link child none]
56
56
  option :force_flush, default: false, validate: :boolean
57
- option :span_naming, default: :queue, validate: ->(opt) { %i[job_class queue].include?(opt) }
57
+ option :span_naming, default: :queue, validate: %i[job_class queue]
58
58
 
59
59
  private
60
60
 
61
+ def gem_version
62
+ ::ActiveJob.version
63
+ end
64
+
61
65
  def require_dependencies
62
66
  require_relative 'patches/base'
63
67
  require_relative 'patches/active_job_callbacks'
@@ -10,8 +10,8 @@ module OpenTelemetry
10
10
  module Patches
11
11
  # Module to prepend to ActiveJob::Base for instrumentation.
12
12
  module ActiveJobCallbacks
13
- def self.prepended(base) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
14
- base.class_eval do # rubocop:disable Metrics/BlockLength
13
+ def self.prepended(base)
14
+ base.class_eval do
15
15
  around_enqueue do |job, block|
16
16
  span_kind = job.class.queue_adapter_name == 'inline' ? :client : :producer
17
17
  span_name = "#{otel_config[:span_naming] == :job_class ? job.class : job.queue_name} send"
@@ -21,45 +21,46 @@ module OpenTelemetry
21
21
  block.call
22
22
  end
23
23
  end
24
+ end
25
+ end
24
26
 
25
- around_perform do |job, block| # rubocop:disable Metrics/BlockLength
26
- span_kind = job.class.queue_adapter_name == 'inline' ? :server : :consumer
27
- span_name = "#{otel_config[:span_naming] == :job_class ? job.class : job.queue_name} process"
28
- span_attributes = job_attributes(job).merge('messaging.operation' => 'process')
27
+ def perform_now # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
28
+ span_kind = self.class.queue_adapter_name == 'inline' ? :server : :consumer
29
+ span_name = "#{otel_config[:span_naming] == :job_class ? self.class : queue_name} process"
30
+ span_attributes = job_attributes(self).merge('messaging.operation' => 'process')
31
+ executions_count = (executions || 0) + 1 # because we run before the count is incremented in ActiveJob::Execution
29
32
 
30
- extracted_context = OpenTelemetry.propagation.extract(job.metadata)
31
- OpenTelemetry::Context.with_current(extracted_context) do
32
- if otel_config[:propagation_style] == :child
33
- otel_tracer.in_span(span_name, attributes: span_attributes, kind: span_kind) do |span|
34
- span.set_attribute('messaging.active_job.executions', job.executions)
35
- block.call
36
- end
37
- else
38
- span_links = []
39
- if otel_config[:propagation_style] == :link
40
- span_context = OpenTelemetry::Trace.current_span(extracted_context).context
41
- span_links << OpenTelemetry::Trace::Link.new(span_context) if span_context.valid?
42
- end
33
+ extracted_context = OpenTelemetry.propagation.extract(metadata)
34
+ OpenTelemetry::Context.with_current(extracted_context) do
35
+ if otel_config[:propagation_style] == :child
36
+ otel_tracer.in_span(span_name, attributes: span_attributes, kind: span_kind) do |span|
37
+ span.set_attribute('messaging.active_job.executions', executions_count)
38
+ super
39
+ end
40
+ else
41
+ span_links = []
42
+ if otel_config[:propagation_style] == :link
43
+ span_context = OpenTelemetry::Trace.current_span(extracted_context).context
44
+ span_links << OpenTelemetry::Trace::Link.new(span_context) if span_context.valid?
45
+ end
43
46
 
44
- root_span = otel_tracer.start_root_span(span_name, attributes: span_attributes, links: span_links, kind: span_kind)
45
- OpenTelemetry::Trace.with_span(root_span) do |span|
46
- span.set_attribute('messaging.active_job.executions', job.executions)
47
- block.call
48
- rescue Exception => e # rubocop:disable Lint/RescueException
49
- span.record_exception(e)
50
- span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{e.class}")
51
- raise e
52
- ensure
53
- root_span.finish
54
- end
55
- end
47
+ root_span = otel_tracer.start_root_span(span_name, attributes: span_attributes, links: span_links, kind: span_kind)
48
+ OpenTelemetry::Trace.with_span(root_span) do |span|
49
+ span.set_attribute('messaging.active_job.executions', executions_count)
50
+ super
51
+ rescue Exception => e # rubocop:disable Lint/RescueException
52
+ span.record_exception(e)
53
+ span.status = OpenTelemetry::Trace::Status.error("Unhandled exception of type: #{e.class}")
54
+ raise e
55
+ ensure
56
+ root_span.finish
56
57
  end
57
- ensure
58
- # We may be in a job system (eg: resque) that forks and kills worker processes often.
59
- # We don't want to lose spans by not flushing any span processors, so we optionally force it here.
60
- OpenTelemetry.tracer_provider.force_flush if otel_config[:force_flush]
61
58
  end
62
59
  end
60
+ ensure
61
+ # We may be in a job system (eg: resque) that forks and kills worker processes often.
62
+ # We don't want to lose spans by not flushing any span processors, so we optionally force it here.
63
+ OpenTelemetry.tracer_provider.force_flush if otel_config[:force_flush]
63
64
  end
64
65
 
65
66
  private
@@ -27,7 +27,7 @@ module OpenTelemetry
27
27
  end
28
28
 
29
29
  def deserialize(job_data)
30
- self.metadata = (deserialize_arguments(job_data['metadata']) || []).to_h
30
+ self.metadata = deserialize_arguments(job_data['metadata'] || []).to_h
31
31
  super
32
32
  end
33
33
  end
@@ -7,7 +7,7 @@
7
7
  module OpenTelemetry
8
8
  module Instrumentation
9
9
  module ActiveJob
10
- VERSION = '0.1.4'
10
+ VERSION = '0.3.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-active_job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.3.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: 2021-09-30 00:00:00.000000000 Z
11
+ date: 2022-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opentelemetry-api
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.18.3
33
+ version: 0.21.0
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.18.3
40
+ version: 0.21.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activejob
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '1.0'
103
+ version: '1.1'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '1.0'
110
+ version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: opentelemetry-test-helpers
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: pry
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -228,10 +242,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
228
242
  licenses:
229
243
  - Apache-2.0
230
244
  metadata:
231
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_job/v0.1.4/file.CHANGELOG.html
245
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_job/v0.3.0/file.CHANGELOG.html
232
246
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/active_job
233
247
  bug_tracker_uri: https://github.com/open-telemetry/opentelemetry-ruby/issues
234
- documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_job/v0.1.4
248
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_job/v0.3.0
235
249
  post_install_message:
236
250
  rdoc_options: []
237
251
  require_paths:
@@ -240,7 +254,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
254
  requirements:
241
255
  - - ">="
242
256
  - !ruby/object:Gem::Version
243
- version: 2.5.0
257
+ version: 2.6.0
244
258
  required_rubygems_version: !ruby/object:Gem::Requirement
245
259
  requirements:
246
260
  - - ">="