Skip to content

Commit d8c7574

Browse files
committed
fix: Node build
1 parent fa506ce commit d8c7574

File tree

7 files changed

+44
-60
lines changed

7 files changed

+44
-60
lines changed

packages/apm/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sentry/apm",
3-
"version": "5.10.0-beta.3",
3+
"version": "5.9.0",
44
"description": "Extensions for APM",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/core",
@@ -16,10 +16,10 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/hub": "5.10.0-beta.3",
20-
"@sentry/minimal": "5.10.0-beta.3",
21-
"@sentry/types": "5.10.0-beta.3",
22-
"@sentry/utils": "5.10.0-beta.3",
19+
"@sentry/hub": "5.8.0",
20+
"@sentry/minimal": "5.8.0",
21+
"@sentry/types": "5.7.1",
22+
"@sentry/utils": "5.8.0",
2323
"tslib": "^1.9.3"
2424
},
2525
"devDependencies": {

packages/apm/src/integrations/tracing.ts

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export class Tracing implements Integration {
3838
* @param _options TracingOptions
3939
*/
4040
public constructor(private readonly _options: TracingOptions = {}) {
41+
// TODO
4142
makeMain(new Hub());
4243
if (!Array.isArray(_options.tracingOrigins) || _options.tracingOrigins.length === 0) {
4344
const defaultTracingOrigins = ['localhost', /^\//];

packages/apm/src/integrations/transactionactivity.ts

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class TransactionActivity implements Integration {
5656
* @inheritDoc
5757
*/
5858
public constructor(public readonly _options?: Partial<TransactionActivityOptions>) {
59+
// TODO
5960
makeMain(new Hub());
6061
const defaults = {
6162
idleTimeout: 500,

packages/node/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19+
"@sentry/apm": "5.9.0",
1920
"@sentry/core": "5.8.0",
2021
"@sentry/hub": "5.8.0",
2122
"@sentry/types": "5.7.1",

packages/node/src/handlers.ts

+20-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { captureException, getCurrentHub, Span, withScope } from '@sentry/core';
1+
import { Hub, Span } from '@sentry/apm';
2+
import { captureException, getCurrentHub, withScope } from '@sentry/core';
23
import { Event } from '@sentry/types';
34
import { forget, isString, logger, normalize } from '@sentry/utils';
45
import * as cookie from 'cookie';
@@ -30,21 +31,24 @@ export function tracingHandler(): (
3031
// but `req.path` or `req.url` should do the job as well. We could unify this here.
3132
const reqMethod = (req.method || '').toUpperCase();
3233
const reqUrl = req.url;
33-
const hub = getCurrentHub();
34-
const transaction = hub.startSpan({
35-
transaction: `${reqMethod}|${reqUrl}`,
36-
});
37-
hub.configureScope(scope => {
38-
scope.setSpan(transaction);
39-
});
40-
res.once('finish', () => {
41-
if (res.statusCode >= 500) {
42-
transaction.setFailure();
43-
} else {
44-
transaction.setSuccess();
45-
}
46-
transaction.finish();
47-
});
34+
// TODO
35+
const hub = (getCurrentHub() as unknown) as Hub;
36+
if (hub.startSpan) {
37+
const transaction = hub.startSpan({
38+
transaction: `${reqMethod}|${reqUrl}`,
39+
});
40+
hub.configureScope(scope => {
41+
scope.setSpan(transaction);
42+
});
43+
res.once('finish', () => {
44+
if (res.statusCode >= 500) {
45+
transaction.setFailure();
46+
} else {
47+
transaction.setSuccess();
48+
}
49+
transaction.finish();
50+
});
51+
}
4852
next();
4953
};
5054
}

packages/node/src/integrations/http.ts

+16-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { getCurrentHub, Span } from '@sentry/core';
2-
import { Integration } from '@sentry/types';
1+
import { Hub } from '@sentry/apm';
2+
import { getCurrentHub } from '@sentry/core';
3+
import { makeMain } from '@sentry/hub';
4+
import { Integration, Span } from '@sentry/types';
35
import { fill, parseSemver } from '@sentry/utils';
46
import * as http from 'http';
57
import * as https from 'https';
@@ -31,6 +33,8 @@ export class Http implements Integration {
3133
* @inheritDoc
3234
*/
3335
public constructor(options: { breadcrumbs?: boolean; tracing?: boolean } = {}) {
36+
// TODO
37+
makeMain(new Hub());
3438
this._breadcrumbs = typeof options.breadcrumbs === 'undefined' ? true : options.breadcrumbs;
3539
this._tracing = typeof options.tracing === 'undefined' ? false : options.tracing;
3640
}
@@ -80,10 +84,14 @@ function createHandlerWrapper(
8084

8185
let span: Span;
8286
if (tracingEnabled) {
83-
span = getCurrentHub().startSpan({
84-
description: `${typeof options === 'string' || !options.method ? 'GET' : options.method}|${requestUrl}`,
85-
op: 'request',
86-
});
87+
// TODO
88+
const hub = (getCurrentHub() as unknown) as Hub;
89+
if (hub.startSpan) {
90+
span = hub.startSpan({
91+
description: `${typeof options === 'string' || !options.method ? 'GET' : options.method}|${requestUrl}`,
92+
op: 'request',
93+
});
94+
}
8795
}
8896

8997
return originalHandler
@@ -93,7 +101,7 @@ function createHandlerWrapper(
93101
addRequestBreadcrumb('response', requestUrl, this, res);
94102
}
95103
// TODO: Mark >= 500 as failed as well?
96-
if (tracingEnabled) {
104+
if (tracingEnabled && span) {
97105
span.setSuccess();
98106
span.finish();
99107
}
@@ -102,7 +110,7 @@ function createHandlerWrapper(
102110
if (breadcrumbsEnabled) {
103111
addRequestBreadcrumb('error', requestUrl, this);
104112
}
105-
if (tracingEnabled) {
113+
if (tracingEnabled && span) {
106114
span.setFailure();
107115
span.finish();
108116
}

yarn.lock

-31
Original file line numberDiff line numberDiff line change
@@ -1092,37 +1092,6 @@
10921092
universal-user-agent "^2.0.0"
10931093
url-template "^2.0.8"
10941094

1095-
"@sentry/hub@5.10.0-beta.3":
1096-
version "5.10.0-beta.3"
1097-
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.10.0-beta.3.tgz#12ac48561411ca8be6be3191b8b43e73a7eda68c"
1098-
integrity sha512-zCw/lOaNskP4bDUBSMK5h5Mvb9cYAZI0LmlCGNHLpd+82R5+VUCzZBMlcAnaQHfXoTc2hPITK+A29YeC8PvJxQ==
1099-
dependencies:
1100-
"@sentry/types" "5.10.0-beta.3"
1101-
"@sentry/utils" "5.10.0-beta.3"
1102-
tslib "^1.9.3"
1103-
1104-
"@sentry/minimal@5.10.0-beta.3":
1105-
version "5.10.0-beta.3"
1106-
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.10.0-beta.3.tgz#51d0ecff4863a04082f2b4d907016edfa5a85d69"
1107-
integrity sha512-V+Ln8QHkGJeEWEVXqjD8wrfR5vBcdlOcUmDXOq60UDbBF8i6PsPoKsO8xHnIY8wQUmN4/aV301tc0r2uaswX5g==
1108-
dependencies:
1109-
"@sentry/hub" "5.10.0-beta.3"
1110-
"@sentry/types" "5.10.0-beta.3"
1111-
tslib "^1.9.3"
1112-
1113-
"@sentry/types@5.10.0-beta.3":
1114-
version "5.10.0-beta.3"
1115-
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.10.0-beta.3.tgz#f34b81e5b1286147e5ba173baea23897f2def6e3"
1116-
integrity sha512-4CmlpvuUkhPc4JLrxp4z8W/N4XP6xTbsDx9rNYbUebWDgbHfz+vbbTJihMWzpZU7V4/YM+P8ik2Dgaflb5uAdw==
1117-
1118-
"@sentry/utils@5.10.0-beta.3":
1119-
version "5.10.0-beta.3"
1120-
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.10.0-beta.3.tgz#a327e4e5d90b547b918e2ed743ae51ef1a11fadf"
1121-
integrity sha512-frcC6C94LTXa8M8aiAjJ9mebhY1N90/VY+ouHwYcivUQRlz3zKdfEOPO9+uEeZP3hhddvljk3Ke0K9z8JgDTFQ==
1122-
dependencies:
1123-
"@sentry/types" "5.10.0-beta.3"
1124-
tslib "^1.9.3"
1125-
11261095
"@sinonjs/commons@^1", "@sinonjs/commons@^1.4.0":
11271096
version "1.4.0"
11281097
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.4.0.tgz#7b3ec2d96af481d7a0321252e7b1c94724ec5a78"

0 commit comments

Comments
 (0)