Comments (10)
The purpose of the CauseStacker interface is primarily for the Cause part rather than the Stack part as it is the only way to chain errors. I see what you mean about losing the error class name, this can be alleviated by making an error wrapper which returns the original error as the Cause as we would then surface both the original error and the wrapper in the UI as they would become part of a chain.
I think the easiest thing to do here is actually to support multiple interfaces, it isn't that hard and would provide some flexibility.
If you have a type that implements part of the interface, i.e. just the Stack part, with a different Stack type than rollbar.Stack
like runtime.Frames
, then making a wrapper around that to turn runtime.Frames
into rollbar.Stack
should be straight forward and would only require the package that is actually reporting to Rollbar, which already has the dependency, to know about the rollbar package types.
Let me see what I can put together to support multiple options for providing your own stack. I have an example with a wrapper type that I will clean up and put in the repo too which shows how to get the original error class name along with the stack.
from rollbar-go.
@dofelt thanks for the suggestion. Our primary maintainer for the Go SDK will be out for a couple of weeks, but when he gets back I'll ask him to take a look at this suggestion.
from rollbar-go.
@jessewgibbs Thanks! I'm more than happy to help out if you think it's something that would benefit the SDK. For now I've just created an intermediate struct that implements the CauseStacker
interface to avoid the dependency.
from rollbar-go.
Any update on this?
from rollbar-go.
@fgblomqvist this is still in our backlog. We're glad to accept PRs if someone out there wants to implement it :)
from rollbar-go.
@jessewgibbs just wrote some code to work my way around it, which naturally felt less than optimal.
I'd happily do the change, I'll take a look tonight to see if I feel like I know what's going on (but no promises) :)
Update: Took a look at it and did some work. Doesn't seem to bad. I'll post an update next week (won't have much time to work on it for the rest of this week).
from rollbar-go.
Until this gets fixed/changed, most likely every error generated by an application will have to be wrapped/aliased in order to satisfy CauseStacker
(due to the rollbar.Stack type). But even once it's been changed (to the proposed runtime.Frames
), most errors will still have to be wrapped/aliased since I've personally not seen many/if any errors that has a "Stack()" method that returns precisely that type. The issue I have with wrapping/aliasing is that the error class name gets lost in the process (on top of the fact that I have to do it to begin with). While it may not be the most important information, I do think it is still nice (and tbh it is shown in Rollbar for a reason).
Now, I get the purpose of checking if the error already has a stack (to simplify in some cases), and that this has to be done by checking for some interface compliance, but I guess I don't really see the point of defining an own interface for this (since it, like I mentioned, will most likely help very few if any people right out-of-box). This leads me to wonder if it's better to just utilize an existing interface that at least a few thousand (if not significantly more) applications already rely on. The most popular error package I know of is pkg/errors and it has a stackTracer
interface (that while not exported, "it is considered a part of its stable public interface."):
type Frame uintptr
type StackTrace []Frame
type stackTracer interface {
StackTrace() errors.StackTrace
}
Then, people can wrap/alias their other error types (that have stack traces) to satisfy this one instead. Alternatively, rollbar-go
can go the direction of supporting multiple interfaces? E.g. on top of it's own Stack
(if that is still considered necessary), it could support errors.stackTracer
, and maybe more in the future.
Yet another solution is to (perhaps drop Stack
and) allow passing of a stack trace separately, similar to how stvp/roll used to do it/is doing it.
Would love some input on these thoughts from @jessewgibbs and/or @dolfelt :)
from rollbar-go.
Did not think about having the wrapper report the original error as the final cause, smart :)
Other than that, sounds good. Not sure if it's a part of your plan, but maybe keep the cause and the stack interface separate (similar to how pkg/errors handles it)? Since they fulfill separate purposes. E.g. one "causer" interfacer and one "stacker/stacktracer" interface (or rather multiple, like we just talked about). I think a lot of error types satisfy a "causer" interface automatically since it seems universal for that to be "Cause() error". But yeah then the user could fiddle to satisfy one of the "stacker" interfaces (if not already satisfied).
from rollbar-go.
@rokob Just to clarify: with what you said, what's the status of this issue? I'm still willing to continue/do the PR for swapping Stack
for runtime.Frames
, but just wanna make sure you don't have in mind to keep CauseStacker as-is and just allow other interfaces.
If Stack
is still going away (or rather, I'm keeping it internally in my fork, with the sole purpose of building a JSON serializable struct from a runtime.Frames
at the end of the flow). I do find runtime.Frames
a bit awkward to work with since it's a more dynamic/linked-list-similar structure compared to a normal array/slice, but I still think it's better than exporting Stack
. That being said, maybe it's better/easier to just go with some alternative, such as []runtime.Frame or perhaps just a []uintptr and then call runtime.CallersFrames on it before we transform it to a JSON serializable struct?
from rollbar-go.
This issue can be closed, I believe.
from rollbar-go.
Related Issues (20)
- Prevent rollbar-go to start a Client by default HOT 1
- SetPlatform is overloaded
- Unexported function on the Transport interface prevents mocking HOT 1
- Consider tagging submodule "errors"?
- IP Logging should not depend on client knowing the remote IP address HOT 2
- Any example for adding rollbar to serverless ? HOT 1
- set a new transport HOT 1
- Take advantage of new Go 1.13 Unwrap method HOT 1
- Confusion around Wait() function HOT 6
- Bug: `LambdaWrapper` panics at runtime when panic occurs inside a lambda handler with multiple return values
- Stop hacker's from thefting HOT 5
- Unclear how to send messages with custom client instance HOT 2
- Segfault when using client HOT 2
- client/transport.Close() does not support context HOT 4
- Will you release this pkg anymore? HOT 3
- 422 Unprocessable Entity after Upgrading to v1.4.2 HOT 1
- Add support for FluentD
- Async transpot can panic HOT 2
- Unable to get IP addresses in gin middleware. HOT 3
- Breaking API change with release of v1.4.3 HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rollbar-go.