Skip to content
Merged
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
12 changes: 6 additions & 6 deletions packages/remix/src/utils/instrumentServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ function makeWrappedDocumentRequestFunction(
const activeTransaction = getActiveTransaction();
const currentScope = getCurrentHub().getScope();

if (!activeTransaction || !currentScope) {
if (!currentScope) {
return origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context);
}

try {
const span = activeTransaction.startChild({
const span = activeTransaction?.startChild({
op: 'remix.server.documentRequest',
description: activeTransaction.name,
tags: {
Expand All @@ -125,7 +125,7 @@ function makeWrappedDocumentRequestFunction(

res = await origDocumentRequestFunction.call(this, request, responseStatusCode, responseHeaders, context);

span.finish();
span?.finish();
} catch (err) {
captureRemixServerException(err, 'documentRequest');
throw err;
Expand All @@ -141,12 +141,12 @@ function makeWrappedDataFunction(origFn: DataFunction, id: string, name: 'action
const activeTransaction = getActiveTransaction();
const currentScope = getCurrentHub().getScope();

if (!activeTransaction || !currentScope) {
if (!currentScope) {
return origFn.call(this, args);
}

try {
const span = activeTransaction.startChild({
const span = activeTransaction?.startChild({
op: `remix.server.${name}`,
description: id,
tags: {
Expand All @@ -162,7 +162,7 @@ function makeWrappedDataFunction(origFn: DataFunction, id: string, name: 'action
res = await origFn.call(this, args);

currentScope.setSpan(activeTransaction);
span.finish();
span?.finish();
} catch (err) {
captureRemixServerException(err, name);
throw err;
Expand Down