Just wrapping the DefaultTransport in the RoundTripper implementation is not very flexible if the http.Client required has it's own custom transport. A good example of this is in calling the AWS Elasticsearch service with signed requests which uses a RoundTripper to sign the request. Kicking myself for not doing this in my initial PR.
Also added a check on the tracer being nil in the RoundTrip method, and setting it to the global tracer if it is. We initialize our dependencies in main and inject them into the handler before calling WrapLambdaHandler, and in doing so the tracer is nil in the TracingTransport as the global tracer has not yet been created. I'm not sure if this solution is the best approach for that and am open to other approaches. Here is an example of the approach we use in our main() functions:
Just wrapping the DefaultTransport in the RoundTripper implementation is not very flexible if the http.Client required has it's own custom transport. A good example of this is in calling the AWS Elasticsearch service with signed requests which uses a RoundTripper to sign the request. Kicking myself for not doing this in my initial PR.
Also added a check on the tracer being nil in the RoundTrip method, and setting it to the global tracer if it is. We initialize our dependencies in main and inject them into the handler before calling WrapLambdaHandler, and in doing so the tracer is nil in the TracingTransport as the global tracer has not yet been created. I'm not sure if this solution is the best approach for that and am open to other approaches. Here is an example of the approach we use in our main() functions:
The http.Client with TracingTransport is created in the stripe.NewClient function, which occurs before the global tracer is created.