5

I would like to measure the time of full request stack. The New Relic capture time of the middleware (e.g. java, python, ruby) and request time (See https://newrelic.com/docs/features/tracking-front-end-time). For this, I need to configure the X-Request-Start header as the request pass through the HAProxy load balance. The haproxy.cfg should look like:

backend www
  balance roundrobin
  mode http
reqadd      "X-Request-Start"  UNKNOWN_TIME_FUNCTION()
server servername 192.168.0.1:80 weight 1 check

There is a haproxy native function to replace the UNKNOWN_TIME_FUNCTION()?

Tupy
  • 153
  • 4
  • Out of curiosity, are you front loading your haproxy with an nginx? I'm wary of recompiling nginx with the provided patch – John K. Chow Nov 20 '12 at 04:21
  • No, my front is HAProxy which pass the requests to nginx. – Tupy Jan 24 '13 at 02:02
  • 1
    I'm curious, @Tupy, did you ever discover a solution to this? I would also like to setup New Relic to work with HAProxy. – Chris W. Mar 01 '13 at 20:06

1 Answers1

3

You can't do that right now, though it will be possible after we can pass SSL info because we'll permit to pass any dynamic information in a header. This piece of information would as well be the current time.

If you absolutely need this, it's not terribly difficult to implement in the code. Ideally it should be done in the function which is also able to send the server name in a header, so that in case of connect retry or redispatch, the time is updated, though that does not seem critical.

Oh and BTW, why don't you simply use haproxy's logs as everyone to measure your precise processing time ? It does exactly what you need with more details (eg: split connect/processing/transfer) without having to change anything in the server, and with more accuracy (having two machines synchronized at less than 1 millisecond is not easy).

Willy Tarreau
  • 3,896
  • 1
  • 20
  • 12