epsagon / epsagon-go

Automated tracing library for Go 1.x ⚡️
https://epsagon.com
MIT License
28 stars 11 forks source link

Handle send traces error response #16

Closed geototti21 closed 5 years ago

geototti21 commented 5 years ago

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:

Following the http.Do docs for guidance https://github.com/golang/go/blob/master/src/net/http/client.go#L508