Skip to content

Commit

Permalink
Uses prometheus counter gen creating egress connector for syslog
Browse files Browse the repository at this point in the history
  • Loading branch information
bonzofenix committed May 28, 2024
1 parent 3d780f4 commit 5ad72de
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/autoscaler/metricsforwarder/forwarder/syslog_emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@ 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 {
logger lager.Logger
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
Expand Down Expand Up @@ -54,20 +48,27 @@ 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":
writer = syslog.NewTLSWriter(
binding,
netConf,
tlsConfig,
&Counter{},
syslogEgressCounter,
syslog.NewConverter(),
)
}
Expand Down

0 comments on commit 5ad72de

Please sign in to comment.