signalfx / signalfx-go

Go client library and instrumentation bindings for SignalFx
https://www.signalfx.com
Apache License 2.0
14 stars 51 forks source link

Expose HTTP status information for non-2xx status codes #83

Closed ChimeraCoder closed 4 years ago

ChimeraCoder commented 4 years ago

At the moment, the high-level query functions exposed (such as SearchCharts) don't expose the status code of the underlying HTTP request. Looking at doRequest/doRequestWithToken, it looks like the method will return a non-nil error if there is a network error, but not for 4xx/5xx statuses, which will not get passed on to the higher-level methods.

Could we either expose the HTTP status information in the result struct types (such as SearchResult), or perform an HTTP status check within doRequestWithToken itself to represent the non-200 status codes as non-nil error values?

cory-signalfx commented 4 years ago

Yeah, that's definitely a thing we can do. I'll get on it! (Likely not today, but maybe tomorrow!)

cory-signalfx commented 4 years ago

Ok, back on this now. The pattern in other places has been to verify that the response has the status code that the docs expect. These search methods lack any of this checking, whereas the various DELETE/POST/PUT methods do. I'll first adjust this behavior and see how that looks.