Skip to content

Commit 9ddea61

Browse files
committed
Fix handling of duration
1 parent 0ffe375 commit 9ddea61

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

sentry-rails/lib/sentry/rails/log_subscribers/action_controller_subscriber.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ActionControllerSubscriber < Sentry::Rails::LogSubscriber
2828
# @param event [ActiveSupport::Notifications::Event] The controller action event
2929
def process_action(event)
3030
payload = event.payload
31-
duration = event.time.round(2)
31+
duration = event.duration.round(2)
3232

3333
controller = payload[:controller]
3434
action = payload[:action]

sentry-rails/spec/sentry/rails/log_subscribers/action_controller_subscriber_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@
2525
expect(log_event[:attributes][:controller][:value]).to eq("HelloController")
2626
expect(log_event[:attributes][:action][:value]).to eq("world")
2727
expect(log_event[:attributes][:status][:value]).to eq(200)
28-
expect(log_event[:attributes][:duration_ms][:value]).to be > 0
28+
29+
duration = log_event[:attributes][:duration_ms][:value]
30+
expect(duration).to be_a(Float)
31+
expect(duration).to be_in(0.01..30.0)
32+
2933
expect(log_event[:attributes][:method][:value]).to eq("GET")
3034
expect(log_event[:attributes][:path][:value]).to eq("/world")
3135
expect(log_event[:attributes][:format][:value]).to eq(:html)

0 commit comments

Comments
 (0)