Skip to content

Commit

Permalink
add guages for buffer size and contents
Browse files Browse the repository at this point in the history
  • Loading branch information
torywheelwright committed Mar 29, 2024
1 parent bc143bc commit dee9d5d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (

"github.com/go-redis/redis/v8"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -76,7 +78,26 @@ func main() {
// and sends them to Redis.
//
// TODO PERF: Use a leaky buffer (https://github.com/tulip/oplogtoredis/issues/2)
bufferCapacity := 10000
redisPubs := make(chan *redispub.Publication, 10000)

var metricBufferCapacity = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "otr",
Subsystem: "main",
Name: "buffer_capacity",
Help: "Gauge indicating the capacity of the buffer that holds messages waiting to be written to redis.",
})
metricBufferCapacity.Set(float64(bufferCapacity))

promauto.NewGaugeFunc(prometheus.GaugeOpts{
Namespace: "otr",
Subsystem: "main",
Name: "buffer_contents",
Help: "Guage indicating the number of messages waiting in the buffer to be written to redis.",
}, func () float64 {
return float64(len(redisPubs))
})

waitGroup := sync.WaitGroup{}

stopOplogTail := make(chan bool)
Expand Down

0 comments on commit dee9d5d

Please sign in to comment.