8000 add logs showing what functions we land in · sdemjanenko/sentry-javascript@2bc0845 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2bc0845

Browse files
committed
add logs showing what functions we land in
1 parent aaf8e90 commit 2bc0845

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

packages/nextjs/src/utils/instrumentServer.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import * as url from 'url';
1111

1212
import * as Sentry from '../index.server';
1313

14+
console.log('logger: ', logger);
15+
1416
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1517
type PlainObject<T = any> = { [key: string]: T };
1618

@@ -96,6 +98,8 @@ export function instrumentServer(): void {
9698
// handled and the wrapped `Server.findPageComponents` is called:
9799
// Replace URL in transaction name with parameterized version
98100

101+
console.log('in instrumentServer()');
102+
99103
const nextServerPrototype = Object.getPrototypeOf(createNextServer({}));
100104
fill(nextServerPrototype, 'getServerRequestHandler', makeWrappedHandlerGetter);
101105
}
@@ -108,9 +112,12 @@ export function instrumentServer(): void {
108112
* @returns A wrapped version of the same method, to monkeypatch in at server startup
109113
*/
110114
function makeWrappedHandlerGetter(origHandlerGetter: HandlerGetter): WrappedHandlerGetter {
115+
console.log('in makeWrappedHandlerGetter');
111116
// We wrap this purely in order to be able to grab data and do further monkeypatching the first time it runs.
112117
// Otherwise, it's just a pass-through to the original method.
113118
const wrappedHandlerGetter = async function(this: NextServer): Promise<ReqHandler> {
119+
console.log('in wrappedHandlerGetter');
120+
114121
if (!sdkSetupComplete) {
115122
try {
116123
// `SENTRY_SERVER_INIT_PATH` is set at build time, and points to a webpack-processed version of the user's
@@ -157,7 +164,11 @@ function makeWrappedHandlerGetter(origHandlerGetter: HandlerGetter): WrappedHand
157164
* @returns A wrapped version of that logger
158165
*/
159166
function makeWrappedErrorLogger(origErrorLogger: ErrorLogger): WrappedErrorLogger {
167+
console.log('in makeWrappedErrorLogger');
168+
160169
return function(this: Server, err: Error): void {
170+
console.log('in wrappedErrorLogger');
171+
161172
// TODO add context data here
162173
Sentry.captureException(err);
163174
return origErrorLogger.call(this, err);
@@ -188,6 +199,8 @@ function getPublicDirFiles(): Set<string> {
188199
* @returns A wrapped version of that handler
189200
*/
190201
function makeWrappedReqHandler(origReqHandler: ReqHandler): WrappedReqHandler {
202+
console.log('in makeWrappedReqHandler');
203+
191204
const publicDirFiles = getPublicDirFiles();
192205
// add transaction start and stop to the normal request handling
193206
const wrappedReqHandler = async function(
@@ -196,6 +209,8 @@ function makeWrappedReqHandler(origReqHandler: ReqHandler): WrappedReqHandler {
196209
res: NextResponse,
197210
parsedUrl?: url.UrlWithParsedQuery,
198211
): Promise<void> {
212+
console.log('in wrappedReqHandler');
213+
199214
// wrap everything in a domain in order to prevent scope bleed between requests
200215
const local = domain.create();
201216
local.add(req);
@@ -204,6 +219,7 @@ function makeWrappedReqHandler(origReqHandler: ReqHandler): WrappedReqHandler {
204219
// local.on('error', Sentry.captureException);
205220

206221
local.run(() => {
222+
console.log('in domain callback');
207223
const currentScope = Sentry.getCurrentHub().getScope();
208224

209225
if (currentScope) {
@@ -274,8 +290,12 @@ function makeWrappedReqHandler(origReqHandler: ReqHandler): WrappedReqHandler {
274290
function makeWrappedMethodForGettingParameterizedPath(
275291
origMethod: ApiPageEnsurer | PageComponentFinder,
276292
): WrappedApiPageEnsurer | WrappedPageComponentFinder {
293+
console.log('in makeWrappedMethodForGettingParameterizedPath');
294+
console.log('orig method:', origMethod);
295+
277296
// eslint-disable-next-line @typescript-eslint/no-explicit-any
278297
const wrappedMethod = async function(this: Server, parameterizedPath: string, ...args: any[]): Promise<any> {
298+
console.log('in wrapped paramaterized path getter');
279299
const transaction = getActiveTransaction();
280300

281301
// replace specific URL with parameterized version

0 commit comments

Comments
 (0)
0