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

Conversation

ibnjunaid
Copy link
Contributor

Issue #, if available:

Description of changes:

X-Ray SDK expects time in seconds with up to nanosecond precision.
This change make sure that the time is passed in seconds to the X-Ray for DB transactions.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ibnjunaid ibnjunaid requested a review from a team as a code owner August 16, 2024 22:21
ibnjunaid and others added 2 commits August 17, 2024 05:05
the latest macos-14 supports arm only. 
This PR using the previous version of macos image to unblock the release.
Copy link
Contributor

@wangzlei wangzlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wangzlei
Copy link
Contributor

wangzlei commented Aug 19, 2024

The PR is to address DB subsegment timestamp issue in rails version larger than 7.
#92

Copy link
Contributor

@jj22ee jj22ee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at my comments.

I believe you can check for rails version like:

if Rails::VERSION::MAJOR >= 7
  # Do the new thing
else
  # Do it the old way
end

@ibnjunaid ibnjunaid requested a review from jj22ee August 21, 2024 17:35
@jj22ee
Copy link
Contributor

jj22ee commented Aug 21, 2024

TY, can you update convert_time_in_seconds to be specifically for Rails 7.1, and update unit tests appropriately? Seems we only want to divide by 1000 only if Rails version is 7.1.

@ibnjunaid
Copy link
Contributor Author

convert_time_in_seconds

@jj22ee How do you suggest.

should we do something like this

          subsegment.start_time = (::Rails::VERSION::MAJOR == 7 and ::Rails::VERSION::MINOR == 1) ? convert_time_in_seconds(transaction.time.to_f) : transaction.time.to_f

or

   subsegment.start_time = (::Rails::VERSION::MAJOR == 7 and ::Rails::VERSION::MINOR == 1) ? transaction.time.to_f / 1000 : transaction.time.to_f

@ibnjunaid
Copy link
Contributor Author

ibnjunaid commented Aug 22, 2024

@jj22ee

I am in favour of the first one because the changes are being back ported to some rails 7.1 version so I think its not a good idea to just divide by 1000 without checking.

Like has been back ported to 7-1-stable rails/rails#50493 (comment)

https://api.rubyonrails.org/v5.1/classes/Rails/VERSION.html

subsegment.start_time = (::Rails::VERSION::MAJOR == 7 and ::Rails::VERSION::MINOR == 1) ? convert_time_in_seconds(transaction.time.to_f) : transaction.time.to_f

@jj22ee
Copy link
Contributor

jj22ee commented Aug 22, 2024

Like has been back ported to 7-1-stable rails/rails#50493 (comment)

  1. This is saying the bug is back ported to 7.1, the fix isn't backported from looking at this issue
  2. The function you are proposing will still have the code smell I've commented here

Can you provide some test results for Rails v7, v7.1, v7.2 for your change?

@jj22ee
Copy link
Contributor

jj22ee commented Aug 22, 2024

We can see here that the fix is applied in 7.1-stable branch here

@ibnjunaid
Copy link
Contributor Author

@jj22ee . The issue is still there for the available versions of 7.1.x.y of rails .
Theres not any rails version with stable release it is just a branch in the repo as of now.
https://rubygems.org/gems/rails/versions

@jj22ee jj22ee merged commit 16d808f into aws:master Aug 23, 2024
8 checks passed
@mxiamxia mxiamxia mentioned this pull request Sep 5, 2024
tetsu040e added a commit to enechange/aws-xray-sdk-ruby that referenced this pull request Oct 15, 2024
* Add ECS metadata allowing cloudwatch-logs to be linked with traces (aws#93)

* First step

* Add comment

* Typo

* Copy logic of EC2 plugin for ECS

* Typo

* Back to symbols

* Copy paste all EC2 tests as starting point for ECS

* Comments

* Somewhat working ?

* Backword compatible with prevous feature when not 1.4

* Add hint for fargate 1.4 in case of errors

---------

Co-authored-by: Etienne Chabert <[email protected]>

* release 0.15.0 (aws#94)

* Update version for 0.15.0 release (aws#95)

* Update continuous-build.yml (aws#97)

the latest macos-14 supports arm only. 
This PR using the previous version of macos image to unblock the release.

* Fix issue: Wrong duration for DB transaction event  on ROR 7.1 aws#92 (aws#96)

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

* Added unit tests and restructured the code

* Fix unit tests

* Update continuous-build.yml (aws#97)

the latest macos-14 supports arm only. 
This PR using the previous version of macos image to unblock the release.

* Worked on the jj22ee's comment and added logic that convert in seconds only for rails 7.1 versions.

* Conditionally handle for ruby 7.1

---------

Co-authored-by: Lei Wang <[email protected]>

* Release 0.16.0 (aws#98)

---------

Co-authored-by: Chabert Etienne <[email protected]>
Co-authored-by: Etienne Chabert <[email protected]>
Co-authored-by: Prashant Srivastava <[email protected]>
Co-authored-by: Lei Wang <[email protected]>
Co-authored-by: Osama Bin Junaid <[email protected]>
Co-authored-by: Min Xia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants