Fullscript / yabeda-activejob

Yabeda Instrumentation for some metrics around rails activejobs
MIT License
8 stars 2 forks source link

Support event.end time in seconds #12

Closed rosa closed 2 weeks ago

rosa commented 8 months ago

Hey! Thanks for the work on this Yabeda plugin πŸ™ I'm in the process of bumping one of our apps to Rails edge and ran into an issue with it.

In Rails 7, ActiveSupport::Notifications::Event times (end, time, duration) are in seconds as per https://github.com/rails/rails/pull/50779, which changes all times to be in seconds (done for Rails 7.2 and backported to Rails 7.1 and 7.0). This means that calling Time.parse(time.to_s).utc on a seconds value results in an

ArgumentError: argument out of range

For example:

>> Time.at(1710189541.5303319)
=> 2024-03-11 21:39:01 2224373/4194304 +0100
>> Time.parse("1710189541.5303319")
Traceback (most recent call last):
        7: from /Users/rosa/.rbenv/versions/2.7.3/bin/irb:23:in `<main>'
        6: from /Users/rosa/.rbenv/versions/2.7.3/bin/irb:23:in `load'
        5: from /Users/rosa/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
        4: from (irb):4
        3: from /Users/rosa/.rbenv/versions/2.7.3/lib/ruby/2.7.0/time.rb:375:in `parse'
        2: from /Users/rosa/.rbenv/versions/2.7.3/lib/ruby/2.7.0/time.rb:266:in `make_time'
        1: from /Users/rosa/.rbenv/versions/2.7.3/lib/ruby/2.7.0/time.rb:266:in `local'
ArgumentError (argument out of range)
andrewmarkle commented 2 weeks ago

@rosa thank you so much!

rosa commented 2 weeks ago

Thank you! πŸ™ ❀️