Skip to content
This repository has been archived by the owner on Aug 30, 2019. It is now read-only.

writer: don't discard the client on api errors #257

Merged
merged 1 commit into from
Mar 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions agent/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func (err *apiError) IsEmpty() bool {
return len(err.errs) == 0
}

func (err *apiError) SetClient(client *http.Client) {
err.endpoint.client = client
}

func (err *apiError) Append(url, apiKey string, e error) {
err.errs = append(err.errs, e)
err.endpoint.urls = append(err.endpoint.urls, url)
Expand Down Expand Up @@ -124,6 +128,11 @@ func (a *APIEndpoint) Write(p model.AgentPayload) (int, error) {

endpointErr := newAPIError()

// if this payload cannot be flushed due to API errors
// we need to pass the client along for future submissions
// FIXME(aaditya)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Short-term fix is fine IMHO but as we see this now only, probably no test is going through that path for real. This is beyond the scope of this PR anyway.

endpointErr.SetClient(a.client)

for i := range a.urls {
atomic.AddInt64(&a.stats.TracesPayload, 1)

Expand Down
1 change: 1 addition & 0 deletions agent/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func NewWriter(conf *config.AgentConfig) *Writer {
if conf.Proxy != nil {
// we have some kind of proxy configured.
// make sure our http client uses it
log.Infof("configuring proxy through host %s", conf.Proxy.Host)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

endpoint.(*APIEndpoint).SetProxy(conf.Proxy)
}
} else {
Expand Down