Skip to content

Commit

Permalink
ref: Remove status from tags in transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
HazAT committed Mar 13, 2020
1 parent 712b6e7 commit 03f751f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions packages/apm/src/span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export class Span implements SpanInterface, SpanContext {
*/
private readonly _parentSpanId?: string;

/**
* Internal keeper of the status
*/
private _status?: SpanStatus;

/**
* @inheritDoc
*/
Expand Down Expand Up @@ -153,6 +158,9 @@ export class Span implements SpanInterface, SpanContext {
if (spanContext.tags) {
this.tags = spanContext.tags;
}
if (spanContext.status) {
this._status = spanContext.status;
}
}

/**
Expand Down Expand Up @@ -229,7 +237,7 @@ export class Span implements SpanInterface, SpanContext {
* @inheritDoc
*/
public setStatus(value: SpanStatus): this {
this.setTag('status', value);
this._status = value;
return this;
}

Expand All @@ -249,7 +257,7 @@ export class Span implements SpanInterface, SpanContext {
* @inheritDoc
*/
public isSuccess(): boolean {
return this.tags.status === SpanStatus.Ok;
return this._status === SpanStatus.Ok;
}

/**
Expand Down Expand Up @@ -333,7 +341,7 @@ export class Span implements SpanInterface, SpanContext {
op: this.op,
parent_span_id: this._parentSpanId,
span_id: this._spanId,
status: this.tags.status,
status: this._status,
tags: Object.keys(this.tags).length > 0 ? this.tags : undefined,
trace_id: this._traceId,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/apm/test/span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ describe('Span', () => {
test('setStatus', () => {
const span = new Span({});
span.setStatus(SpanStatus.PermissionDenied);
expect(span.tags.status).toBe('permission_denied');
expect((span.getTraceContext() as any).status).toBe('permission_denied');
});

test('setHttpStatus', () => {
const span = new Span({});
span.setHttpStatus(404);
expect(span.tags.status).toBe('not_found');
expect((span.getTraceContext() as any).status).toBe('not_found');
expect(span.tags['http.status_code']).toBe('404');
});

Expand Down

0 comments on commit 03f751f

Please sign in to comment.