Skip to content

Commit

Permalink
fix: Remove auto unknown_error transaction status (#2440)
Browse files Browse the repository at this point in the history
* ref: Mark transaction as failed on error

* ref: Remove transaction status

* fix: Don't set status if UnknownError
  • Loading branch information
HazAT authored Feb 19, 2020
1 parent a46f7ee commit 779dfe3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
20 changes: 10 additions & 10 deletions packages/apm/src/integrations/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,16 @@ export class Tracing implements Integration {
return event;
}

if (
Tracing.options.maxTransactionDuration !== 0 &&
Tracing._isEnabled() &&
event.type === 'transaction' &&
event.timestamp &&
event.start_timestamp &&
(event.timestamp - event.start_timestamp > Tracing.options.maxTransactionDuration ||
event.timestamp - event.start_timestamp < 0)
) {
return null;
if (Tracing._isEnabled()) {
const isOutdatedTransaction =
event.timestamp &&
event.start_timestamp &&
(event.timestamp - event.start_timestamp > Tracing.options.maxTransactionDuration ||
event.timestamp - event.start_timestamp < 0);

if (Tracing.options.maxTransactionDuration !== 0 && event.type === 'transaction' && isOutdatedTransaction) {
return null;
}
}

return event;
Expand Down
5 changes: 4 additions & 1 deletion packages/apm/src/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ export class Span implements SpanInterface, SpanContext {
*/
public setHttpStatus(httpStatus: number): this {
this.setTag('http.status_code', String(httpStatus));
this.setStatus(SpanStatus.fromHttpCode(httpStatus));
const spanStatus = SpanStatus.fromHttpCode(httpStatus);
if (spanStatus !== SpanStatus.UnknownError) {
this.setStatus(spanStatus);
}
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export enum SpanStatus {
/** The operation completed successfully. */
Ok = 'ok',
/** Deadline expired before operation could complete. */
DealineExceeded = 'deadline_exceeded',
DeadlineExceeded = 'deadline_exceeded',
/** 401 Unauthorized (actually does mean unauthenticated according to RFC 7235) */
Unauthenticated = 'unauthenticated',
/** 403 Forbidden */
Expand Down Expand Up @@ -164,7 +164,7 @@ export namespace SpanStatus {
case 503:
return SpanStatus.Unavailable;
case 504:
return SpanStatus.DealineExceeded;
return SpanStatus.DeadlineExceeded;
default:
return SpanStatus.InternalError;
}
Expand Down

0 comments on commit 779dfe3

Please sign in to comment.