heroku / barnes

Tell StatsD about request time, GC, objects and more. Latest Rails 4 and Ruby 2.1 support, and ancient Rails 2 and Ruby 1.8 support.
MIT License
0 stars 0 forks source link

Support loading on Windows, use CLOCK_REALTIME or CLOCK_MONOTONIC #40

Open ariccio opened 2 years ago

ariccio commented 2 years ago

Strangely, for the first time ever tonight, Rails failed to start on my windows dev machine because Barnes tries to use Process.clock_gettime with Process::CLOCK_PROCESS_CPUTIME_ID. Again, I have no clue why this is an issue all of a sudden. I haven't changed anything reasonably related since last successful start. Either way, Ruby on Windows only currently supports CLOCK_REALTIME and CLOCK_MONOTONIC.

It's easy for me to workaround, since I don't actually need barnes in development or test, so I just add it to the :production group in my gemfile. Perhaps someone should update the docs to say it should be added in production? Or otherwise nop out the code.

The stacktrace is:

C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/instruments/stopwatch.rb:77:in `clock_gettime': Invalid argument - clock_gettime (Errno::EINVAL)
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/instruments/stopwatch.rb:77:in `cpu'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/instruments/stopwatch.rb:64:in `current'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/instruments/stopwatch.rb:33:in `start!'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/panel.rb:38:in `block in start!'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/panel.rb:37:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/panel.rb:37:in `start!'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/periodic.rb:43:in `block (2 levels) in initialize'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/barnes-0.0.9/lib/barnes/periodic.rb:42:in `each'