MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / MetricValue

Method MetricValue

internal/nodes/http_request_metrics.go:20–40  ·  view source on GitHub ↗
(value string)

Source from the content-addressed store, hash-verified

18}
19
20func (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
42func (this *HTTPRequest) MetricServerId() int64 {
43 return this.ReqServer.Id

Callers

nothing calls this directly

Calls 1

SentBodyBytesMethod · 0.80

Tested by

no test coverage detected