Description
Description
My original problem is that I want the post body to be logged with each notification to Bugsnag. Since the Java library doesn't do this, I have to hack together a solution on my side.
It's an expensive task to take the request body my controller received and then serialize it back into a string and attach it to Bugsnag using addThreadMetaData
. If the exception rarely occurs, I would be wasting time on this expensive operation on all successful requests.
Describe the solution you'd like
I'd like addThreadMetaData
to take a callback (or a runnable lambda) instead of an Object, so that Bugsnag can evaluate it only if it needs to perform the notification to Bugsnag.
Describe alternatives you've considered
Although the method bugsnag.addCallback
gives access to the granular report, the callback is created when Bugsnag is initialized. The callback has no way to be aware of the controller state in Spring.
Additional context
My Spring controller decodes the post body into a specific object, for example
void postRequest(@RequestBody Payload payload) {}
I tried addThreadMetaData(..., payload)
but Bugsnag strips the contents. You're using an object mapper that filters for example things that aren't marked with your Expose
annotation.
An alternate solution to this thread: you could continue to use your existing object mapper for your own objects, but use a second new object mapper for the objects added via addThreadMetaData
so that you stop stripping out the data.