feature: log queue and buffer memory size configuration (#6591)

* feature: log queue and buffer memory size configuration

Signed-off-by: chenyuliang5 <chenyuliang@jd.com>
This commit is contained in:
chenylh
2024-10-01 23:49:59 +08:00
committed by GitHub
parent 6efa95ca98
commit ae0b79313b
6 changed files with 86 additions and 56 deletions

View File

@@ -3,6 +3,7 @@ package dnstap
import (
"net/url"
"os"
"strconv"
"strings"
"github.com/coredns/caddy"
@@ -20,7 +21,10 @@ func parseConfig(c *caddy.Controller) ([]*Dnstap, error) {
dnstaps := []*Dnstap{}
for c.Next() { // directive name
d := Dnstap{}
d := Dnstap{
MultipleTcpWriteBuf: 1,
MultipleQueue: 1,
}
endpoint := ""
d.repl = replacer.New()
@@ -32,6 +36,14 @@ func parseConfig(c *caddy.Controller) ([]*Dnstap, error) {
endpoint = args[0]
if len(args) >= 3 {
d.MultipleTcpWriteBuf, _ = strconv.Atoi(args[2])
}
if len(args) >= 4 {
d.MultipleQueue, _ = strconv.Atoi(args[3])
}
var dio *dio
if strings.HasPrefix(endpoint, "tls://") {
// remote network endpoint
@@ -39,23 +51,23 @@ func parseConfig(c *caddy.Controller) ([]*Dnstap, error) {
if err != nil {
return nil, c.ArgErr()
}
dio = newIO("tls", endpointURL.Host)
d = Dnstap{io: dio}
dio = newIO("tls", endpointURL.Host, d.MultipleQueue, d.MultipleTcpWriteBuf)
d.io = dio
} else if strings.HasPrefix(endpoint, "tcp://") {
// remote network endpoint
endpointURL, err := url.Parse(endpoint)
if err != nil {
return nil, c.ArgErr()
}
dio = newIO("tcp", endpointURL.Host)
d = Dnstap{io: dio}
dio = newIO("tcp", endpointURL.Host, d.MultipleQueue, d.MultipleTcpWriteBuf)
d.io = dio
} else {
endpoint = strings.TrimPrefix(endpoint, "unix://")
dio = newIO("unix", endpoint)
d = Dnstap{io: dio}
dio = newIO("unix", endpoint, d.MultipleQueue, d.MultipleTcpWriteBuf)
d.io = dio
}
d.IncludeRawMessage = len(args) == 2 && args[1] == "full"
d.IncludeRawMessage = len(args) >= 2 && args[1] == "full"
hostname, _ := os.Hostname()
d.Identity = []byte(hostname)