rack-timeout 0.1.0beta4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +108 -138
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f4a3287d087373af78ba892d153244e803c4615
|
4
|
+
data.tar.gz: 6111fecabc946f4537890bc63ec9e60f1dae757c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f609b6a82e645730dc47a945bcd2834424c4e1d68bfb1ff2f2462dcb2d1af36b77c8e7714da1df3ee00389c703101cd14484803c70c5d387a9f65d05803b0f3a
|
7
|
+
data.tar.gz: b1a9caec46c8fa8b6832b2c265fa39c53d625806cac669b9705b0ea496e637aa5a982885d582377aed98a9c0fc38b7073280033bfc5b75cb601a8c0bddfcbbdf
|
data/README.markdown
CHANGED
@@ -1,167 +1,160 @@
|
|
1
|
-
README is not very out-of-date for this release. Lots of comments in source though. README updates coming before next release.
|
2
|
-
|
3
1
|
Rack::Timeout
|
4
2
|
=============
|
5
3
|
|
6
4
|
Abort requests that are taking too long; a subclass of `Rack::Timeout::Error` is raised.
|
7
5
|
|
8
|
-
A generous timeout of 15s is the default. It's recommended to set the timeout as low as
|
9
|
-
|
6
|
+
A generous timeout of 15s is the default. It's recommended to set the timeout as low as realistically viable for your application. Most applications will do fine with a setting between 2 and 5 seconds.
|
7
|
+
|
8
|
+
There's a handful of other settings, read on for details.
|
9
|
+
|
10
|
+
Rack::Timeout is not a solution to the problem of long-running requests, it's a debug and remediation tool. App developers should track rack-timeout's data and address recurring instances of particular timeouts, for example by refactoring code so it runs faster or offseting lengthy work to happen asynchronously.
|
10
11
|
|
11
12
|
|
12
|
-
Usage
|
13
|
-
|
13
|
+
Basic Usage
|
14
|
+
-----------
|
14
15
|
|
15
|
-
The following covers currently supported versions of Rails, Rack, Ruby, and Bundler. See the
|
16
|
-
Compatibility section at the end for legacy versions.
|
16
|
+
The following covers currently supported versions of Rails, Rack, Ruby, and Bundler. See the Compatibility section at the end for legacy versions.
|
17
17
|
|
18
18
|
### Rails apps
|
19
19
|
|
20
20
|
# Gemfile
|
21
21
|
gem "rack-timeout"
|
22
22
|
|
23
|
-
That's all that's required if you want to use the default timeout of 15s. To use a custom timeout,
|
24
|
-
create an initializer file:
|
23
|
+
That's all that's required if you want to use the default timeout of 15s. To use a custom timeout, create an initializer file:
|
25
24
|
|
26
25
|
# config/initializers/timeout.rb
|
27
|
-
Rack::Timeout.timeout =
|
26
|
+
Rack::Timeout.timeout = 5 # seconds
|
28
27
|
|
29
28
|
### Sinatra and other Rack apps
|
30
29
|
|
31
30
|
# config.ru
|
32
31
|
require "rack-timeout"
|
33
|
-
use Rack::Timeout
|
34
|
-
Rack::Timeout.timeout =
|
32
|
+
use Rack::Timeout # Call as early as possible so rack-timeout runs before all other middleware.
|
33
|
+
Rack::Timeout.timeout = 5 # Recommended. If omitted, defaults to 15 seconds.
|
35
34
|
|
36
35
|
|
37
|
-
|
36
|
+
The Rabbit Hole
|
38
37
|
---------------
|
39
38
|
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
### Service Timeout
|
40
|
+
|
41
|
+
`Rack::Timeout.timeout` (or `Rack::Timeout.service_timeout`) is our principal setting.
|
42
|
+
|
43
|
+
*Service time* is the time taken from when a request first enters rack to when its response is sent back. When the application takes longer than `service_timeout` to process a request, the request's status is logged as `timed_out` and a `Rack::Timeout::RequestTimeoutError` error is raised on the application thread. This may be automatically caught by the framework or plugins, so beware. Also, the error is not guaranteed to be raised in a timely fashion, see section below about IO blocks.
|
44
|
+
|
45
|
+
Service timeout can be disabled entirely by setting the property to `0` or `false`, at which point the request skips Rack::Timeout's machinery (so no logging will be present).
|
46
|
+
|
47
|
+
|
48
|
+
### Wait Timeout
|
49
|
+
|
50
|
+
Before a request reaches the rack application, it may have spent some time being received by the web server, or waiting in the application server's queue before being dispatched to rack. The time between when a request is received by the web server and when rack starts handling it is called the *wait time*.
|
51
|
+
|
52
|
+
On Heroku, a request will be dropped when the routing layer sees no data being transferred for over 30 seconds. (You can read more about the specifics of Heroku routing's timeout [here][heroku-routing] and [here][heroku-timeout].) In this case, it makes no sense to process a request that reaches the application after having waited more than 30 seconds. That's where the `Rack::Timeout.wait_timeout` setting comes in. When a request has a wait time greater than `wait_timeout`, it'll be dropped without ever being sent down to the application, and a `Rack::Timeout::RequestExpiryError` is raised. Such requests are logged as `expired`.
|
53
|
+
|
54
|
+
[heroku-routing]: https://devcenter.heroku.com/articles/http-routing#timeouts
|
55
|
+
[heroku-timeout]: https://devcenter.heroku.com/articles/request-timeout
|
56
|
+
|
57
|
+
`Rack::Timeout.wait_timeout` is set at a default of 30 seconds, matching Heroku's router's timeout.
|
58
|
+
|
59
|
+
Wait timeout can be disabled entirely by setting the property to `0` or `false`.
|
60
|
+
|
61
|
+
A request's computed wait time may affect the service timeout used for it. Basically, a request's wait time plus service time may not exceed the wait timeout. The reasoning for that is based on Heroku router's behavior, that the request would be dropped anyway after the wait timeout. So, for example, with the default settings of `service_timeout=15`, `wait_timeout=30`, a request that had 20 seconds of wait time will not have a service timeout of 15, but instead of 10, as there are only 10 seconds left before `wait_timeout` is reached. This behavior can be disabled by setting `Rack::Timeout.service_past_wait` to `true`. When set, the `service_timeout` setting will always be honored.
|
62
|
+
|
63
|
+
The way we're able to infer a request's start time, and from that its wait time, is through the availability of the `X-Request-Start` HTTP header, which is expected to contain the time since epoch in milliseconds. (A concession is made for nginx's sec.msec notation.)
|
64
|
+
|
65
|
+
If the `X-Request-Start` header is not present `wait_timeout` handling is skipped entirely.
|
66
|
+
|
43
67
|
|
44
|
-
|
45
|
-
into consideration when determining the timeout to use. If a request is older than 30 seconds,
|
46
|
-
it's dropped immediately. Otherwise, the timeout is the number of seconds left for the request
|
47
|
-
to be 30 seconds old, or the value of `Rack::Timeout.timeout`, whichever is shorter.
|
68
|
+
### Wait Overtime
|
48
69
|
|
49
|
-
|
50
|
-
10s, the timeout used will be 5s, because `30 − 25 = 5`, and `5 < 10`.
|
70
|
+
Relying on `X-Request-Start` is less than ideal, as it computes the time since the request *started* being received by the web server, rather than the time the request *finished* being received by the web server. That poses a problem for lengthy requests.
|
51
71
|
|
52
|
-
|
53
|
-
transferred within 30s, so it makes no sense for the application to process a request it'll
|
54
|
-
never be able to respond to. (This is actually [a bit more involved][heroku-routing].)
|
72
|
+
Lengthy requests are requests with a body, such as POST requests. These take time to complete being received by the application server, especially when the client has a slow upload speed, as is common for example with mobile clients or asymmetric connections.
|
55
73
|
|
56
|
-
|
57
|
-
altered.
|
74
|
+
While we can infer the time since a request started being received, we can't tell when it completed being received, which would be preferable. We're also unable to tell the time since the last byte was sent in the request, which would be relevant in tracking Heroku's router timeout appropriately.
|
58
75
|
|
59
|
-
|
60
|
-
requests. X-Request-Start is set when the Heroku router begins receiving the request, but rack
|
61
|
-
will generally only see the request after it's been fully received by the application server
|
62
|
-
(i.e. thin, unicorn, etc). For short requests such as GET requests, this is irrelevant. But
|
63
|
-
with a slow client (say, a mobile app performing a file upload) the request can take a long
|
64
|
-
time to be fully received. A request that took longer than 30s to transmit would be dropped
|
65
|
-
immediately by Rack::Timeout because it'd be considered too old. The Heroku router, however,
|
66
|
-
would not have dropped this request because it would have been transmitting data all along.
|
76
|
+
A request that took longer than 30s to be fully received, but that had been uploading data all that while, would be dropped immediately by Rack::Timeout because it'd be considered too old. Heroku's router, however, would not have dropped this request because data was being transmitted all along.
|
67
77
|
|
68
|
-
|
69
|
-
default overtime is 60s, on top of the 30s `MAX_REQUEST_AGE`. This is user-configurable with
|
70
|
-
the `Rack::Timeout.overtime` setting:
|
78
|
+
As a concession to these shortcomings, for requests that have a body present, we allow some additional wait time on top of `wait_timeout`. This aims to make up for time lost to long uploads.
|
71
79
|
|
72
|
-
|
80
|
+
This extra time is called *wait overtime* and can be set via `Rack::Timeout.wait_overtime`. It defaults to 60 seconds. This can be disabled as usual by setting the property to `0` or `false`. When disabled, there's no overtime. If you want lengthy requests to never get expired, set `wait_overtime` to a very high number.
|
73
81
|
|
74
|
-
|
75
|
-
`Heroku-Request-ID` header; if not present, it'll then check `X-Request-ID`; and lastly, it'll
|
76
|
-
generate its own.
|
82
|
+
Keep in mind that Heroku [recommends][uploads] uploading large files directly to S3, so as to prevent the dyno from being blocked for too long and hence unable to handle further incoming requests.
|
77
83
|
|
78
|
-
|
79
|
-
[http-request-id labs feature][http-request-id]. It's recommended to enable http-request-id as
|
80
|
-
it allows one to correlate Rack::Timeout events with the Heroku router's events. There are no
|
81
|
-
downsides to enabling http-request-id.
|
84
|
+
[uploads]: https://devcenter.heroku.com/articles/s3#file-uploads
|
82
85
|
|
83
|
-
[X-Request-Start]: https://devcenter.heroku.com/articles/http-routing#heroku-headers
|
84
|
-
[heroku-routing]: https://devcenter.heroku.com/articles/http-routing#timeouts
|
85
|
-
[http-request-id]: https://devcenter.heroku.com/articles/http-request-id
|
86
86
|
|
87
|
-
|
88
|
-
|
87
|
+
### Timing Out During IO Blocks
|
88
|
+
|
89
|
+
Sometimes a request is taking too long to complete because it's blocked waiting on synchronous IO. Such IO does not need to be file operations, it could be, say, network or database operations. If said IO is happening in a C library that's unaware of ruby's interrupt system (i.e. anything written without ruby in mind), calling `Thread#raise` (that's what rack-timeout uses) will not have effect until after the IO block is gone.
|
90
|
+
|
91
|
+
At the moment rack-timeout does not try to address this issue. As a fail-safe against these cases, a blunter solution that kills the entire process is recommended, such as unicorn's timeouts.
|
92
|
+
|
93
|
+
More detailed explanations of the issues surrounding timing out in ruby during IO blocks can be found at:
|
94
|
+
|
95
|
+
- http://redgetan.cc/understanding-timeouts-in-cruby/
|
96
|
+
- https://shellycloud.com/blog/2013/06/the-pesky-problem-of-freezing-thin
|
97
|
+
|
98
|
+
|
99
|
+
### Timing Out Inherently Unsafe
|
100
|
+
|
101
|
+
Raising mid-flight in stateful applications is inherently unsafe. A request can be aborted at any moment in the code flow, and the application cam be left in an inconsistent state. There's little way rack-timeout could be aware of ongoing state changes. Applications that rely on a set of globals (like class variables) or any other state that lives beyond a single request may find those left in an unexpected/inconsistent state after an aborted request. Some cleanup code might not have run, or only half of a set of related changes may have been applied.
|
102
|
+
|
103
|
+
A lot more can go wrong. An intricate explanation of the issue by JRuby's Charles Nutter can be found [here][broken-timeout].
|
104
|
+
|
105
|
+
Ruby 2.1 provides a way to defer the result of raising exceptions through the [Thread.handle_interrupt][handle-interrupt] method. This could be used in critical areas of your application code to prevent Rack::Timeout from accidentally wreaking havoc by raising just in the wrong moment. That said, `handle_interrupt` and threads in general are hard to reason about, and detecting all cases where it would be needed in an application is a tall order, and the added code complexity is probably not worth the trouble.
|
106
|
+
|
107
|
+
Your time is better spent ensuring requests run fast and don't need to timeout.
|
108
|
+
|
109
|
+
That said, it's something to be aware of, and may explain some eerie wonkiness seen in logs.
|
110
|
+
|
111
|
+
[broken-timeout]: http://headius.blogspot.de/2008/02/rubys-threadraise-threadkill-timeoutrb.html
|
112
|
+
[handle-interrupt]: http://www.ruby-doc.org/core-2.1.3/Thread.html#method-c-handle_interrupt
|
89
113
|
|
90
114
|
|
91
115
|
Request Lifetime
|
92
116
|
----------------
|
93
117
|
|
94
|
-
Throughout a request's lifetime, Rack::Timeout keeps details about the request in
|
95
|
-
`env[Rack::Timeout::ENV_INFO_KEY]`, or, more explicitly, `env["rack-timeout.info"]`.
|
118
|
+
Throughout a request's lifetime, Rack::Timeout keeps details about the request in `env[Rack::Timeout::ENV_INFO_KEY]`, or, more explicitly, `env["rack-timeout.info"]`.
|
96
119
|
|
97
|
-
The value of that entry is an instance of `Rack::Timeout::RequestDetails`, which is a `Struct`
|
98
|
-
containing the following fields:
|
120
|
+
The value of that entry is an instance of `Rack::Timeout::RequestDetails`, which is a `Struct` consisting of the following fields:
|
99
121
|
|
100
|
-
* `id`: a unique ID per request. Either
|
122
|
+
* `id`: a unique ID per request. Either the value of the `X-Request-ID` header or a random ID
|
101
123
|
generated internally.
|
102
124
|
|
103
|
-
* `wait`: time in seconds since `X-Request-Start`
|
104
|
-
Only set if `X-Request-Start` is present.
|
125
|
+
* `wait`: time in seconds since `X-Request-Start` at the time the request was initially seen by Rack::Timeout. Only set if `X-Request-Start` is present.
|
105
126
|
|
106
|
-
* `timeout`: timeout to be used, in seconds.
|
107
|
-
`X-Request-Start` is present. See discussion above, under the Heroku Niceties section.
|
127
|
+
* `timeout`: the final timeout value that was used or to be used, in seconds. For `expired` requests, that would be the `wait_timeout`, possibly with `wait_overtime` applied. In all other cases it's the `service_timeout`, potentially reduced to make up for time lost waiting. (See discussion regarding `service_past_wait` above, under the Wait Timeout section.)
|
108
128
|
|
109
|
-
* `service`: set after a request completes (or times out). The time in seconds it took. This is
|
110
|
-
also updated while a request is still active, around every second, with the time it's taken so
|
111
|
-
far.
|
129
|
+
* `service`: set after a request completes (or times out). The time in seconds it took being processed. This is also updated while a request is still active, around every second, with the time taken so far.
|
112
130
|
|
113
|
-
* `state`: the possible states are:
|
131
|
+
* `state`: the possible states, and their log level, are:
|
114
132
|
|
115
|
-
* `expired
|
116
|
-
`X-Request-Start` is present and older than 30s. When this happens, a
|
117
|
-
`Rack::Timeout::RequestExpiryError` exception is raised. See earlier discussion about the
|
118
|
-
`Rack::Timeout.overtime` setting, too.
|
133
|
+
* `expired` (`ERROR`): the request is considered too old and is skipped entirely. This happens when `X-Request-Start` is present and older than `wait_timeout`. When in this state, a `Rack::Timeout::RequestExpiryError` exception is raised. See earlier discussion about the `wait_overtime` setting, too.
|
119
134
|
|
120
|
-
* `ready
|
121
|
-
chain. While it's being processed, it'll move on to `active`, and then on to `timed_out`
|
122
|
-
and/or `completed`.
|
135
|
+
* `ready` (`INFO`): this is the state a request is in right before it's passed down the middleware chain. Once it's being processed, it'll move on to `active`, and then on to `timed_out` and/or `completed`.
|
123
136
|
|
124
|
-
* `active
|
125
|
-
signaled repeatedly every ~1s until the request completes or times out.
|
137
|
+
* `active` (`DEBUG`): the request is being actively processed in the application thread. This is signaled repeatedly every ~1s until the request completes or times out.
|
126
138
|
|
127
|
-
* `timed_out
|
128
|
-
`Rack::Timeout::RequestTimeoutError` error is raised in the application when this occurs.
|
129
|
-
If this error gets caught and handled and not re-raised in the app or framework (which will
|
130
|
-
generally happen with Rails and Sinatra), this state will not be final, `completed` will be
|
131
|
-
set after the framework is done with it.
|
139
|
+
* `timed_out` (`ERROR`): the request ran for longer than the determined timeout and was aborted. A `Rack::Timeout::RequestTimeoutError` error is raised in the application when this occurs. If this error gets caught, handled, and not re-raised in the app or framework (which will generally happen with Rails and Sinatra), this state will not be final, `completed` will be set after the framework is done with it.
|
132
140
|
|
133
|
-
* `completed
|
134
|
-
mean the request completed *successfully*. Rack::Timeout does not concern itself with that.
|
135
|
-
As mentioned just above, a timed out request may still end up with a `completed` state.
|
141
|
+
* `completed` (`INFO`): the request completed and Rack::Timeout is done with it. This does not mean the request completed *successfully*. Rack::Timeout does not concern itself with that. As mentioned just above, a timed out request may still end up with a `completed` state if the framework has dealt with the timeout exception.
|
136
142
|
|
137
143
|
|
138
144
|
Errors
|
139
145
|
------
|
140
146
|
|
141
|
-
Rack::Timeout can raise two types of exceptions. Both descend from `Rack::Timeout::Error`, which
|
142
|
-
itself descends from `RuntimeError`. They are:
|
147
|
+
Rack::Timeout can raise two types of exceptions. Both descend from `Rack::Timeout::Error`, which itself descends from `RuntimeError`. They are:
|
143
148
|
|
144
|
-
* `Rack::Timeout::RequestTimeoutError`: this is raised when a request has run for longer than the
|
145
|
-
specified timeout. This is raised by the rack-timeout timer thread in the application thread,
|
146
|
-
at the point in the stack the app happens to be in when the timeout is triggered. This
|
147
|
-
exception can generally be caught within the application, but in doing so you're working past
|
148
|
-
the timeout. This is ok for quick cleanups but shouldn't be abused as Rack::Timeout will not
|
149
|
-
kick in twice for the same request.
|
149
|
+
* `Rack::Timeout::RequestTimeoutError`: this is raised when a request has run for longer than the specified timeout. It's raised by the rack-timeout timer thread in the application thread, at the point in the stack the app happens to be in when the timeout is triggered. This exception can generally be caught within the application, but in doing so you're working past the timeout. This is ok for quick cleanup work but shouldn't be abused as Rack::Timeout will not kick in twice for the same request.
|
150
150
|
|
151
|
-
* `Rack::Timeout::RequestExpiryError`: this is raised when a request is skipped for being too old
|
152
|
-
(see the X-Request-Start bit under the Heroku Niceties section). This cannot generally be
|
153
|
-
rescued from inside a Rails controller action as it happens before the request has a chance to
|
154
|
-
reach Rails.
|
151
|
+
* `Rack::Timeout::RequestExpiryError`: this is raised when a request is skipped for being too old (see Wait Timeout section). This error cannot generally be rescued from inside a Rails controller action as it happens before the request has a chance to enter Rails.
|
155
152
|
|
156
|
-
This shouldn't be
|
157
|
-
Rack::Timeout in the middleware stack, which you generally shouldn't.
|
153
|
+
This shouldn't be different for other frameworks, unless you have something above Rack::Timeout in the middleware stack, which you generally shouldn't.
|
158
154
|
|
159
|
-
You shouldn't rescue from these errors for reporting purposes. Instead, you can subscribe for state
|
160
|
-
change notifications with observers.
|
155
|
+
You shouldn't rescue from these errors for reporting purposes. Instead, you can subscribe for state change notifications with observers.
|
161
156
|
|
162
|
-
If you're trying to test that a `Rack::Timeout::RequestTimeoutError` is raised in an action in your
|
163
|
-
Rails application, you **must do so in integration tests**. Please note that Rack::Timeout will not
|
164
|
-
kick in for functional tests as they bypass the rack middleware stack.
|
157
|
+
If you're trying to test that a `Rack::Timeout::RequestTimeoutError` is raised in an action in your Rails application, you **must do so in integration tests**. Please note that Rack::Timeout will not kick in for functional tests as they bypass the rack middleware stack.
|
165
158
|
|
166
159
|
[More details about testing middleware with Rails here][pablobm].
|
167
160
|
|
@@ -171,30 +164,19 @@ kick in for functional tests as they bypass the rack middleware stack.
|
|
171
164
|
Observers
|
172
165
|
---------
|
173
166
|
|
174
|
-
Observers are objects or blocks that are notified about state changes during a request lifetime.
|
167
|
+
Observers are objects or blocks that are notified about state changes during a request's lifetime.
|
175
168
|
|
176
169
|
You can register an observer easily with a block:
|
177
170
|
|
178
171
|
Rack::Timeout.register_state_change_observer(:a_unique_name) { |env| do_things env }
|
179
172
|
|
180
|
-
|
181
|
-
|
182
|
-
class MyObserver
|
183
|
-
def rack_timeout_request_did_change_state_in(env)
|
184
|
-
# ... do stuff ...
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
188
|
-
Rack::Timeout.register_state_change_observer(:another_name, MyObserver.new)
|
189
|
-
|
190
|
-
This is how logging is implemented, too. See `Rack::Timeout::StateChangeLogger`.
|
173
|
+
This is how logging is implemented, too. See `Rack::Timeout::StageChangeLoggingObserver`.
|
191
174
|
|
192
175
|
You can remove an observer with `unregister_state_change_observer`:
|
193
176
|
|
194
177
|
Rack::Timeout.unregister_state_change_observer(:a_unique_name)
|
195
178
|
|
196
|
-
Custom observers might be used to store statistics on request length, timeouts, etc., and
|
197
|
-
potentially do performance tuning on the fly.
|
179
|
+
Custom observers might be used to store statistics on request length, timeouts, etc., and potentially do performance tuning on the fly.
|
198
180
|
|
199
181
|
|
200
182
|
Logging
|
@@ -202,30 +184,21 @@ Logging
|
|
202
184
|
|
203
185
|
Rack::Timeout logs a line every time there's a change in state in a request's lifetime.
|
204
186
|
|
205
|
-
Changes into `timed_out` and `expired` are logged at the `ERROR` level, most other things are
|
206
|
-
logged as `INFO`.
|
187
|
+
Changes into `timed_out` and `expired` are logged at the `ERROR` level, most other things are logged as `INFO`. The `active` state is logged as `DEBUG`, every ~1s while the request is still active.
|
207
188
|
|
208
|
-
|
189
|
+
Rack::Timeout will try to use Rails.logger if present, otherwise it'll look for a logger in `env['rack.logger']`, and if neither are present, it'll create its own logger, either writing to `env['rack.errors']`, or to `$stderr` if the former is not set.
|
209
190
|
|
210
|
-
|
191
|
+
A custom logger can be set via `Rack::Timeout::StageChangeLoggingObserver.logger`. This takes priority over the automatic logger detection:
|
211
192
|
|
212
|
-
|
213
|
-
value must be name of a predefined constant in ruby's `Logger` class, e.g. `INFO` or `DEBUG`.
|
214
|
-
Case is not significant.
|
193
|
+
Rack::Timeout::StageChangeLoggingObserver.logger = Logger.new
|
215
194
|
|
216
|
-
|
195
|
+
When creating its own logger, rack-timeout will use a log level of `INFO`. Otherwise whatever log level is already set on the logger being used continues in effect.
|
217
196
|
|
218
|
-
|
219
|
-
|
220
|
-
Logging is enabled by default if Rack::Timeout is loaded via the `rack-timeout` file (recommended),
|
221
|
-
but can be removed by unregistering its observer:
|
197
|
+
Logging is enabled by default if Rack::Timeout is loaded via the `rack-timeout` file (recommended), but can be removed by unregistering its observer:
|
222
198
|
|
223
199
|
Rack::Timeout.unregister_state_change_observer(:logger)
|
224
200
|
|
225
|
-
Each log line is a set of `key=value` pairs, containing the entries from the
|
226
|
-
`env["rack-timeout.info"]` struct that are not `nil`. See the Request Lifetime section above for a
|
227
|
-
description of each field. Note that while the values for `wait`, `timeout`, and `service` are
|
228
|
-
stored internally as seconds, they are logged as milliseconds for readability.
|
201
|
+
Each log line is a set of `key=value` pairs, containing the entries from the `env["rack-timeout.info"]` struct that are not `nil`. See the Request Lifetime section above for a description of each field. Note that while the values for `wait`, `timeout`, and `service` are stored internally as seconds, they are logged as milliseconds for readability.
|
229
202
|
|
230
203
|
A sample log excerpt might look like:
|
231
204
|
|
@@ -233,20 +206,17 @@ A sample log excerpt might look like:
|
|
233
206
|
source=rack-timeout id=13793c wait=369ms timeout=10000ms service=15ms state=completed at=info
|
234
207
|
source=rack-timeout id=ea7bd3 wait=371ms timeout=10000ms state=timed_out at=error
|
235
208
|
|
236
|
-
(IDs shortened for readability.)
|
237
|
-
|
238
209
|
|
239
210
|
Compatibility
|
240
211
|
-------------
|
241
212
|
|
242
|
-
This version of Rack::Timeout is compatible with Ruby 1.9.1 and up, and, for Rails apps, Rails 3.x
|
243
|
-
and up.
|
213
|
+
This version of Rack::Timeout is compatible with Ruby 1.9.1 and up, and, for Rails apps, Rails 3.x and up.
|
244
214
|
|
245
215
|
For applications running Ruby 1.8.x and/or Rails 2.x, use [version 0.0.4][v0.0.4].
|
246
216
|
|
247
|
-
[v0.0.4]: https://github.com/
|
217
|
+
[v0.0.4]: https://github.com/heroku/rack-timeout/tree/v0.0.4
|
248
218
|
|
249
219
|
|
250
220
|
---
|
251
|
-
Copyright © 2010-
|
252
|
-
<http://github.com/
|
221
|
+
Copyright © 2010-2014 Caio Chassot, released under the MIT license
|
222
|
+
<http://github.com/heroku/rack-timeout>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-timeout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Caio Chassot
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rack middleware which aborts requests that have been running for longer
|
14
14
|
than a specified timeout.
|
@@ -22,7 +22,7 @@ files:
|
|
22
22
|
- lib/rack-timeout.rb
|
23
23
|
- lib/rack/timeout.rb
|
24
24
|
- lib/rack/timeout/logger.rb
|
25
|
-
homepage: http://github.com/
|
25
|
+
homepage: http://github.com/heroku/rack-timeout
|
26
26
|
licenses:
|
27
27
|
- MIT
|
28
28
|
metadata: {}
|
@@ -37,9 +37,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - "
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: '0'
|
43
43
|
requirements: []
|
44
44
|
rubyforge_project:
|
45
45
|
rubygems_version: 2.2.2
|