From 5ad72dec32ef3adf1f7815ec059c3a5c42ef39d8 Mon Sep 17 00:00:00 2001 From: Alan Moran Date: Tue, 28 May 2024 17:53:31 +0200 Subject: [PATCH] Uses prometheus counter gen creating egress connector for syslog --- .../forwarder/syslog_emitter.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/autoscaler/metricsforwarder/forwarder/syslog_emitter.go b/src/autoscaler/metricsforwarder/forwarder/syslog_emitter.go index 84ff7e0a90..418fc17a47 100644 --- a/src/autoscaler/metricsforwarder/forwarder/syslog_emitter.go +++ b/src/autoscaler/metricsforwarder/forwarder/syslog_emitter.go @@ -12,6 +12,7 @@ import ( "code.cloudfoundry.org/lager/v3" "code.cloudfoundry.org/loggregator-agent-release/src/pkg/egress" "code.cloudfoundry.org/loggregator-agent-release/src/pkg/egress/syslog" + "github.com/prometheus/client_golang/prometheus" ) type SyslogEmitter struct { @@ -19,13 +20,6 @@ type SyslogEmitter struct { Writer egress.WriteCloser } -type Counter struct{} - -func (c *Counter) Add(delta float64) { -} -func (c *Counter) Set(delta float64) { -} - func NewSyslogEmitter(logger lager.Logger, conf *config.Config) (MetricForwarder, error) { var writer egress.WriteCloser var protocol string @@ -54,12 +48,19 @@ func NewSyslogEmitter(logger lager.Logger, conf *config.Config) (MetricForwarder Hostname: hostname, } + syslogEgressCounter := prometheus.NewCounter(prometheus.CounterOpts{ + Namespace: "autoscaler", + Subsystem: "metricsforwarder", + Name: "syslog_metrics_egress_counter", + Help: "count of metrics sent to syslog", + }) + switch binding.URL.Scheme { case "syslog": writer = syslog.NewTCPWriter( binding, netConf, - &Counter{}, + syslogEgressCounter, syslog.NewConverter(), ) case "syslog-tls": @@ -67,7 +68,7 @@ func NewSyslogEmitter(logger lager.Logger, conf *config.Config) (MetricForwarder binding, netConf, tlsConfig, - &Counter{}, + syslogEgressCounter, syslog.NewConverter(), ) }