-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(release-health): Prevent sending terminal status session updates
Drops sending session updates for sessions that are already in terminal states and caps the number of errors for session at 1
- Loading branch information
1 parent
6829c8c
commit fe53dd9
Showing
3 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
65 changes: 65 additions & 0 deletions
65
packages/node/test/manual/release-health/single-session/errors-in-session-capped-to-one.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const Sentry = require('../../../../dist'); | ||
const { assertSessions, constructStrippedSessionObject, BaseDummyTransport } = require('../test-utils'); | ||
let sessionCounter = 0; | ||
process.on('exit', ()=> { | ||
if (process.exitCode !== 1) { | ||
console.log('SUCCESS: All application mode sessions were sent to node transport as expected'); | ||
} | ||
}) | ||
|
||
class DummyTransport extends BaseDummyTransport { | ||
sendSession(session) { | ||
sessionCounter++; | ||
if (sessionCounter === 1) { | ||
assertSessions(constructStrippedSessionObject(session), | ||
{ | ||
init: true, | ||
status: 'ok', | ||
errors: 1, | ||
release: '1.1' | ||
} | ||
) | ||
} | ||
else if (sessionCounter === 2) { | ||
assertSessions(constructStrippedSessionObject(session), | ||
{ | ||
init: false, | ||
status: 'ok', | ||
errors: 1, | ||
release: '1.1' | ||
} | ||
) | ||
} | ||
else if (sessionCounter === 3) { | ||
assertSessions(constructStrippedSessionObject(session), | ||
{ | ||
init: false, | ||
status: 'exited', | ||
errors: 1, | ||
release: '1.1' | ||
} | ||
) | ||
} | ||
else { | ||
console.log('FAIL: Received way too many Sessions!'); | ||
process.exit(1); | ||
} | ||
return super.sendSession(session); | ||
} | ||
} | ||
|
||
Sentry.init({ | ||
dsn: 'http://[email protected]/1337', | ||
release: '1.1', | ||
transport: DummyTransport, | ||
autoSessionTracking: true | ||
}); | ||
/** | ||
* The following code snippet will throw multiple errors, and thereby send session updates everytime an error is | ||
* captured. However, the number of errors in the session should be capped at 1, regardless of how many errors there are | ||
*/ | ||
for (let i = 0; i < 2; i++) { | ||
Sentry.captureException(new Error('hello world')); | ||
} | ||
|
||
|