You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are trying to build an adapter for our API Gateway proxy request lambdas to convert them into Go's net/http framework. That way we can share more of our framework code regardless of whether the application is serverless.
Unfortunately, we have encountered a bit of a snag with the way this library handles transactions. At the top level, the desire is to use nrlambda.Wrap, which will automatically start a transaction where the name is the function name. However, after we've adapted the incoming request into the net/http framework, we'd like to leverage newrelic.WrapHandle as part of the common routing logic. The issue is that newrelic.WrapHandle just directly starts a transaction no matter what is already in the context, so we would end up with two separate transactions for one request.
Desired Behaviour
There should only be one transaction.
Possible Solution
Perhaps newrelic.WrapHandle could be amended to simply call Transaction.SetName and Transaction.SetOption if there is already a transaction in the request's context?
The trickier part is Transaction.SetWebResponse. My assumption is that wrapping an already wrapped ResponseWriter will cause weird issues, and if newrelic.WrapHandle isn't the one that started the transaction, it has no way in general of knowing if it was already wrapped.
We can also go do our own custom thing instead of using newrelic.WrapHandle, but it would be desirable not to have to do that.
We could also skip calling nrlambda.Wrap, but it's nice to have the attributes like AWS request ID automatically included, and it's also nice to not mandate the use of newrelic.WrapHandle as developers may not bother if the lambda function only has one endpoint.
The text was updated successfully, but these errors were encountered:
Summary
We are trying to build an adapter for our API Gateway proxy request lambdas to convert them into Go's net/http framework. That way we can share more of our framework code regardless of whether the application is serverless.
Unfortunately, we have encountered a bit of a snag with the way this library handles transactions. At the top level, the desire is to use
nrlambda.Wrap
, which will automatically start a transaction where the name is the function name. However, after we've adapted the incoming request into the net/http framework, we'd like to leveragenewrelic.WrapHandle
as part of the common routing logic. The issue is thatnewrelic.WrapHandle
just directly starts a transaction no matter what is already in the context, so we would end up with two separate transactions for one request.Desired Behaviour
There should only be one transaction.
Possible Solution
Perhaps
newrelic.WrapHandle
could be amended to simply callTransaction.SetName
andTransaction.SetOption
if there is already a transaction in the request's context?The trickier part is
Transaction.SetWebResponse
. My assumption is that wrapping an already wrappedResponseWriter
will cause weird issues, and ifnewrelic.WrapHandle
isn't the one that started the transaction, it has no way in general of knowing if it was already wrapped.We can also go do our own custom thing instead of using
newrelic.WrapHandle
, but it would be desirable not to have to do that.We could also skip calling
nrlambda.Wrap
, but it's nice to have the attributes like AWS request ID automatically included, and it's also nice to not mandate the use ofnewrelic.WrapHandle
as developers may not bother if the lambda function only has one endpoint.The text was updated successfully, but these errors were encountered: