Skip to content

Commit fe81e33

Browse files
committed
fixes
1 parent b4a39c4 commit fe81e33

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

packages/browser/src/tracing/backgroundtab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function registerBackgroundTabDetection(): void {
2727

2828
// We should not set status if it is already set, this prevent important statuses like
2929
// error or data loss from being overwritten on transaction.
30-
if (!status) {
30+
if (status === 'ok') {
3131
rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message: cancelledStatus });
3232
}
3333

packages/core/src/tracing/trace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function startSpan<T>(options: StartSpanOptions, callback: (span: Span) =
9191
() => {
9292
// Only update the span status if it hasn't been changed yet, and the span is not yet finished
9393
const { status } = spanToJSON(activeSpan);
94-
if (activeSpan.isRecording() && (!status || status === 'ok')) {
94+
if (activeSpan.isRecording() && status === 'ok') {
9595
activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
9696
}
9797
},
@@ -157,7 +157,7 @@ export function startSpanManual<T>(options: StartSpanOptions, callback: (span: S
157157
() => {
158158
// Only update the span status if it hasn't been changed yet, and the span is not yet finished
159159
const { status } = spanToJSON(activeSpan);
160-
if (activeSpan.isRecording() && (!status || status === 'ok')) {
160+
if (activeSpan.isRecording() && status === 'ok') {
161161
activeSpan.setStatus({ code: SPAN_STATUS_ERROR, message: 'internal_error' });
162162
}
163163
},

packages/opentelemetry/src/applyOtelSpanData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ export function applyOtelSpanKind(span: Span, kind: SpanKind | undefined): void
109109
function applyOtelSpanStatus(
110110
span: Span,
111111
attributes: SpanAttributes,
112-
status: string | undefined,
112+
status: string,
113113
spanStreamingEnabled: boolean,
114114
): void {
115-
if (status === undefined) {
115+
if (status === 'ok') {
116116
span.setStatus(inferStatusFromAttributes(attributes) || { code: SPAN_STATUS_OK });
117117
return;
118118
}

packages/opentelemetry/src/trace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function _startSpan<T>(options: OpenTelemetrySpanContext, callback: (span: Span)
7777
return handleCallbackErrors(
7878
() => callback(span),
7979
() => {
80-
// Only set the span status to ERROR when there wasn't any status set before, in order to avoid stomping useful span statuses
80+
// Only set the span status to ERROR when there wasn't any error status set before, in order to avoid stomping useful span statuses
8181
if (spanToJSON(span).status === 'ok') {
8282
span.setStatus({ code: SpanStatusCode.ERROR });
8383
}
@@ -94,7 +94,7 @@ function _startSpan<T>(options: OpenTelemetrySpanContext, callback: (span: Span)
9494
return handleCallbackErrors(
9595
() => callback(span),
9696
() => {
97-
// Only set the span status to ERROR when there wasn't any status set before, in order to avoid stomping useful span statuses
97+
// Only set the span status to ERROR when there wasn't any error status set before, in order to avoid stomping useful span statuses
9898
if (spanToJSON(span).status === 'ok') {
9999
span.setStatus({ code: SpanStatusCode.ERROR });
100100
}

0 commit comments

Comments
 (0)