-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CustomReport closure to enable external custom reports.
- Loading branch information
Maxim Kupriianov
committed
Mar 18, 2022
1 parent
f9999f1
commit 5be8c10
Showing
1 changed file
with
16 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
} |