This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Repository navigation
feat: Allow to configure stacktrace for captureMessage calls - #388
Merged
Merged
Conversation
mitsuhiko
reviewed
Oct 5, 2017
| var ex; | ||
| // Generate a "synthetic" stack trace | ||
| try { | ||
| throw new Error(message); |
Contributor
There was a problem hiding this comment.
do you have to throw the error to get the stack?
Contributor
Author
There was a problem hiding this comment.
No, it's just more explicit, as we wrap it in try clause. Also this is how we have it written in raven-js and I'm trying to write as unified code as possible.
Contributor
There was a problem hiding this comment.
I'm mostly asking because throwing an exception vs just creating an error should have noticable performance differences. And since message logging is potentially more common than crashes it might be a concern here.
Contributor
Author
There was a problem hiding this comment.
I'm surprised with this, but you're right : o
throw new Error(i)
608.497162ms
575.068622ms
574.888692ms
540.633688ms
540.919783ms
550.634267ms
577.011109ms
541.462129ms
568.272018ms
573.879691ms
avg: 565.1267161000001ms
new Error(i)
410.160736ms
412.978303ms
423.740643ms
434.467241ms
420.66899ms
426.131056ms
430.911071ms
426.683749ms
429.369119ms
432.251688ms
avg: 424.73625960000004ms
var start = process.hrtime()
var avg = 0
var n = 10
var sample = 100000
console.log('\nthrow new Error(i)')
for (var j = 0; j < n; j++) {
for (var i = 0; i < sample; i++) {
try {
throw new Error(i)
} catch (e) {}
}
end = process.hrtime(start)[1]
start = process.hrtime()
avg += end
console.log('' + (end/1000000) + 'ms')
}
console.log('\navg: ' + (avg/n/1000000) + 'ms')
console.log('\nnew Error(i)')
avg = 0
for (var j = 0; j < n; j++) {
for (var i = 0; i < sample; i++) {
try {
new Error(i)
} catch (e) {}
}
end = process.hrtime(start)[1]
start = process.hrtime()
avg += end
console.log('' + (end/1000000) + 'ms')
}
console.log('\navg: ' + (avg/n/1000000) + 'ms')
```js
Contributor
Author
There was a problem hiding this comment.
tests are failing without , in the end it is required ¯_(ツ)_/¯throw
kamilogorek
force-pushed
the
message-stacktrace
branch
3 times, most recently
from
October 6, 2017 10:08
316dac8 to
19a8caa
Compare
mitsuhiko
approved these changes
Oct 6, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ref #332
Stack trace example:

Removed frame (https://github.com/getsentry/raven-node/compare/message-stacktrace?expand=1#diff-50cfa59973c04321b5da0c6da0fdf4feR337):
