-
Notifications
You must be signed in to change notification settings - Fork 373
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
[rack] add request queuing option to the Rack middleware #272
Conversation
header = env[REQUEST_START] | ||
|
||
if header | ||
# nginx header is in the format "t=1512379167.574" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the current testing phase, only nginx is required; I'll iterate over other formats if they're different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Left some comments about code style, but the changes are not necessary, so feel free to skip them!
request_start = Time.at(time_string.to_f) | ||
request_start.utc > now ? nil : request_start | ||
end | ||
rescue StandardError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ruby you can omit the exception class when it is StandardError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
def get_request_start(env, now = Time.now.utc) | ||
header = env[REQUEST_START] | ||
|
||
if header |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I usually prefer early returns than code nested in conditional branches, but that's only a matter of personal style :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -32,19 +40,34 @@ def initialize(app, options = {}) | |||
@app = app | |||
end | |||
|
|||
def compute_queueing_time(env, tracer) | |||
if Datadog.configuration[:rack][:request_queuing] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here about the early return comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
e9f3fc1
to
12ca7bc
Compare
d81a371
to
9980106
Compare
Is this stable enough to merge? Would be cool to close this out if we're happy with it. |
|
||
Datadog::Tracer.log.debug('[experimental] creating request.enqueuing span') | ||
tracer.trace( | ||
'request.enqueuing', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: the name doesn't align with our usual informal conventions (request.
looks like it comes from request
library).
I also guess it has to stay generic between web servers (not Nginx only).
So maybe something like web_server.start_request
, http_server.start_request
?
I also saw that there is a potential for another X-Queue-Start
timing, it would then easily translate into a whatever.queue_start
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally agree, we can change that value with one you've suggested!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's an HTTP header named X-Queue-Start
, those usually get tagged as http
. I'd suggest adding http
, like http.queue_start
, http.headers.queue_start
or something similar (to indicate its origins)
docs/GettingStarted.md
Outdated
|
||
Datadog.configure do |c| | ||
# web_service_name defaults to `web-server` and is different from Rack `service_name` | ||
c.use :rack, request_queuing: true, web_service_name: nginx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: request_queuing
is a specific mechanism of the front web server, while here we want to more generally integrate with front web servers. Maybe we could have an option key more generic? Examples: instrument_web|http_server
, behind_web_server
, http_server_enabled
, ...
I guess it also depends on what we will want to do once stable (enabled by default?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the option name, yes we can stay more generic. For the future (once it's stable), we can keep it enabled by default so to activate it is enough to change something in the proxy configuration (nginx, HAProxy, whatever).
Rescheduled for 0.13.0 but will be available in a beta release right after the 0.12.0 release. |
29c7c2a
to
9f57afe
Compare
|
||
module_function | ||
|
||
def get_request_start(env, now = Time.now.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this to the core library in a future pull request. The behavior here is generic enough, and useful for other integrations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Overview
Provides the request queuing time from the Rack middleware if a frontend web server or load balancer sets a specific header. This is considered an experimental feature and may have breaking changes in the future.
Usage
x-request-start
headerSupported format
At the time of writing, only
nginx
headers are supported in the format oft=1512379167.574
.