nginx-devel Digest, Vol 38, Issue 2
Maxim Dounin
mdounin at mdounin.ru
Tue Dec 4 10:42:21 UTC 2012
Hello!
On Tue, Dec 04, 2012 at 04:57:32PM +1100, Lawrence Pit wrote:
> >>After I finished this patch I checked the 1.3 branch, and noticed it
> >>already has an $msec http variable defined. But it's output is with a
> >>dot character before the milliseconds part. Why is that?
> >
> >http {
> > map $msec $s {
> > ~(?<x>.*)\. $x;
> > }
> >
> > map $msec $ms {
> > ~\.(?<x>.*) $x;
> > }
> >
> > server {
> > return 200 "msec=$msec usec=${s}${ms}000\n";
> > }
> >}
> >
> >$ curl http://localhost:8000/
> >msec=1354471012.591 usec=1354471012591000
>
> That's cool, impressive. Though ugly ;) If it needs to do that for
> every request it's relatively expensive compared to what I'd rather
> do:
>
> proxy_set_header X-Queue-Start "${msec}000";
>
> Is there any objection to not output the dot character starting from
> the 1.3 release?
>
> My reason for not using the dot character is that it seems like an
> arbitrary view concern to me and when the value is not used for
> logging purposes it's most likely to be used for calculations or
> conversions; in which case not having to parse out the dot character
> makes things simpler.
I consider dot character very valuable here, as it simplifies both
reading such numbers and calculations with them, as well as
eliminates measurment units confusion (much like what Time::HiRes
does with time() in Perl). The format also matches all other time
variables nginx exports, like $request_time,
$upstream_response_time and so on.
In any case, the $msec variable appeared in nginx 0.3.8, 7 years ago
(log_format only at that time), and there are no plans to change it's
semantics.
--
Maxim Dounin
http://nginx.com/support.html
More information about the nginx-devel
mailing list