|
9 | 9 | "encoding/json"
|
10 | 10 | "errors"
|
11 | 11 | "fmt"
|
12 |
| - "io/ioutil" |
| 12 | + "io" |
13 | 13 | "math/rand"
|
14 | 14 | "net/http"
|
15 | 15 | "sync"
|
@@ -67,6 +67,7 @@ func NewHarvester(options ...func(*Config)) (*Harvester, error) {
|
67 | 67 | }
|
68 | 68 |
|
69 | 69 | if cfg.APIKey == "" {
|
| 70 | + cancel() |
70 | 71 | return nil, errAPIKeyUnset
|
71 | 72 | }
|
72 | 73 |
|
@@ -100,7 +101,6 @@ func NewHarvester(options ...func(*Config)) (*Harvester, error) {
|
100 | 101 |
|
101 | 102 | h.config.logDebug(map[string]interface{}{
|
102 | 103 | "event": "harvester created",
|
103 |
| - "api-key": h.config.APIKey, |
104 | 104 | "harvest-period-seconds": h.config.HarvestPeriod.Seconds(),
|
105 | 105 | "metrics-url-override": h.config.MetricsURLOverride,
|
106 | 106 | "spans-url-override": h.config.SpansURLOverride,
|
@@ -293,9 +293,9 @@ func postData(req *http.Request, client *http.Client) response {
|
293 | 293 |
|
294 | 294 | // On success, metrics ingest returns 202, span ingest returns 200.
|
295 | 295 | if resp.StatusCode == http.StatusOK || resp.StatusCode == http.StatusAccepted {
|
296 |
| - r.body, _ = ioutil.ReadAll(resp.Body) |
| 296 | + r.body, _ = io.ReadAll(resp.Body) |
297 | 297 | } else {
|
298 |
| - _, _ = ioutil.ReadAll(resp.Body) |
| 298 | + _, _ = io.ReadAll(resp.Body) |
299 | 299 | r.err = fmt.Errorf("unexpected post response code: %d: %s",
|
300 | 300 | resp.StatusCode, http.StatusText(resp.StatusCode))
|
301 | 301 | }
|
@@ -441,7 +441,7 @@ func harvestRequest(req request, cfg *Config) {
|
441 | 441 |
|
442 | 442 | // Reattach request body because the original one has already been read
|
443 | 443 | // and closed.
|
444 |
| - req.Request.Body = ioutil.NopCloser(bytes.NewBuffer(req.compressedBody)) |
| 444 | + req.Request.Body = io.NopCloser(bytes.NewBuffer(req.compressedBody)) |
445 | 445 | }
|
446 | 446 | }
|
447 | 447 |
|
|
0 commit comments