Skip to content

Commit

Permalink
feat: operator scraper 返回详细请求失败信息 --story=119013109 (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiandongx authored Aug 2, 2024
1 parent 2a31e34 commit e3145a8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/operator/operator/scraper/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ func (c *Scraper) StringCh() chan string {
for _, host := range c.config.Hosts {
resp, err := c.doRequest(host)
if err != nil {
ch <- fmt.Sprintf("scraper error: host=%s, err=%v", host, err)
continue
}
defer resp.Body.Close()

if resp.StatusCode >= 400 {
if resp.StatusCode >= 300 {
b, _ := io.ReadAll(resp.Body)
msg := fmt.Sprintf("scrape error => status code: %v, response: %v", resp.StatusCode, string(b))
msg := fmt.Sprintf("scraper error: host=%s, status_code=%d, response(%v)", host, resp.StatusCode, string(b))
ch <- msg
continue
}
Expand Down

0 comments on commit e3145a8

Please sign in to comment.