opentelemetry-instrumentation-active_job 0.1.5 → 0.2.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: 3c341fbc24129813db37f6b8b83719df56bfd042378b97619969a5a7684647dc
4
- data.tar.gz: 4d436b96869793778d0b1a237cca48b69dfc1ef53e7c0a4fa1cfff7ccd9a3432
3
+ metadata.gz: cf28c56776d6925a23e7a0dd65162cc217c7e5fd4e591b471cd77912241d5f89
4
+ data.tar.gz: 728c70ce03a1d03f28242dabcee397ce7bd7186f05fd747cd2e3451f6fdc7ab4
5
5
  SHA512:
6
- metadata.gz: d72fbe4abcd71905d858f8fe7baf4d6ff94feadbc0c64bf2be8bdd44da158510c0b07997d2feaa851435394e48a824a6eccb0aac5ce7b16d99afea3b350b4ffa
7
- data.tar.gz: 4aa9e51f6bbd8cb640f2ae177602d9381844b1394effe1e152bf3ebfebee16dbfde87ac47a59fcf2b6389fc83e41f251b1e1609a9da189845f84018b9695dd50
6
+ metadata.gz: 35f01f133c73ff36562554d783b890c928f81e24256dbd4c9d91a4b024f4dff4e07e8a853b888d1542aa444f0505774d618b671462d598ab0e19f34169de4ae5
7
+ data.tar.gz: 9e23409ef225df507335da04b877bb9e82cb3d13569687577ca2f7e1d6e856f26278054740762d521a9e311228364d86a4b6351b740524424afe3c00fc0016d7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Release History: opentelemetry-instrumentation-active_job
2
2
 
3
+ ### v0.2.0 / 2022-05-02
4
+
5
+ * ADDED: Validate Using Enums
6
+ * ADDED: Make the context available in ActiveJob notifications
7
+ * FIXED: Fix deserialization of jobs that are missing metadata
8
+ * FIXED: RubyGems Fallback
9
+
3
10
  ### v0.1.5 / 2021-12-02
4
11
 
5
12
  * (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.5'
10
+ VERSION = '0.2.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.5
4
+ version: 0.2.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-12-02 00:00:00.000000000 Z
11
+ date: 2022-05-02 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.19.0
33
+ version: 0.20.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.19.0
40
+ version: 0.20.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activejob
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -228,10 +228,10 @@ homepage: https://github.com/open-telemetry/opentelemetry-ruby
228
228
  licenses:
229
229
  - Apache-2.0
230
230
  metadata:
231
- changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_job/v0.1.5/file.CHANGELOG.html
231
+ changelog_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_job/v0.2.0/file.CHANGELOG.html
232
232
  source_code_uri: https://github.com/open-telemetry/opentelemetry-ruby/tree/main/instrumentation/active_job
233
233
  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.5
234
+ documentation_uri: https://open-telemetry.github.io/opentelemetry-ruby/opentelemetry-instrumentation-active_job/v0.2.0
235
235
  post_install_message:
236
236
  rdoc_options: []
237
237
  require_paths: