Skip to content

Commit 1669c84

Browse files
committed
ref: Mark transaction as failed on error
1 parent a46f7ee commit 1669c84

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

packages/apm/src/integrations/tracing.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,23 @@ export class Tracing implements Integration {
202202
return event;
203203
}
204204

205-
if (
206-
Tracing.options.maxTransactionDuration !== 0 &&
207-
Tracing._isEnabled() &&
208-
event.type === 'transaction' &&
209-
event.timestamp &&
210-
event.start_timestamp &&
211-
(event.timestamp - event.start_timestamp > Tracing.options.maxTransactionDuration ||
212-
event.timestamp - event.start_timestamp < 0)
213-
) {
214-
return null;
205+
if (Tracing._isEnabled()) {
206+
if (
207+
Tracing.options.maxTransactionDuration !== 0 &&
208+
event.type === 'transaction' &&
209+
event.timestamp &&
210+
event.start_timestamp &&
211+
(event.timestamp - event.start_timestamp > Tracing.options.maxTransactionDuration ||
212+
event.timestamp - event.start_timestamp < 0)
213+
) {
214+
return null;
215+
}
216+
217+
// TODO: Once we have session this should change
218+
// If an event is level fatal we consider the transaction failed
219+
if (event.type !== 'transaction' && event.level === 'fatal') {
220+
Tracing.setTransactionStatus(SpanStatus.InternalError);
221+
}
215222
}
216223

217224
return event;

packages/types/src/span.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export enum SpanStatus {
9191
/** The operation completed successfully. */
9292
Ok = 'ok',
9393
/** Deadline expired before operation could complete. */
94-
DealineExceeded = 'deadline_exceeded',
94+
DeadlineExceeded = 'deadline_exceeded',
9595
/** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */
9696
Unauthenticated = 'unauthenticated',
9797
/** 403 Forbidden */
@@ -164,7 +164,7 @@ export namespace SpanStatus {
164164
case 503:
165165
return SpanStatus.Unavailable;
166166
case 504:
167-
return SpanStatus.DealineExceeded;
167+
return SpanStatus.DeadlineExceeded;
168168
default:
169169
return SpanStatus.InternalError;
170170
}

0 commit comments

Comments
 (0)