Skip to content

Commit 2b21ff7

Browse files
committed
ref: Pre-release linter and tests patches
1 parent 5ca412a commit 2b21ff7

File tree

6 files changed

+70
-26
lines changed

6 files changed

+70
-26
lines changed

packages/hub/src/hub.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,7 @@ export class Hub implements HubInterface {
430430

431431
if (span.sampled) {
432432
const experimentsOptions = (client && client.getOptions()._experiments) || {};
433-
const maxSpans = experimentsOptions.maxSpans || 1000;
434-
span.initFinishedSpans(maxSpans);
433+
span.initFinishedSpans(experimentsOptions.maxSpans);
435434
}
436435

437436
return span;

packages/hub/src/span.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ export class Span implements SpanInterface, SpanContext {
134134
if (spanContext.parentSpanId) {
135135
this._parentSpanId = spanContext.parentSpanId;
136136
}
137-
if (spanContext.sampled) {
137+
// We want to include booleans as well here
138+
if ('sampled' in spanContext) {
138139
this.sampled = spanContext.sampled;
139140
}
140141
if (spanContext.transaction) {
@@ -158,7 +159,7 @@ export class Span implements SpanInterface, SpanContext {
158159
* Attaches SpanRecorder to the span itself
159160
* @param maxlen maximum number of spans that can be recorded
160161
*/
161-
public initFinishedSpans(maxlen: number): void {
162+
public initFinishedSpans(maxlen: number = 1000): void {
162163
if (!this.spanRecorder) {
163164
this.spanRecorder = new SpanRecorder(maxlen);
164165
}
@@ -288,8 +289,7 @@ export class Span implements SpanInterface, SpanContext {
288289
logger.warn('Discarding transaction Span without sampling decision');
289290
return undefined;
290291
}
291-
292-
const finishedSpans = !this.spanRecorder ? [] : this.spanRecorder.finishedSpans.filter(s => s !== this);
292+
const finishedSpans = this.spanRecorder ? this.spanRecorder.finishedSpans.filter(s => s !== this) : [];
293293

294294
return this._hub.captureEvent({
295295
// TODO: Is this necessary? We already do store contextx in in applyToEvent,

packages/hub/test/span.test.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,17 @@ describe('Span', () => {
169169

170170
test('finish a scope span with transaction', () => {
171171
const spy = jest.spyOn(hub as any, 'captureEvent') as any;
172-
const span = new Span({ transaction: 'test' }, hub);
172+
const span = new Span({ transaction: 'test', sampled: false }, hub);
173+
span.initFinishedSpans();
173174
span.finish();
174175
expect(spy).toHaveBeenCalled();
175-
expect(spy.mock.calls[0][0].spans).toBeUndefined();
176+
expect(spy.mock.calls[0][0].spans).toHaveLength(0);
176177
});
177178

178179
test('finish a scope span with transaction + child span', () => {
179180
const spy = jest.spyOn(hub as any, 'captureEvent') as any;
180-
const parentSpan = new Span({ transaction: 'test' }, hub);
181+
const parentSpan = new Span({ transaction: 'test', sampled: false }, hub);
182+
parentSpan.initFinishedSpans();
181183
const childSpan = parentSpan.child();
182184
childSpan.finish();
183185
parentSpan.finish();

packages/integrations/src/express.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { EventProcessor, Hub, Integration } from '@sentry/types';
22
import { logger } from '@sentry/utils';
3+
// tslint:disable-next-line:no-implicit-dependencies
34
import { Application, ErrorRequestHandler, NextFunction, Request, RequestHandler, Response } from 'express';
45

56
/**

packages/node/src/handlers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { captureException, getCurrentHub } from '@sentry/core';
1+
import { captureException, getCurrentHub, Span, withScope } from '@sentry/core';
22
import { Event } from '@sentry/types';
33
import { forget, isString, logger, normalize } from '@sentry/utils';
44
import * as cookie from 'cookie';

yarn.lock

+58-16
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,14 @@
11931193
dependencies:
11941194
"@babel/types" "^7.3.0"
11951195

1196+
"@types/body-parser@*":
1197+
version "1.17.1"
1198+
resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.17.1.tgz#18fcf61768fb5c30ccc508c21d6fd2e8b3bf7897"
1199+
integrity sha512-RoX2EZjMiFMjZh9lmYrwgoP9RTpAjSHiJxdp4oidAQVO02T7HER3xj9UKue5534ULWeqVEkujhWcyvUce+d68w==
1200+
dependencies:
1201+
"@types/connect" "*"
1202+
"@types/node" "*"
1203+
11961204
"@types/caseless@*":
11971205
version "0.12.1"
11981206
resolved "https://registry.yarnpkg.com/@types/caseless/-/caseless-0.12.1.tgz#9794c69c8385d0192acc471a540d1f8e0d16218a"
@@ -1202,10 +1210,17 @@
12021210
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.1.7.tgz#1b8e33b61a8c09cbe1f85133071baa0dbf9fa71a"
12031211
integrity sha512-2Y8uPt0/jwjhQ6EiluT0XCri1Dbplr0ZxfFXUz+ye13gaqE8u5gL5ppao1JrUYr9cIip5S6MvQzBS7Kke7U9VA==
12041212

1205-
"@types/cookie@^0.3.2":
1206-
version "0.3.3"
1207-
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.3.tgz#85bc74ba782fb7aa3a514d11767832b0e3bc6803"
1208-
integrity sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow==
1213+
"@types/connect@*":
1214+
version "3.4.32"
1215+
resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.32.tgz#aa0e9616b9435ccad02bc52b5b454ffc2c70ba28"
1216+
integrity sha512-4r8qa0quOvh7lGD0pre62CAb1oni1OO6ecJLGCezTmhQ8Fz50Arx9RUszryR8KlgK6avuSXvviL6yWyViQABOg==
1217+
dependencies:
1218+
"@types/node" "*"
1219+
1220+
"@types/cookie@0.3.2":
1221+
version "0.3.2"
1222+
resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.3.2.tgz#453f4b14b25da6a8ea4494842dedcbf0151deef9"
1223+
integrity sha512-aHQA072E10/8iUQsPH7mQU/KUyQBZAGzTVRCUvnSz8mSvbrYsP4xEO2RSA0Pjltolzi0j8+8ixrm//Hr4umPzw==
12091224

12101225
"@types/estree@0.0.39":
12111226
version "0.0.39"
@@ -1217,6 +1232,23 @@
12171232
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
12181233
integrity sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==
12191234

1235+
"@types/express-serve-static-core@*":
1236+
version "4.16.10"
1237+
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.16.10.tgz#3c1313c6e6b75594561b473a286f016a9abf2132"
1238+
integrity sha512-gM6evDj0OvTILTRKilh9T5dTaGpv1oYiFcJAfgSejuMJgGJUsD9hKEU2lB4aiTNy4WwChxRnjfYFuBQsULzsJw==
1239+
dependencies:
1240+
"@types/node" "*"
1241+
"@types/range-parser" "*"
1242+
1243+
"@types/express@^4.17.1":
1244+
version "4.17.1"
1245+
resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.1.tgz#4cf7849ae3b47125a567dfee18bfca4254b88c5c"
1246+
integrity sha512-VfH/XCP0QbQk5B5puLqTLEeFgR8lfCJHZJKkInZ9mkYd+u8byX0kztXEQxEk4wZXJs8HI+7km2ALXjn4YKcX9w==
1247+
dependencies:
1248+
"@types/body-parser" "*"
1249+
"@types/express-serve-static-core" "*"
1250+
"@types/serve-static" "*"
1251+
12201252
"@types/form-data@*":
12211253
version "2.2.1"
12221254
resolved "https://registry.yarnpkg.com/@types/form-data/-/form-data-2.2.1.tgz#ee2b3b8eaa11c0938289953606b745b738c54b1e"
@@ -1288,6 +1320,11 @@
12881320
dependencies:
12891321
"@types/node" "*"
12901322

1323+
"@types/mime@*":
1324+
version "2.0.1"
1325+
resolved "https://registry.yarnpkg.com/@types/mime/-/mime-2.0.1.tgz#dc488842312a7f075149312905b5e3c0b054c79d"
1326+
integrity sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw==
1327+
12911328
"@types/minimatch@*", "@types/minimatch@3.0.3":
12921329
version "3.0.3"
12931330
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
@@ -1308,6 +1345,11 @@
13081345
resolved "https://registry.yarnpkg.com/@types/node/-/node-11.13.7.tgz#85dbb71c510442d00c0631f99dae957ce44fd104"
13091346
integrity sha512-suFHr6hcA9mp8vFrZTgrmqW2ZU3mbWsryQtQlY/QvwTISCw7nw/j+bCQPPohqmskhmqa5wLNuMHTTsc+xf1MQg==
13101347

1348+
"@types/range-parser@*":
1349+
version "1.2.3"
1350+
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.3.tgz#7ee330ba7caafb98090bece86a5ee44115904c2c"
1351+
integrity sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA==
1352+
13111353
"@types/raven@^2.5.1":
13121354
version "2.5.3"
13131355
resolved "https://registry.yarnpkg.com/@types/raven/-/raven-2.5.3.tgz#bd4bed667dd9cfda39452f8ed64a87f45233bc3a"
@@ -1332,6 +1374,14 @@
13321374
dependencies:
13331375
"@types/node" "*"
13341376

1377+
"@types/serve-static@*":
1378+
version "1.13.3"
1379+
resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.13.3.tgz#eb7e1c41c4468272557e897e9171ded5e2ded9d1"
1380+
integrity sha512-oprSwp094zOglVrXdlo/4bAHtKTAxX6VT8FOZlBKrmyLbNvE1zxZyJ6yikMVtHIvwP45+ZQGJn+FdXGKTozq0g==
1381+
dependencies:
1382+
"@types/express-serve-static-core" "*"
1383+
"@types/mime" "*"
1384+
13351385
"@types/shelljs@^0.8.0":
13361386
version "0.8.3"
13371387
resolved "https://registry.yarnpkg.com/@types/shelljs/-/shelljs-0.8.3.tgz#f713f312dbae49ab5025290007e71ea32998e9a9"
@@ -1597,7 +1647,7 @@ after@0.8.2:
15971647
version "0.8.2"
15981648
resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f"
15991649

1600-
agent-base@4, agent-base@4.3.0, agent-base@^4.1.0, agent-base@^4.3.0, agent-base@~4.2.0:
1650+
agent-base@4, agent-base@4.3.0, agent-base@^4.1.0, agent-base@~4.2.0:
16011651
version "4.3.0"
16021652
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee"
16031653
integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==
@@ -3514,7 +3564,7 @@ cookie-signature@1.0.6:
35143564
version "1.0.6"
35153565
resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c"
35163566

3517-
cookie@0.3.1, cookie@^0.3.1:
3567+
cookie@0.3.1:
35183568
version "0.3.1"
35193569
resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.3.1.tgz#e7e0a1f9ef43b4c8ba925c5c5a96e806d16873bb"
35203570

@@ -5432,21 +5482,13 @@ https-browserify@^1.0.0:
54325482
version "1.0.0"
54335483
resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73"
54345484

5435-
https-proxy-agent@^2.2.1:
5485+
https-proxy-agent@2.2.1, https-proxy-agent@^2.2.1:
54365486
version "2.2.1"
54375487
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0"
54385488
dependencies:
54395489
agent-base "^4.1.0"
54405490
debug "^3.1.0"
54415491

5442-
https-proxy-agent@^3.0.0:
5443-
version "3.0.0"
5444-
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-3.0.0.tgz#0106efa5d63d6d6f3ab87c999fa4877a3fd1ff97"
5445-
integrity sha512-y4jAxNEihqvBI5F3SaO2rtsjIOnnNA8sEbuiP+UhJZJHeM2NRm6c09ax2tgqme+SgUUvjao2fJXF4h3D6Cb2HQ==
5446-
dependencies:
5447-
agent-base "^4.3.0"
5448-
debug "^3.1.0"
5449-
54505492
humanize-ms@^1.2.1:
54515493
version "1.2.1"
54525494
resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed"
@@ -7185,7 +7227,7 @@ lru-cache@^5.0.0, lru-cache@^5.1.1:
71857227
dependencies:
71867228
yallist "^3.0.2"
71877229

7188-
lru_map@^0.3.3:
7230+
lru_map@0.3.3:
71897231
version "0.3.3"
71907232
resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd"
71917233
integrity sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0=

0 commit comments

Comments
 (0)