Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { loggingTransport } = require('@sentry-internal/node-integration-tests');
const Sentry = require('@sentry/node');
const http = require('http');

Sentry.init({
dsn: 'https://[email protected]/1337',
Expand All @@ -11,7 +10,7 @@ Sentry.init({
integrations: [
Sentry.httpIntegration({
ignoreOutgoingRequests: (url, request) => {
if (url === 'http://example.com/blockUrl') {
if (url === 'https://example.com/blockUrl') {
return true;
}

Expand All @@ -24,6 +23,8 @@ Sentry.init({
],
});

const https = require('https');

// express must be required after Sentry is initialized
const express = require('express');
const cors = require('cors');
Expand All @@ -34,16 +35,16 @@ const app = express();
app.use(cors());

app.get('/testUrl', (_req, response) => {
makeHttpRequest('http://example.com/blockUrl').then(() => {
makeHttpRequest('http://example.com/pass').then(() => {
makeHttpRequest('https://example.com/blockUrl').then(() => {
makeHttpRequest('https://example.com/pass').then(() => {
response.send({ response: 'done' });
});
});
});

app.get('/testRequest', (_req, response) => {
makeHttpRequest('http://example.com/blockRequest').then(() => {
makeHttpRequest('http://example.com/pass').then(() => {
makeHttpRequest('https://example.com/blockRequest').then(() => {
makeHttpRequest('https://example.com/pass').then(() => {
response.send({ response: 'done' });
});
});
Expand All @@ -55,7 +56,7 @@ startExpressServerAndSendPortToRunner(app);

function makeHttpRequest(url) {
return new Promise((resolve, reject) => {
http
https
.get(url, res => {
res.on('data', () => {});
res.on('end', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ describe('httpIntegration', () => {

const requestSpans = event.spans?.filter(span => span.op === 'http.client');
expect(requestSpans).toHaveLength(1);
expect(requestSpans![0]?.description).toBe('GET http://example.com/pass');
expect(requestSpans![0]?.description).toBe('GET https://example.com/pass');

const breadcrumbs = event.breadcrumbs?.filter(b => b.category === 'http');
expect(breadcrumbs).toHaveLength(1);
expect(breadcrumbs![0]?.data?.url).toEqual('http://example.com/pass');
expect(breadcrumbs![0]?.data?.url).toEqual('https://example.com/pass');
},
})
.start(done);
Expand All @@ -157,11 +157,11 @@ describe('httpIntegration', () => {

const requestSpans = event.spans?.filter(span => span.op === 'http.client');
expect(requestSpans).toHaveLength(1);
expect(requestSpans![0]?.description).toBe('GET http://example.com/pass');
expect(requestSpans![0]?.description).toBe('GET https://example.com/pass');

const breadcrumbs = event.breadcrumbs?.filter(b => b.category === 'http');
expect(breadcrumbs).toHaveLength(1);
expect(breadcrumbs![0]?.data?.url).toEqual('http://example.com/pass');
expect(breadcrumbs![0]?.data?.url).toEqual('https://example.com/pass');
},
})
.start(done);
Expand Down
Loading