Skip to content

Commit

Permalink
add prom metric on amount of events
Browse files Browse the repository at this point in the history
  • Loading branch information
Termina1 committed Sep 9, 2024
1 parent f9cb6c9 commit 4e67c2a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions chotki.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/drpcorg/chotki/protocol"
"github.com/drpcorg/chotki/rdx"
"github.com/drpcorg/chotki/utils"
"github.com/prometheus/client_golang/prometheus"
"github.com/puzpuzpuz/xsync/v3"
)

Expand Down Expand Up @@ -456,9 +457,20 @@ func (cho *Chotki) CommitPacket(lit byte, ref rdx.ID, body protocol.Records) (id
return
}

var EventsMetric = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "chotki",
Name: "packet_count",
})

func (cho *Chotki) Metrics() []prometheus.Collector {
return []prometheus.Collector{EventsMetric}
}

func (cho *Chotki) Drain(recs protocol.Records) (err error) {
var calls []CallHook

EventsMetric.Add(float64(len(recs)))

for _, packet := range recs { // parse the packets
if err != nil {
break
Expand Down

0 comments on commit 4e67c2a

Please sign in to comment.