(value string)
| 18 | } |
| 19 | |
| 20 | func (this *HTTPRequest) MetricValue(value string) (result int64, ok bool) { |
| 21 | // TODO 需要忽略健康检查的请求,但是同时也要防止攻击者模拟健康检查 |
| 22 | switch value { |
| 23 | case "${countRequest}": |
| 24 | return 1, true |
| 25 | case "${countTrafficOut}": |
| 26 | // 这里不包括Header长度 |
| 27 | return this.writer.SentBodyBytes(), true |
| 28 | case "${countTrafficIn}": |
| 29 | var hl int64 = 0 // header length |
| 30 | for k, values := range this.RawReq.Header { |
| 31 | for _, v := range values { |
| 32 | hl += int64(len(k) + len(v) + 2 /** k: v **/) |
| 33 | } |
| 34 | } |
| 35 | return this.RawReq.ContentLength + hl, true |
| 36 | case "${countConnection}": |
| 37 | return 1, true |
| 38 | } |
| 39 | return 0, false |
| 40 | } |
| 41 | |
| 42 | func (this *HTTPRequest) MetricServerId() int64 { |
| 43 | return this.ReqServer.Id |
nothing calls this directly
no test coverage detected