Wrong duration for DB transaction event
- Dominant language
- Ruby
- Stars
- 60
- Forks
- 54
- PR merge metrics
- No merged PRs in 30d
Description
### [Steps to reproduce the issue]
* Create a Ruby on rails application with the X-Ray SDK for Ruby middleware [3] to send requests to the Database.
* Create a Model and a corresponding Controller.
* Define routing URL pattern corresponding to the Controller.
* Start the X-Ray daemon.
* Send a request to the created application.
* Confirm the the time duration for the trace in the X-Ray console.
As a result, the start_time of a subsegment during a DB operation was set to a time in the distant future.
### [Investigation]
* aws-xray-sdk-ruby subscribes to transaction events and uses the start time of the event as the start_time of the subsegment.
https://github.com/aws/aws-xray-sdk-ruby/blob/master/lib/aws-xray-sdk/facets/rails/active_record.rb
* However, while the subsegment start_time is assumed to be in seconds, the event start_time is recorded in milliseconds. In other words, it is 1000 times larger than the assumed value.
https://github.com/rails/rails/blob/0c09ae546fae39333068177b28767abbc6c8726e/activesupport/lib/active_support/notifications/ instrumenter.rb#L106
Contributor guide
Assessment
This issue has not been assessed yet.