go-agent icon indicating copy to clipboard operation
go-agent copied to clipboard

Need some way to provide a cause for http response code errors

Open rubensayshi opened this issue 4 years ago • 3 comments

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;

  1. 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 to errDataFromError to create the error.

  2. add some hook we can set to customize the creation of the error, ie. replace e := txnErrorFromResponseCode(...) with txn.MakeErrorFromResponseCode(...) and add txn.SetErrorFromResponseCodeFactory()

  3. expose responseHeaderAttributes, responseCodeAttribute and responseHeader 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)

rubensayshi avatar Sep 02 '20 09:09 rubensayshi

Hello @rubensayshi. Our team wanted to check in and see if this issue is still needed from your end.

Ak-x avatar Aug 17 '21 17:08 Ak-x

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.

rubensayshi avatar Aug 18 '21 07:08 rubensayshi

Thank you@rubensayshi, This has been added to our Roadmap.

cc: @ak-war

Ak-x avatar Sep 28 '21 17:09 Ak-x