Skip to content

Commit

Permalink
add user-agent in http header. (#1867)
Browse files Browse the repository at this point in the history
Signed-off-by: johncming <johncming@yahoo.com>
  • Loading branch information
johncming authored and bwplotka committed Dec 11, 2019
1 parent 29813ba commit 80c23db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/alert/alert.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ import (
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"

"github.com/prometheus/common/version"
"github.com/prometheus/prometheus/pkg/labels"

"github.com/thanos-io/thanos/pkg/runutil"
)

Expand All @@ -27,6 +28,8 @@ const (
contentTypeJSON = "application/json"
)

var userAgent = fmt.Sprintf("Thanos/%s", version.Version)

// Alert is a generic representation of an alert in the Prometheus eco-system.
type Alert struct {
// Label value pairs for purpose of aggregation, matching, and disposition
Expand Down Expand Up @@ -369,6 +372,7 @@ func (s *Sender) sendOne(ctx context.Context, url string, b []byte) error {
}
req = req.WithContext(ctx)
req.Header.Set("Content-Type", contentTypeJSON)
req.Header.Set("User-Agent", userAgent)

resp, err := s.doReq(req)
if err != nil {
Expand Down

0 comments on commit 80c23db

Please sign in to comment.