catpm 0.10.2 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b2fde17350e1e195b3e7aa1cf8084b435d474c8d73aee1e83b2924cf8809a40
4
- data.tar.gz: 253e27024b75ef3a5d1cb538b87275afbe373b9645b41d56ff751d86c3c27612
3
+ metadata.gz: 17dea4b78b491f51fac82cb2f2a186ec102b7485e27a603878dfcf1e0daa63e5
4
+ data.tar.gz: a4699301f378675ef029421d0a55203dabf5b755ac39c6517ad6d1403c9feba1
5
5
  SHA512:
6
- metadata.gz: dd586cd99584f463ef1c77e25c8c4e2c0920dc66115528c90a53af483e3601f1b1d4a554c9b80e0f403174ceb67fa5e3956d10a60d4c96c206f1669bd74d7c0d
7
- data.tar.gz: 74fc43ecc58017374a011982100e1780ff44e7c068b36c814626be37e85ac517b658527e7021bd7ea2b500b499935b807745cb52a54989f1e23b413f093cd90a
6
+ metadata.gz: 9160d359ba4f722ed174260984bd231ffbf4bf500570efc4693a4c7cdb2209bcdc72708f611d0b996acd6d29dfb736b225ae3e0dc26f33ae16bd2bcd4c3de46e
7
+ data.tar.gz: 695ee4ef924685b4f49eb14392358306a2436976be7361b6458779749db5c67db8c6eceb280b05e57dea35b727c912dbe8c9df7e95d530aa6f956d0e81f1544e
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  gem build catpm.gemspec
2
- gem push catpm-0.10.1.gem
2
+ gem push catpm-0.10.3.gem
3
3
 
4
4
  # Catpm
5
5
 
@@ -194,6 +194,9 @@ module Catpm
194
194
  def process_active_job(event)
195
195
  return unless Catpm.enabled?
196
196
 
197
+ # No middleware in job workers — restart flusher after fork
198
+ Catpm.flusher&.ensure_running!
199
+
197
200
  payload = event.payload
198
201
  job = payload[:job]
199
202
  target = job.class.name
@@ -61,6 +61,11 @@ module Catpm
61
61
  target = job.class.name
62
62
  return if Catpm.config.ignored?(target)
63
63
 
64
+ # Mark that we're inside a job so nested Catpm.span calls don't
65
+ # promote themselves to standalone endpoints when this job is not
66
+ # selected for segment sampling.
67
+ Thread.current[:catpm_job_active] = true
68
+
64
69
  if Collector.should_instrument?(:job, target, job.queue_name)
65
70
  use_sampler = Catpm.config.instrument_stack_sampler || Catpm.config.instrument_call_tree
66
71
  start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
@@ -79,6 +84,8 @@ module Catpm
79
84
  end
80
85
 
81
86
  def finish(_name, _id, payload)
87
+ Thread.current[:catpm_job_active] = nil
88
+
82
89
  return unless payload[:_catpm_job_owns_segments]
83
90
 
84
91
  req_segments = Thread.current[:catpm_request_segments]
data/lib/catpm/trace.rb CHANGED
@@ -9,9 +9,9 @@ module Catpm
9
9
 
10
10
  req_segments = Thread.current[:catpm_request_segments]
11
11
  unless req_segments
12
- # Inside a non-instrumented HTTP request — just run the block
12
+ # Inside a non-instrumented request/job — just run the block
13
13
  # without promoting the span to a standalone endpoint
14
- if Thread.current[:catpm_request_start]
14
+ if Thread.current[:catpm_request_start] || Thread.current[:catpm_job_active]
15
15
  return block.call if block
16
16
  return nil
17
17
  end
@@ -52,7 +52,7 @@ module Catpm
52
52
  type: :custom, duration: duration_ms, detail: name,
53
53
  source: source, started_at: start_time
54
54
  )
55
- elsif buffer && !Thread.current[:catpm_request_start]
55
+ elsif buffer && !Thread.current[:catpm_request_start] && !Thread.current[:catpm_job_active]
56
56
  Collector.process_custom(
57
57
  name: name, duration: duration_ms,
58
58
  metadata: metadata, error: error, context: context
@@ -155,7 +155,7 @@ module Catpm
155
155
  type: :custom, duration: duration_ms, detail: @name,
156
156
  source: source, started_at: @start_time
157
157
  )
158
- elsif Catpm.enabled? && Catpm.buffer && !Thread.current[:catpm_request_start]
158
+ elsif Catpm.enabled? && Catpm.buffer && !Thread.current[:catpm_request_start] && !Thread.current[:catpm_job_active]
159
159
  Collector.process_custom(
160
160
  name: @name, duration: duration_ms,
161
161
  metadata: @metadata, error: error, context: @context
data/lib/catpm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Catpm
4
- VERSION = '0.10.2'
4
+ VERSION = '0.10.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''