go-agent
go-agent copied to clipboard
Need some way to provide a cause for http response code errors
Summary
We use github.com/pkg/errors
throughout our codebase to make sure all our errors have good traces,
and it would be really awesome if we could somehow attach the actual cause of a failed http request to the error that is created for >400 http response code errors.
Instead atm we're forced to do NoticeError
for the actual error, and then there's always 2 errors in the transaction, which is "fine", but far from perfect ...
Desired Behaviour
Either be able to attach a cause to the http response code errors, or be able to create the http response code errors ourselves with minimal effort.
The problem of doing it ourselves is that there's a lot of (useful) logic in addCrossProcessHeaders
and headersJustWritten
which we'd need to copy into our codebase...
Possible Solution
So I think there's 2 options;
-
add some way to provide the cause of the request failure so that in
headersJustWritten
you can add that as cause to the error that is created. and then use similar logic toerrDataFromError
to create the error. -
add some hook we can set to customize the creation of the error, ie. replace
e := txnErrorFromResponseCode(...)
withtxn.MakeErrorFromResponseCode(...)
and addtxn.SetErrorFromResponseCodeFactory()
-
expose
responseHeaderAttributes
,responseCodeAttribute
andresponseHeader
so we can do everything else (which isn't that much) ourselves and call those methods to add the attributes.
I think option 2) might be the best / easiest way since it allows the most flexibility.
option 1)
Hello @rubensayshi. Our team wanted to check in and see if this issue is still needed from your end.
hey @Ak-x ye this would still be very much appreciated to avoid the double error we're seeing in our dashboard every time now.
Thank you@rubensayshi, This has been added to our Roadmap.
cc: @ak-war