lib/promscrape/client: make User-Agent consistent between fasthttp and native client (#4886)

User agent was not set for native client which resulted in using one provided by Golang.

See: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4884

Signed-off-by: Zakhar Bessarab <z.bessarab@victoriametrics.com>
This commit is contained in:
Zakhar Bessarab 2023-08-24 13:31:13 +04:00 committed by GitHub
parent 757ae4275b
commit 6788704152
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -201,6 +201,8 @@ func (c *client) GetStreamReader() (*streamReader, error) {
// Set X-Prometheus-Scrape-Timeout-Seconds like Prometheus does, since it is used by some exporters such as PushProx.
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1179#issuecomment-813117162
req.Header.Set("X-Prometheus-Scrape-Timeout-Seconds", c.scrapeTimeoutSecondsStr)
// Set same useragent as fasthttp.HostClient at c.hc uses for scraping
req.Header.Set("User-Agent", "vm_promscrape")
c.setHeaders(req)
c.setProxyHeaders(req)
scrapeRequests.Inc()