-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
292 additions
and
14 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
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
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
scrape_configs: | ||
- job_name: 'prometheus' | ||
static_configs: | ||
- targets: ['localhost:9090'] | ||
- job_name: 'moira-api' | ||
static_configs: | ||
- targets: ['api:8091'] | ||
- job_name: 'moira-checker' | ||
static_configs: | ||
- targets: ['checker:8092'] | ||
- job_name: 'moira-notifier' | ||
static_configs: | ||
- targets: ['notifier:8093'] | ||
- job_name: 'moira-filter' | ||
static_configs: | ||
- targets: ['filter:8094'] |
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 |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package metrics | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
type CompositeRegistry struct { | ||
registries []Registry | ||
} | ||
|
||
func NewCompositeRegistry(registries ...Registry) *CompositeRegistry { | ||
return &CompositeRegistry{registries} | ||
} | ||
|
||
func (source *CompositeRegistry) NewMeter(path ...string) Meter { | ||
var meters = make([]Meter, 0) | ||
for _, registry := range source.registries { | ||
meters = append(meters, registry.NewMeter(path...)) | ||
} | ||
return &compositeMeter{meters} | ||
} | ||
|
||
func (source *CompositeRegistry) NewTimer(path ...string) Timer { | ||
var timers = make([]Timer, 0) | ||
for _, registry := range source.registries { | ||
timers = append(timers, registry.NewTimer(path...)) | ||
} | ||
return &compositeTimer{timers} | ||
} | ||
|
||
func (source *CompositeRegistry) NewHistogram(path ...string) Histogram { | ||
var histograms = make([]Histogram, 0) | ||
for _, registry := range source.registries { | ||
histograms = append(histograms, registry.NewHistogram(path...)) | ||
} | ||
return &compositeHistogram{histograms} | ||
} | ||
|
||
func (source *CompositeRegistry) NewCounter(path ...string) Counter { | ||
var counters = make([]Counter, 0) | ||
for _, registry := range source.registries { | ||
counters = append(counters, registry.NewCounter(path...)) | ||
} | ||
return &compositeCounter{counters} | ||
} | ||
|
||
type compositeMeter struct { | ||
meters []Meter | ||
} | ||
|
||
func (source *compositeMeter) Count() int64 { | ||
if len(source.meters) == 0 { | ||
return 0 | ||
} | ||
|
||
return source.meters[0].Count() | ||
} | ||
|
||
func (source *compositeMeter) Mark(value int64) { | ||
for _, meter := range source.meters { | ||
meter.Mark(value) | ||
} | ||
} | ||
|
||
type compositeTimer struct { | ||
timers []Timer | ||
} | ||
|
||
func (source *compositeTimer) Count() int64 { | ||
if len(source.timers) == 0 { | ||
return 0 | ||
} | ||
|
||
return source.timers[0].Count() | ||
} | ||
|
||
func (source *compositeTimer) UpdateSince(ts time.Time) { | ||
for _, timer := range source.timers { | ||
timer.UpdateSince(ts) | ||
} | ||
} | ||
|
||
type compositeHistogram struct { | ||
histograms []Histogram | ||
} | ||
|
||
func (source *compositeHistogram) Count() int64 { | ||
if len(source.histograms) == 0 { | ||
return 0 | ||
} | ||
|
||
return source.histograms[0].Count() | ||
} | ||
|
||
func (source *compositeHistogram) Update(value int64) { | ||
for _, histogram := range source.histograms { | ||
histogram.Update(value) | ||
} | ||
} | ||
|
||
type compositeCounter struct { | ||
counters []Counter | ||
} | ||
|
||
func (source *compositeCounter) Count() int64 { | ||
if len(source.counters) == 0 { | ||
return 0 | ||
} | ||
|
||
return source.counters[0].Count() | ||
} | ||
|
||
func (source *compositeCounter) Inc() { | ||
for _, counter := range source.counters { | ||
counter.Inc() | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package metrics | ||
|
||
import goMetrics "github.com/rcrowley/go-metrics" | ||
|
||
func NewDummyRegistry() Registry { | ||
return &GraphiteRegistry{goMetrics.NewRegistry()} | ||
} |
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
Oops, something went wrong.