Skip to content

Commit abd8bc7

Browse files
fix(active-job): Handle missing CLOCK_THREAD_CPUTIME_ID on JRuby
Use defined? guard instead of begin/rescue since JRuby raises NameError (constant doesn't exist) rather than Errno::EINVAL.
1 parent dd3c094 commit abd8bc7

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

  • instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers

instrumentation/active_job/lib/opentelemetry/instrumentation/active_job/handlers/perform.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,11 @@ def now_gc
118118
end
119119
end
120120

121-
begin
122-
Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :float_millisecond)
121+
if defined?(Process::CLOCK_THREAD_CPUTIME_ID)
123122
def now_cpu
124123
Process.clock_gettime(Process::CLOCK_THREAD_CPUTIME_ID, :float_millisecond)
125124
end
126-
rescue Errno::EINVAL
125+
else
127126
def now_cpu
128127
0.0
129128
end

0 commit comments

Comments
 (0)