mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-29 22:51:36 -08:00
Include Accept header for telemetry request.
This pull request introduces a HTTP Accept header to indicate a preference for Protocol Buffer-encoded messages.
This commit is contained in:
parent
30b1cf80b5
commit
b8c7fd8c34
|
@ -14,7 +14,6 @@ package retrieval
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -194,6 +193,8 @@ func (t *target) Scrape(earliest time.Time, results chan<- *extraction.Result) (
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const acceptHeader = `application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited;q=0.7,application/json;schema=prometheus/telemetry;version=0.0.2;q=0.2,*/*;q=0.1`
|
||||||
|
|
||||||
func (t *target) scrape(timestamp time.Time, results chan<- *extraction.Result) (err error) {
|
func (t *target) scrape(timestamp time.Time, results chan<- *extraction.Result) (err error) {
|
||||||
defer func(start time.Time) {
|
defer func(start time.Time) {
|
||||||
ms := float64(time.Since(start)) / float64(time.Millisecond)
|
ms := float64(time.Since(start)) / float64(time.Millisecond)
|
||||||
|
@ -206,7 +207,13 @@ func (t *target) scrape(timestamp time.Time, results chan<- *extraction.Result)
|
||||||
targetOperations.Increment(labels)
|
targetOperations.Increment(labels)
|
||||||
}(time.Now())
|
}(time.Now())
|
||||||
|
|
||||||
resp, err := t.client.Get(t.Address())
|
req, err := http.NewRequest("GET", t.Address(), nil)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
req.Header.Add("Accept", acceptHeader)
|
||||||
|
|
||||||
|
resp, err := t.client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue