如何在HAProxy中添加X-Request-Start?

问题描述 投票:3回答:2

我们想跟踪请求队列时间,并且根据https://docs.newrelic.com/docs/apm/other-features/request-queueing/configuring-request-queue-reporting,我们需要添加X-Request-StartX-Queue-Start以及时间戳(以毫秒为单位)。

newrelic haproxy
2个回答
5
投票

解决方案是在frontend块中添加此行。你需要一个HTTP和HTTPS。

http-request set-header X-Request-Start t=%Ts%ms


2
投票

使用%Ts不是正确的解决方案,因为它是会话的开始时间(流)而不是请求时间。多个请求将使用相同的%Ts时间。 See more details here

haproxy版本<1.9的正确解决方案是在frontend块中使用以下内容。不幸的是它只有秒数分辨率。

http-request set-header X-Request-Start t=%[date()]

如果您使用的是haproxy版本> = 1.9,则可以使用新的样本获取方法date_us()来获取微秒分辨率。

http-request set-header X-Request-Start t=%[date()]%[date_us()]

注意:The newrelic agents can automatically handle timestamps values sent using seconds, milliseconds, or as microseconds

© www.soinside.com 2019 - 2024. All rights reserved.