Is microsecond precision available in an iRule?
I am trying to get to microsecond precision in an iRule I am working on.
Based on reading the Tcl docs that I found a link to on this site (http://tmml.sourceforge.net/doc/tcl/index.html) I would expect "clock microseconds" to have worked. A bit more digging and experimentation after I got an error I would have expected "clock clicks -microseconds" to have worked. After that also triggered an error I started digging through the forums. At this point I'm not sure that microsecond precision is available but I haven't been able to find definitive documentation saying that. I tried to figure out the level of Tcl support that I should expect but have been unable to do so. I'm reasonably certain that I'm on a BigIP 6900 at version 10.2.1.
What I'm ultimately trying to achieve is an iRule that inserts a header named "X-Request-Start" that inserts a value like "t=1304697000869668". The following is what I have right now. There is a bit of debugging/development cruft in this version.
when HTTP_REQUEST {
set now t=[clock clicks]
set x_request_start "X-Request-Start"
set big_ip_x_request_start "BigIP-X-Request-Start"
HTTP::header remove $x_request_start
HTTP::header remove $big_ip_x_request_start
HTTP::header insert $x_request_start $now
HTTP::header insert $big_ip_x_request_start $now
HTTP::header insert X-HELLO there
}
Trimming that down to a focused version of what I'm really after one would get something like
when HTTP_REQUEST {
set now t=[clock microseconds]
set x_request_start "X-Request-Start"
HTTP::header remove $x_request_start
HTTP::header insert $x_request_start $now
}
The Tcl documentation for "clock clicks" states that without "If no -option argument is supplied, returns a high-resolution time value as a system-dependent integer value." I tried that hoping to get microseconds, I instead got a negative value that won't be useful to me.
this value came from an intermediate Apache server that inserted the sort of value I'm trying to achieve
t=1304702175756372
this value from "HTTP::header insert $big_ip_x_request_start $now" above
t=-1510467564
Can anyone explain what clicks means within an iRule? If I can't get to microseconds, can I get to milliseconds? I tried both "clicks -milliseconds" and "clock milliseconds" and go results that mirrored what I've seen attempting to get microseconds so I don't think milliseconds is available either.