Hello!
On Tue, Dec 11, 2012 at 04:44:52PM +0000, Jonathan M. wrote:
On 11 December 2012 15:01, Maxim D. [email protected] wrote:
Changes with nginx 1.2.6 11 Dec 2012
*) Feature: the $request_time and $msec variables can now be used not
only in the "log_format" directive.
This is great! Could you give some examples of other variables that
these can now be considered similar to, with respect to when and where
they’re available for use?
There are some (semi-)variables which were only available in the
log_format directive, see here for a full list:
http://nginx.org/r/log_format
These variables wasn’t available as generic ones as they weren’t
expected to be usable during request processing. For now this
aproach is reconsidered, and the plan is to eventually make all such
variables generic, even if they don’t make much sense till request
processing is complete. This will allow, in particular, to use
such variables in other modules similar to ngx_http_log_module, or
to log some derivative variables using map{}.
Semantic of such variables didn’t change when they are made
available as generic variables as long as they are used in the
“log_format” directive, i.e. evaluated during request logging. If
you’ll try to use them at other phases of a request processing, in
some cases previous definitions no longer apply or slightly
changes.
E.g. $msec, previously defined as (quote from
Module ngx_http_log_module):
time in seconds with a milliseconds resolution at the time of
log write
now defined as (quote from
Module ngx_http_core_module):
current time in seconds with a milliseconds resolution
Where “current” means a time of the variable evaluation. E.g. if
you’ll use it in proxy_set_header directive, it will be the time
when request to an upstream was created.
The $request_time was defined as (quote from
Module ngx_http_log_module):
request processing time in seconds with a milliseconds
resolution; time elapsed between the first bytes were read from
the client and the log write after the last bytes were sent to the
client
It remains the same when used in log format, but more generic
definition is now available (quote from
Module ngx_http_core_module):
request processing time in seconds with a milliseconds
resolution (1.3.9, 1.2.6); time elapsed since the first bytes were
read from the client
Much like $msec, if you’ll use it in proxy_set_header, it will be
the time from a request start till nginx created a request to an
upstream. And if used in add_header, it will be the time from a
request start till sending response headers to a client.
Hope this helps.
–
Maxim D.