This is to fix a panic that can happen when an error is returned from the sendTraces HTTP call.
Steps to reproduce:
If you set in your env AWS_DEFAULT_REGION or AWS_REGION to something not AWS valid and you also not set the EPSAGON_COLLECTOR_URL then this line will create a url that will make the trace request fail https://github.com/epsagon/epsagon-go/blob/master/epsagon/tracer.go#L151. So it will panic as resp will be nil and we will try to access it.
What was done:
If an error is gets returned from the http call; log only that
If a 5XX response is returned then log the response body
This is to fix a panic that can happen when an error is returned from the sendTraces HTTP call.
Steps to reproduce:
If you set in your env
AWS_DEFAULT_REGION
orAWS_REGION
to something not AWS valid and you also not set theEPSAGON_COLLECTOR_URL
then this line will create a url that will make the trace request fail https://github.com/epsagon/epsagon-go/blob/master/epsagon/tracer.go#L151. So it will panic asresp
will benil
and we will try to access it.What was done:
Following the http.Do docs for guidance https://github.com/golang/go/blob/master/src/net/http/client.go#L508