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

Queue time mismatch between X-Request-Time scale and start time call #163

Closed
cschneid opened this issue Feb 6, 2020 · 0 comments · Fixed by #169
Closed

Queue time mismatch between X-Request-Time scale and start time call #163

cschneid opened this issue Feb 6, 2020 · 0 comments · Fixed by #169
Assignees
Labels
bug Something isn't working

Comments

@cschneid
Copy link
Contributor

cschneid commented Feb 6, 2020

The X-Request-Time header is in milliseconds, but the PHP code then does a divide by 10000, and uses microtime to compare against it, which I don't think matches up.

The current code:

  • The header value comes in as milliseconds since epoch. To simplify, assume we're in 1970 and say "2".
  • The code divides that number by 10000, so it's 0.0002
  • Then it gets the start time as microseconds, say 3000 (3 milliseconds after epoch)
  • The final value is then (3000 - 0.0002) * 1e9 = 2.999e12 nanoseconds. Which is ~50 minutes.

The expected value is:

  • Header value of 2ms after epoch
  • start time is 3ms after epoch
  • start - header = 1ms
  • convert to nanoseconds = 1e6 nanoseconds

Because of the subtraction, epoch cancels out.

https://github.com/scoutapp/scout-apm-php/blob/master/src/Events/Request/Request.php#L95-L96

https://devcenter.heroku.com/articles/http-routing#heroku-headers

@asgrim asgrim self-assigned this Feb 17, 2020
@asgrim asgrim added the bug Something isn't working label Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants