Merge pull request #352 from bakins/parser-interface

Use a Parser interface to allow alternate implementations
This commit is contained in:
Matthias Rampke 2020-12-18 09:50:43 +01:00 committed by GitHub
commit 5a7d7fe3d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,15 +23,19 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/statsd_exporter/pkg/event"
pkgLine "github.com/prometheus/statsd_exporter/pkg/line"
)
type Parser interface {
LineToEvents(line string, sampleErrors prometheus.CounterVec, samplesReceived prometheus.Counter, tagErrors prometheus.Counter, tagsReceived prometheus.Counter, logger log.Logger) event.Events
}
type StatsDUDPListener struct {
Conn *net.UDPConn
EventHandler event.EventHandler
Logger log.Logger
LineParser *pkgLine.Parser
LineParser Parser
UDPPackets prometheus.Counter
LinesReceived prometheus.Counter
EventsFlushed prometheus.Counter
@ -76,7 +80,7 @@ type StatsDTCPListener struct {
Conn *net.TCPListener
EventHandler event.EventHandler
Logger log.Logger
LineParser *pkgLine.Parser
LineParser Parser
LinesReceived prometheus.Counter
EventsFlushed prometheus.Counter
SampleErrors prometheus.CounterVec
@ -138,7 +142,7 @@ type StatsDUnixgramListener struct {
Conn *net.UnixConn
EventHandler event.EventHandler
Logger log.Logger
LineParser *pkgLine.Parser
LineParser Parser
UnixgramPackets prometheus.Counter
LinesReceived prometheus.Counter
EventsFlushed prometheus.Counter