Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: introduce ended property on Span #625

Merged
merged 10 commits into from
Mar 10, 2020
1 change: 1 addition & 0 deletions packages/opentelemetry-exporter-collector/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const mockedReadableSpan: ReadableSpan = {
parentSpanId: '78a8915098864388',
startTime: [1574120165, 429803070],
endTime: [1574120165, 438688070],
ended: true,
status: { code: 0 },
attributes: { component: 'document-load' },
links: [
Expand Down
1 change: 1 addition & 0 deletions packages/opentelemetry-exporter-jaeger/test/jaeger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe('JaegerExporter', () => {
spanContext,
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
status: {
code: types.CanonicalCode.DATA_LOSS,
},
Expand Down
4 changes: 4 additions & 0 deletions packages/opentelemetry-exporter-jaeger/test/transform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('transform', () => {
spanContext,
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
status: {
code: types.CanonicalCode.OK,
},
Expand Down Expand Up @@ -131,6 +132,7 @@ describe('transform', () => {
spanContext,
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
status: {
code: types.CanonicalCode.DATA_LOSS,
message: 'data loss',
Expand Down Expand Up @@ -187,6 +189,7 @@ describe('transform', () => {
spanContext,
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
status: {
code: types.CanonicalCode.OK,
},
Expand Down Expand Up @@ -230,6 +233,7 @@ describe('transform', () => {
},
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
status: {
code: types.CanonicalCode.DATA_LOSS,
message: 'data loss',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('Stackdriver Trace Exporter', () => {
duration: [32, 800000000],
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
events: [],
kind: types.SpanKind.CLIENT,
links: [],
Expand Down Expand Up @@ -140,6 +141,7 @@ describe('Stackdriver Trace Exporter', () => {
duration: [32, 800000000],
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
events: [],
kind: types.SpanKind.CLIENT,
links: [],
Expand Down Expand Up @@ -171,6 +173,7 @@ describe('Stackdriver Trace Exporter', () => {
duration: [32, 800000000],
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
events: [],
kind: types.SpanKind.CLIENT,
links: [],
Expand Down Expand Up @@ -200,6 +203,7 @@ describe('Stackdriver Trace Exporter', () => {
duration: [32, 800000000],
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
events: [],
kind: types.SpanKind.CLIENT,
links: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('transform', () => {
duration: [32, 800000000],
startTime: [1566156729, 709],
endTime: [1566156731, 709],
ended: true,
events: [],
kind: types.SpanKind.CLIENT,
links: [],
Expand Down
3 changes: 3 additions & 0 deletions packages/opentelemetry-exporter-zipkin/test/zipkin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function getReadableSpan() {
},
startTime: [startTime, 0],
endTime: [startTime + duration, 0],
ended: true,
duration: [duration, 0],
status: {
code: types.CanonicalCode.OK,
Expand Down Expand Up @@ -133,6 +134,7 @@ describe('ZipkinExporter', () => {
},
startTime: [startTime, 0],
endTime: [startTime + duration, 0],
ended: true,
duration: [duration, 0],
status: {
code: types.CanonicalCode.OK,
Expand All @@ -159,6 +161,7 @@ describe('ZipkinExporter', () => {
},
startTime: [startTime, 0],
endTime: [startTime + duration, 0],
ended: true,
duration: [duration, 0],
status: {
code: types.CanonicalCode.OK,
Expand Down
8 changes: 8 additions & 0 deletions packages/opentelemetry-tracing/src/Span.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ export class Span implements types.Span, ReadableSpan {
return true;
}

isEnded(): boolean {
Flarna marked this conversation as resolved.
Show resolved Hide resolved
return this._ended;
}

toReadableSpan(): ReadableSpan {
return this;
}
Expand All @@ -180,6 +184,10 @@ export class Span implements types.Span, ReadableSpan {
return this._duration;
}

get ended(): boolean {
return this._ended;
}

private _isSpanEnded(): boolean {
if (this._ended) {
this._logger.warn(
Expand Down
1 change: 1 addition & 0 deletions packages/opentelemetry-tracing/src/export/ReadableSpan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ export interface ReadableSpan {
readonly links: Link[];
readonly events: TimedEvent[];
readonly duration: HrTime;
readonly ended: boolean;
}
7 changes: 7 additions & 0 deletions packages/opentelemetry-tracing/test/Span.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,11 @@ describe('Span', () => {
span.updateName('bar-span');
assert.strictEqual(span.name, 'foo-span');
});

it('should have ended', () => {
const span = new Span(tracer, name, spanContext, SpanKind.SERVER);
assert.strictEqual(span.ended, false);
span.end();
assert.strictEqual(span.ended, true);
});
});