mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Update dependents.
This commit is contained in:
parent
9281347790
commit
9c98df2b37
9
main.go
9
main.go
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/matttproud/prometheus/api"
|
||||
"github.com/matttproud/prometheus/config"
|
||||
"github.com/matttproud/prometheus/retrieval"
|
||||
"github.com/matttproud/prometheus/retrieval/format"
|
||||
"github.com/matttproud/prometheus/rules"
|
||||
"github.com/matttproud/prometheus/rules/ast"
|
||||
"github.com/matttproud/prometheus/storage/metric/leveldb"
|
||||
|
@ -58,7 +59,7 @@ func main() {
|
|||
|
||||
defer persistence.Close()
|
||||
|
||||
scrapeResults := make(chan retrieval.Result, 4096)
|
||||
scrapeResults := make(chan format.Result, 4096)
|
||||
|
||||
targetManager := retrieval.NewTargetManager(scrapeResults, 1)
|
||||
targetManager.AddTargetsFromConfig(conf)
|
||||
|
@ -85,12 +86,10 @@ func main() {
|
|||
for {
|
||||
select {
|
||||
case scrapeResult := <-scrapeResults:
|
||||
//fmt.Printf("scrapeResult -> %s\n", scrapeResult)
|
||||
for _, sample := range scrapeResult.Samples {
|
||||
persistence.AppendSample(&sample)
|
||||
if scrapeResult.Err == nil {
|
||||
persistence.AppendSample(&scrapeResult.Sample)
|
||||
}
|
||||
case ruleResult := <-ruleResults:
|
||||
//fmt.Printf("ruleResult -> %s\n", ruleResult)
|
||||
for _, sample := range ruleResult.Samples {
|
||||
persistence.AppendSample(sample)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import (
|
|||
"github.com/matttproud/golang_instrumentation/metrics"
|
||||
"github.com/matttproud/prometheus/model"
|
||||
"github.com/matttproud/prometheus/retrieval/format"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
@ -115,8 +114,6 @@ func NewTarget(address string, interval, deadline time.Duration, baseLabels mode
|
|||
}
|
||||
|
||||
func (t *target) Scrape(earliest time.Time, results chan format.Result) (err error) {
|
||||
result := Result{}
|
||||
|
||||
defer func() {
|
||||
futureState := t.state
|
||||
|
||||
|
@ -133,7 +130,6 @@ func (t *target) Scrape(earliest time.Time, results chan format.Result) (err err
|
|||
done := make(chan bool)
|
||||
|
||||
request := func() {
|
||||
ti := time.Now()
|
||||
resp, err := http.Get(t.Address())
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -141,12 +137,7 @@ func (t *target) Scrape(earliest time.Time, results chan format.Result) (err err
|
|||
|
||||
defer resp.Body.Close()
|
||||
|
||||
raw, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
processor, err := format.DefaultRegistry.ProcessForRequest(resp.Header)
|
||||
processor, err := format.DefaultRegistry.ProcessorForRequestHeader(resp.Header)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"container/heap"
|
||||
"github.com/matttproud/prometheus/config"
|
||||
"github.com/matttproud/prometheus/model"
|
||||
"github.com/matttproud/prometheus/retrieval/format"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
@ -32,10 +33,10 @@ type TargetManager interface {
|
|||
type targetManager struct {
|
||||
requestAllowance chan bool
|
||||
pools map[time.Duration]*TargetPool
|
||||
results chan Result
|
||||
results chan format.Result
|
||||
}
|
||||
|
||||
func NewTargetManager(results chan Result, requestAllowance int) TargetManager {
|
||||
func NewTargetManager(results chan format.Result, requestAllowance int) TargetManager {
|
||||
return &targetManager{
|
||||
requestAllowance: make(chan bool, requestAllowance),
|
||||
results: results,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package retrieval
|
||||
|
||||
import (
|
||||
"github.com/matttproud/prometheus/retrieval/format"
|
||||
"github.com/matttproud/prometheus/utility/test"
|
||||
"testing"
|
||||
"time"
|
||||
|
@ -34,7 +35,7 @@ func (t fakeTarget) Interval() time.Duration {
|
|||
return t.interval
|
||||
}
|
||||
|
||||
func (t *fakeTarget) Scrape(e time.Time, r chan Result) error {
|
||||
func (t *fakeTarget) Scrape(e time.Time, r chan format.Result) error {
|
||||
t.scrapeCount++
|
||||
|
||||
return nil
|
||||
|
@ -52,7 +53,7 @@ func (t *fakeTarget) scheduledFor() (time time.Time) {
|
|||
}
|
||||
|
||||
func testTargetManager(t test.Tester) {
|
||||
results := make(chan Result, 5)
|
||||
results := make(chan format.Result, 5)
|
||||
targetManager := NewTargetManager(results, 3)
|
||||
|
||||
target1GroupA := &fakeTarget{
|
||||
|
|
|
@ -2,6 +2,7 @@ package retrieval
|
|||
|
||||
import (
|
||||
"container/heap"
|
||||
"github.com/matttproud/prometheus/retrieval/format"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
@ -44,7 +45,7 @@ func (p TargetPool) Swap(i, j int) {
|
|||
p.targets[i], p.targets[j] = p.targets[j], p.targets[i]
|
||||
}
|
||||
|
||||
func (p *TargetPool) Run(results chan Result, interval time.Duration) {
|
||||
func (p *TargetPool) Run(results chan format.Result, interval time.Duration) {
|
||||
ticker := time.Tick(interval)
|
||||
|
||||
for {
|
||||
|
@ -62,14 +63,14 @@ func (p TargetPool) Stop() {
|
|||
p.done <- true
|
||||
}
|
||||
|
||||
func (p *TargetPool) runSingle(earliest time.Time, results chan Result, t Target) {
|
||||
func (p *TargetPool) runSingle(earliest time.Time, results chan format.Result, t Target) {
|
||||
p.manager.acquire()
|
||||
defer p.manager.release()
|
||||
|
||||
t.Scrape(earliest, results)
|
||||
}
|
||||
|
||||
func (p *TargetPool) runIteration(results chan Result) {
|
||||
func (p *TargetPool) runIteration(results chan format.Result) {
|
||||
for i := 0; i < p.Len(); i++ {
|
||||
target := heap.Pop(p).(Target)
|
||||
if target == nil {
|
||||
|
|
Loading…
Reference in a new issue