epsagon / epsagon-go

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

get global tracer each time #69

Closed mgarski closed 3 years ago

mgarski commented 3 years ago

I discovered an issue with assigning the tracer to the TracingTransport instance the first time when RoundTrip is called by the http.Client. If the TracingTransport instance is re-used across multiple Lambda invocations the first invocation will succeed however subsequent requests will fail as the tracer is only valid for a single invocation with a new tracer created on each invocation as at the end of the invocation the tracer is stopped.

This change alters that behavior to use a local variable for the tracer in the TracingTransport instance allowing it to be used across multiple invocations.


Discovered an odd issue when wrapping another transport, where after the request is sent the function req.GetBody() is nil. I'm not sure why this is happening when calling the AWS Elasticsearch service with a signed request but I can reproduce it. Made another change to the TracingTransport to capture the request headers & body before sending. This change is implemented similar to how the response body is read & a new reader is created for it.