Skip to content

Commit

Permalink
Added CustomReport closure to enable external custom reports.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Kupriianov committed Mar 18, 2022
1 parent f9999f1 commit 5be8c10
Showing 1 changed file with 16 additions and 33 deletions.
49 changes: 16 additions & 33 deletions reports.go
Original file line number Diff line number Diff line change
@@ -1,53 +1,36 @@
package metrics

func SlowSubscriberEventsDropped(amount int, tags ...Tags) {
func CustomReport(reportFn func(s Statter, tagSpec []string), tags ...Tags) {
clientMux.RLock()
defer clientMux.RUnlock()

if client == nil {
return
}

tagSpec := JoinTags(tags...)
reportFn(client, JoinTags(tags...))
}

client.Count("pubsub.slow_subscriber.events_dropped", int64(amount), tagSpec, 1)
func SlowSubscriberEventsDropped(amount int, tags ...Tags) {
CustomReport(func(s Statter, tagSpec []string) {
s.Count("pubsub.slow_subscriber.events_dropped", int64(amount), tagSpec, 1)
})
}

func SpotTradesBatchSubmitted(size int, tags ...Tags) {
clientMux.RLock()
defer clientMux.RUnlock()

if client == nil {
return
}

tagSpec := JoinTags(tags...)

client.Count("events.spot_trades_batch.size", int64(size), tagSpec, 1)
CustomReport(func(s Statter, tagSpec []string) {
s.Count("events.spot_trades_batch.size", int64(size), tagSpec, 1)
})
}

func DerivativeTradesBatchSubmitted(size int, tags ...Tags) {
clientMux.RLock()
defer clientMux.RUnlock()

if client == nil {
return
}

tagSpec := JoinTags(tags...)

client.Count("events.derivative_trades_batch.size", int64(size), tagSpec, 1)
CustomReport(func(s Statter, tagSpec []string) {
s.Count("events.derivative_trades_batch.size", int64(size), tagSpec, 1)
})
}

func IndexPriceUpdatesBatchSubmitted(size int, tags ...Tags) {
clientMux.RLock()
defer clientMux.RUnlock()

if client == nil {
return
}

tagSpec := JoinTags(tags...)

client.Count("events.set_price_batch.size", int64(size), tagSpec, 1)
CustomReport(func(s Statter, tagSpec []string) {
s.Count("events.set_price_batch.size", int64(size), tagSpec, 1)
})
}

0 comments on commit 5be8c10

Please sign in to comment.