Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue: Wrong duration for DB transaction event on ROR 7.1 #92 #96

Merged
merged 6 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/continuous-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os:
- macos-latest
- macos-13
jj22ee marked this conversation as resolved.
Show resolved Hide resolved
- ubuntu-latest
ruby:
- 2.4
Expand Down
6 changes: 4 additions & 2 deletions lib/aws-xray-sdk/facets/rails/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ def record(transaction)
subsegment = XRay.recorder.begin_subsegment name, namespace: 'remote'
# subsegment is nil in case of context missing
return if subsegment.nil?
subsegment.start_time = transaction.time.to_f
# Rails 7.1 introduced time measurement in milliseconds instead seconds of causing xray-sdk to report wrong duration for transaction calls.
# This is being handled in rails 7.2 and later. https://github.com/rails/rails/pull/50779
subsegment.start_time = (::Rails::VERSION::MAJOR == 7 and ::Rails::VERSION::MINOR == 1) ? transaction.time.to_f/1000 : transaction.time.to_f
subsegment.sql = sql
XRay.recorder.end_subsegment end_time: transaction.end.to_f
XRay.recorder.end_subsegment end_time: (::Rails::VERSION::MAJOR == 7 and ::Rails::VERSION::MINOR == 1) ? transaction.end.to_f/1000 : transaction.end.to_f
end

private
Expand Down
Loading