aws / aws/aws-xray-sdk-ruby

Wrong duration for DB transaction event

Open
#92 2 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.