app/vminsert: use netutil.TCPListener for collecting network-related metrics for Graphite and OpenTSDB TCP traffic

This commit is contained in:
Aliaksandr Valialkin 2019-07-15 22:58:00 +03:00
parent ec1b439329
commit 575d2f0a91
2 changed files with 4 additions and 2 deletions

View File

@ -9,6 +9,7 @@ import (
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil" "github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger" "github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/netutil"
"github.com/VictoriaMetrics/metrics" "github.com/VictoriaMetrics/metrics"
) )
@ -23,7 +24,7 @@ var (
// Serve starts graphite server on the given addr. // Serve starts graphite server on the given addr.
func Serve(addr string) { func Serve(addr string) {
logger.Infof("starting TCP Graphite server at %q", addr) logger.Infof("starting TCP Graphite server at %q", addr)
lnTCP, err := net.Listen("tcp4", addr) lnTCP, err := netutil.NewTCPListener("graphite", addr)
if err != nil { if err != nil {
logger.Fatalf("cannot start TCP Graphite server at %q: %s", addr, err) logger.Fatalf("cannot start TCP Graphite server at %q: %s", addr, err)
} }

View File

@ -9,6 +9,7 @@ import (
"github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil" "github.com/VictoriaMetrics/VictoriaMetrics/lib/bytesutil"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/logger" "github.com/VictoriaMetrics/VictoriaMetrics/lib/logger"
"github.com/VictoriaMetrics/VictoriaMetrics/lib/netutil"
"github.com/VictoriaMetrics/metrics" "github.com/VictoriaMetrics/metrics"
) )
@ -23,7 +24,7 @@ var (
// Serve starts OpenTSDB collector on the given addr. // Serve starts OpenTSDB collector on the given addr.
func Serve(addr string) { func Serve(addr string) {
logger.Infof("starting TCP OpenTSDB collector at %q", addr) logger.Infof("starting TCP OpenTSDB collector at %q", addr)
lnTCP, err := net.Listen("tcp4", addr) lnTCP, err := netutil.NewTCPListener("opentsdb", addr)
if err != nil { if err != nil {
logger.Fatalf("cannot start TCP OpenTSDB collector at %q: %s", addr, err) logger.Fatalf("cannot start TCP OpenTSDB collector at %q: %s", addr, err)
} }