Remove request forwarding measurement from log
This commit is contained in:
parent
578c090890
commit
af096f8488
|
@ -5,7 +5,6 @@ import (
|
|||
"math/rand"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/jedisct1/dlog"
|
||||
|
@ -93,9 +92,7 @@ func (plugin *PluginForward) Eval(pluginsState *PluginsState, msg *dns.Msg) erro
|
|||
return nil
|
||||
}
|
||||
server := servers[rand.Intn(len(servers))]
|
||||
reqStart := time.Now()
|
||||
respMsg, err := dns.Exchange(msg, server)
|
||||
pluginsState.forwardDuration = time.Now().Sub(reqStart)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -71,11 +71,10 @@ func (plugin *PluginQueryLog) Eval(pluginsState *PluginsState, msg *dns.Msg) err
|
|||
returnCode = string(returnCode)
|
||||
}
|
||||
|
||||
var requestDuration, forwardDuration time.Duration
|
||||
var requestDuration time.Duration
|
||||
if !pluginsState.requestStart.IsZero() && !pluginsState.requestEnd.IsZero() {
|
||||
requestDuration = pluginsState.requestEnd.Sub(pluginsState.requestStart)
|
||||
}
|
||||
forwardDuration = pluginsState.forwardDuration
|
||||
|
||||
var line string
|
||||
if plugin.format == "tsv" {
|
||||
|
@ -83,10 +82,10 @@ func (plugin *PluginQueryLog) Eval(pluginsState *PluginsState, msg *dns.Msg) err
|
|||
year, month, day := now.Date()
|
||||
hour, minute, second := now.Clock()
|
||||
tsStr := fmt.Sprintf("[%d-%02d-%02d %02d:%02d:%02d]", year, int(month), day, hour, minute, second)
|
||||
line = fmt.Sprintf("%s\t%s\t%s\t%s\t%s\t%d\t%d\n", tsStr, clientIPStr, StringQuote(qName), qType, returnCode, requestDuration/time.Millisecond, forwardDuration/time.Millisecond)
|
||||
line = fmt.Sprintf("%s\t%s\t%s\t%s\t%s\t%d\n", tsStr, clientIPStr, StringQuote(qName), qType, returnCode, requestDuration/time.Millisecond)
|
||||
} else if plugin.format == "ltsv" {
|
||||
line = fmt.Sprintf("time:%d\thost:%s\tmessage:%s\ttype:%s\treturn:%s\treqDuration:%d\tfwdDuration:%d\n",
|
||||
time.Now().Unix(), clientIPStr, StringQuote(qName), qType, returnCode, requestDuration/time.Millisecond, forwardDuration/time.Millisecond)
|
||||
line = fmt.Sprintf("time:%d\thost:%s\tmessage:%s\ttype:%s\treturn:%s\tduration:%d\n",
|
||||
time.Now().Unix(), clientIPStr, StringQuote(qName), qType, returnCode, requestDuration/time.Millisecond)
|
||||
} else {
|
||||
dlog.Fatalf("Unexpected log format: [%s]", plugin.format)
|
||||
}
|
||||
|
|
|
@ -73,7 +73,6 @@ type PluginsState struct {
|
|||
questionMsg *dns.Msg
|
||||
requestStart time.Time
|
||||
requestEnd time.Time
|
||||
forwardDuration time.Duration
|
||||
returnCode PluginsReturnCode
|
||||
}
|
||||
|
||||
|
|
|
@ -362,13 +362,11 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
return
|
||||
}
|
||||
serverInfo.noticeBegin(proxy)
|
||||
reqStart := time.Now()
|
||||
if serverProto == "udp" {
|
||||
response, err = proxy.exchangeWithUDPServer(serverInfo, sharedKey, encryptedQuery, clientNonce)
|
||||
} else {
|
||||
response, err = proxy.exchangeWithTCPServer(serverInfo, sharedKey, encryptedQuery, clientNonce)
|
||||
}
|
||||
pluginsState.forwardDuration = time.Now().Sub(reqStart)
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeServerError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
|
@ -379,9 +377,8 @@ func (proxy *Proxy) processIncomingQuery(serverInfo *ServerInfo, clientProto str
|
|||
tid := TransactionID(query)
|
||||
SetTransactionID(query, 0)
|
||||
serverInfo.noticeBegin(proxy)
|
||||
resp, duration, err := proxy.xTransport.DoHQuery(serverInfo.useGet, serverInfo.URL, query, proxy.timeout)
|
||||
resp, _, err := proxy.xTransport.DoHQuery(serverInfo.useGet, serverInfo.URL, query, proxy.timeout)
|
||||
SetTransactionID(query, tid)
|
||||
pluginsState.forwardDuration = duration
|
||||
if err != nil {
|
||||
pluginsState.returnCode = PluginsReturnCodeServerError
|
||||
pluginsState.ApplyLoggingPlugins(&proxy.pluginsGlobals)
|
||||
|
|
Loading…
Reference in New Issue