-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
99 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,23 @@ var app = express(); | |
|
||
// Initalize Sentry (import library and instantiate) | ||
const Sentry = require('@sentry/node'); | ||
Sentry.init({ dsn: 'https://[email protected]/1366275'}); | ||
const Tracing = require('@sentry/tracing'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1366275', | ||
integrations: [ | ||
// Enable HTTP calls tracing | ||
new Sentry.Integrations.Http({ tracing: true }), | ||
// Enable Express.js middleware tracing | ||
new Tracing.Integrations.Express({ app }), | ||
], | ||
|
||
// Sample rate can be set as a decimal between 0 and 1 | ||
// representing the percent of transactions to record | ||
// | ||
// For our example, we will collect all transactions | ||
tracesSampleRate: 1.0, | ||
}); | ||
|
||
let Inventory = { | ||
wrench: 0, | ||
|
@@ -30,6 +46,8 @@ let checkout = (cart) => { | |
|
||
// The request handler must be the first middleware on the app | ||
app.use(Sentry.Handlers.requestHandler()); | ||
// TracingHandler creates a trace for every incoming request | ||
app.use(Sentry.Handlers.tracingHandler()); | ||
|
||
app.use(bodyParser.json()); | ||
app.use(cors()); | ||
|
@@ -69,8 +87,11 @@ app.post('/checkout', function (req, res) { | |
}); | ||
|
||
app.get('/capture-message', function (req, res) { | ||
// Simulate an API call that takes a random amount | ||
// of time and goes long | ||
let delay = 2500; | ||
Sentry.captureMessage('Custom Message'); | ||
res.send('Success'); | ||
setTimeout(() => { res.send('Success'); }, delay); | ||
}); | ||
|
||
app.get('/unhandled', function (req, res) { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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