Add statistics groups
This commit is contained in:
parent
0e1fbbe729
commit
bfa1575d79
4
satan.go
4
satan.go
@ -45,8 +45,8 @@ type Publisher interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Statistics interface {
|
type Statistics interface {
|
||||||
Add(daemonName string, dur time.Duration)
|
Add(name string, dur time.Duration)
|
||||||
Error(daemonName string)
|
Error(name string)
|
||||||
}
|
}
|
||||||
|
|
||||||
type task struct {
|
type task struct {
|
||||||
|
29
stats/group.go
Normal file
29
stats/group.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package stats
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/localhots/satan"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Group struct {
|
||||||
|
backends []satan.Statistics
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGroup(backends ...satan.Statistics) *Group {
|
||||||
|
return &Group{
|
||||||
|
backends: backends,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Group) Add(name string, dur time.Duration) {
|
||||||
|
for _, b := range g.backends {
|
||||||
|
b.Add(name, dur)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Group) Error(name string) {
|
||||||
|
for _, b := range g.backends {
|
||||||
|
b.Error(name)
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user