mirror of
https://github.com/NotAShelf/watchdog.git
synced 2026-04-17 07:40:07 +00:00
various: standardize registry APIs; truncate metrics responses at 10MB
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I428255e61f8d2211fec0c320527b8e066a6a6964
This commit is contained in:
parent
6fed378bb6
commit
c925cca321
3 changed files with 73 additions and 0 deletions
|
|
@ -54,3 +54,20 @@ func (r *CustomEventRegistry) OverflowCount() int {
|
|||
defer r.mu.RUnlock()
|
||||
return r.overflowCount
|
||||
}
|
||||
|
||||
// Contains checks if an event name exists in the registry.
|
||||
func (r *CustomEventRegistry) Contains(eventName string) bool {
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
_, exists := r.events[eventName]
|
||||
return exists
|
||||
}
|
||||
|
||||
// Count returns the number of unique events in the registry.
|
||||
func (r *CustomEventRegistry) Count() int {
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
return len(r.events)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,3 +56,20 @@ func (r *ReferrerRegistry) OverflowCount() int {
|
|||
defer r.mu.RUnlock()
|
||||
return r.overflowCount
|
||||
}
|
||||
|
||||
// Contains checks if a source exists in the registry.
|
||||
func (r *ReferrerRegistry) Contains(source string) bool {
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
_, exists := r.sources[source]
|
||||
return exists
|
||||
}
|
||||
|
||||
// Count returns the number of unique sources in the registry.
|
||||
func (r *ReferrerRegistry) Count() int {
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
return len(r.sources)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue