-
-
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.
Backport of #14902
- Loading branch information
Showing
5 changed files
with
76 additions
and
6 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...node-integration-tests/suites/express/tracing/tracesSampler/scenario-normalizedRequest.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,34 @@ | ||
const { loggingTransport } = require('@sentry-internal/node-integration-tests'); | ||
const Sentry = require('@sentry/node'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://public@dsn.ingest.sentry.io/1337', | ||
release: '1.0', | ||
transport: loggingTransport, | ||
tracesSampler: samplingContext => { | ||
// The sampling decision is based on whether the data in `normalizedRequest` is available --> this is what we want to test for | ||
return ( | ||
samplingContext.normalizedRequest.url.includes('/test-normalized-request?query=123') && | ||
samplingContext.normalizedRequest.method && | ||
samplingContext.normalizedRequest.query_string === 'query=123' && | ||
!!samplingContext.normalizedRequest.headers | ||
); | ||
}, | ||
}); | ||
|
||
// express must be required after Sentry is initialized | ||
const express = require('express'); | ||
const cors = require('cors'); | ||
const { startExpressServerAndSendPortToRunner } = require('@sentry-internal/node-integration-tests'); | ||
|
||
const app = express(); | ||
|
||
app.use(cors()); | ||
|
||
app.get('/test-normalized-request', (_req, res) => { | ||
res.send('Success'); | ||
}); | ||
|
||
Sentry.setupExpressErrorHandler(app); | ||
|
||
startExpressServerAndSendPortToRunner(app); |
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
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