Traceparent header
Signed-off-by: Vanshikav123 <vanshikav928@gmail.com>
This commit is contained in:
parent
2aaafae36f
commit
44a620dd73
|
@ -36,6 +36,8 @@ import (
|
|||
"github.com/prometheus/common/model"
|
||||
"github.com/prometheus/common/promslog"
|
||||
"github.com/prometheus/common/version"
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/propagation"
|
||||
|
||||
"github.com/prometheus/prometheus/config"
|
||||
"github.com/prometheus/prometheus/discovery/targetgroup"
|
||||
|
@ -819,6 +821,10 @@ func acceptEncodingHeader(enableCompression bool) string {
|
|||
var UserAgent = version.PrometheusUserAgent()
|
||||
|
||||
func (s *targetScraper) scrape(ctx context.Context) (*http.Response, error) {
|
||||
tracer := otel.GetTracerProvider().Tracer("prometheus/scraper")
|
||||
ctx, span := tracer.Start(ctx, "scrape_"+s.URL().String())
|
||||
defer span.End()
|
||||
|
||||
if s.req == nil {
|
||||
req, err := http.NewRequest(http.MethodGet, s.URL().String(), nil)
|
||||
if err != nil {
|
||||
|
@ -832,7 +838,13 @@ func (s *targetScraper) scrape(ctx context.Context) (*http.Response, error) {
|
|||
s.req = req
|
||||
}
|
||||
|
||||
return s.client.Do(s.req.WithContext(ctx))
|
||||
req := s.req.WithContext(ctx)
|
||||
|
||||
propagator := otel.GetTextMapPropagator()
|
||||
|
||||
propagator.Inject(ctx, propagation.HeaderCarrier(req.Header))
|
||||
|
||||
return s.client.Do(req)
|
||||
}
|
||||
|
||||
func (s *targetScraper) readResponse(_ context.Context, resp *http.Response, w io.Writer) (string, error) {
|
||||
|
|
Loading…
Reference in New Issue