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