Skip to content

Commit 49142c1

Browse files
authored
ref: Remove status from tags in transaction (getsentry#2497)
1 parent 712b6e7 commit 49142c1

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/apm/src/span.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export class Span implements SpanInterface, SpanContext {
7171
*/
7272
private readonly _parentSpanId?: string;
7373

74+
/**
75+
* Internal keeper of the status
76+
*/
77+
private _status?: SpanStatus;
78+
7479
/**
7580
* @inheritDoc
7681
*/
@@ -153,6 +158,9 @@ export class Span implements SpanInterface, SpanContext {
153158
if (spanContext.tags) {
154159
this.tags = spanContext.tags;
155160
}
161+
if (spanContext.status) {
162+
this._status = spanContext.status;
163+
}
156164
}
157165

158166
/**
@@ -229,7 +237,7 @@ export class Span implements SpanInterface, SpanContext {
229237
* @inheritDoc
230238
*/
231239
public setStatus(value: SpanStatus): this {
232-
this.setTag('status', value);
240+
this._status = value;
233241
return this;
234242
}
235243

@@ -249,7 +257,7 @@ export class Span implements SpanInterface, SpanContext {
249257
* @inheritDoc
250258
*/
251259
public isSuccess(): boolean {
252-
return this.tags.status === SpanStatus.Ok;
260+
return this._status === SpanStatus.Ok;
253261
}
254262

255263
/**
@@ -333,7 +341,7 @@ export class Span implements SpanInterface, SpanContext {
333341
op: this.op,
334342
parent_span_id: this._parentSpanId,
335343
span_id: this._spanId,
336-
status: this.tags.status,
344+
status: this._status,
337345
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
338346
trace_id: this._traceId,
339347
});

packages/apm/test/span.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ describe('Span', () => {
5555
test('setStatus', () => {
5656
const span = new Span({});
5757
span.setStatus(SpanStatus.PermissionDenied);
58-
expect(span.tags.status).toBe('permission_denied');
58+
expect((span.getTraceContext() as any).status).toBe('permission_denied');
5959
});
6060

6161
test('setHttpStatus', () => {
6262
const span = new Span({});
6363
span.setHttpStatus(404);
64-
expect(span.tags.status).toBe('not_found');
64+
expect((span.getTraceContext() as any).status).toBe('not_found');
6565
expect(span.tags['http.status_code']).toBe('404');
6666
});
6767

0 commit comments

Comments
 (0)