Skip to content

Commit

Permalink
Restores old method, marking it deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Cole committed Jun 26, 2019
1 parent a0f096c commit 1249b2d
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ describe('axios instrumentation - integration test', () => {
wuhanWeatherSpanId = annot.traceId.spanId;
}

expect(annot.traceId.parentId).to.equal(None);
expect(annot.traceId.parentSpanId).to.equal(None);
});

expect(beijingWeatherSpanId).to.not.equal(wuhanWeatherSpanId);
Expand Down Expand Up @@ -403,7 +403,7 @@ describe('axios instrumentation - integration test', () => {
wuhanWeatherSpanId = annot.traceId.spanId;
}

expect(annot.traceId.parentId).to.equal(None);
expect(annot.traceId.parentSpanId).to.equal(None);
});

expect(beijingWeatherSpanId).to.not.equal(wuhanWeatherSpanId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('wrapGot', () => {
const {parentId, traceId} = firstArg._zipkin;
expect(parentId).to.equal(id);
expect(traceId).to.not.be.undefined; // eslint-disable-line no-unused-expressions
expect(traceId.parentId.getOrElse()).to.equal(id.traceId);
expect(traceId.parentSpanId.getOrElse()).to.equal(id.traceId);
done();
})
.catch(done);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class GrpcClientInstrumentation {
metadata.add(HttpHeaders.TraceId, traceId.traceId);
metadata.add(HttpHeaders.SpanId, traceId.spanId);

traceId._parentId.ifPresent(psid => {
traceId.parentSpanId.ifPresent(psid => {
metadata.add(HttpHeaders.ParentSpanId, psid);
});
traceId.sampled.ifPresent(sampled => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('gRPC client instrumentation (integration test)', () => {
if (annot.annotation.name === '/weather.WeatherService/GetLocations') {
locationSpanId = annot.traceId.spanId;
}
expect(annot.traceId.parentId).to.equal(None);
expect(annot.traceId.parentSpanId).to.equal(None);
});

expect(weatherSpanId).to.not.equal(locationSpanId);
Expand Down Expand Up @@ -170,7 +170,7 @@ describe('gRPC client instrumentation (integration test)', () => {
locationSpanId = annot.traceId.spanId;
}

expect(annot.traceId.parentId).to.equal(None);
expect(annot.traceId.parentSpanId).to.equal(None);
});

expect(weatherSpanId).to.not.equal(locationSpanId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe('memcached interceptor', () => {
).not.to.equal(annotations[annotations.length / 2].traceId.spanId);

annotations.forEach(ann => {
expect(ann.traceId.parentId.getOrElse()).to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.parentSpanId.getOrElse()).to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.spanId).not.to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.traceId).to.equal(firstAnn.traceId.traceId);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/zipkin-instrumentation-redis/test/integrationTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('redis interceptor', () => {
).not.to.equal(annotations[annotations.length / 2].traceId.spanId);

annotations.forEach(ann => {
expect(ann.traceId.parentId.getOrElse()).to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.parentSpanId.getOrElse()).to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.spanId).not.to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.traceId).to.equal(firstAnn.traceId.traceId);
});
Expand Down Expand Up @@ -110,7 +110,7 @@ describe('redis interceptor', () => {
).not.to.equal(annotations[Math.floor(annotations.length / 2)].traceId.spanId);

annotations.forEach(ann => {
expect(ann.traceId.parentId.getOrElse()).to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.parentSpanId.getOrElse()).to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.spanId).not.to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.traceId).to.equal(firstAnn.traceId.traceId);
});
Expand All @@ -136,7 +136,7 @@ describe('redis interceptor', () => {
const annotations = recorder.record.args.map(args => args[0]);
const firstAnn = annotations[0];
annotations.forEach(ann => {
expect(ann.traceId.parentId.getOrElse()).to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.parentSpanId.getOrElse()).to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.traceId).to.equal(firstAnn.traceId.traceId);
expect(ann.traceId.spanId).not.to.equal(firstAnn.traceId.traceId);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ describe('request instrumentation - integration test', () => {
annotations.forEach(ann => expect(ann.traceId.spanId)
.to.not.equal(rootId.traceId, 'the span id should not equal the root id'));

annotations.forEach(ann => expect(ann.traceId.parentId.getOrElse())
annotations.forEach(ann => expect(ann.traceId.parentSpanId.getOrElse())
.to.have.lengthOf(16).and
.to.equal(rootId.traceId, 'all spans should have the root as their parent'));

Expand Down Expand Up @@ -436,7 +436,7 @@ describe('request instrumentation - integration test', () => {
.to.have.lengthOf(16).and
.to.not.equal(rootId.traceId));

annotations.forEach(ann => expect(ann.traceId.parentId.getOrElse())
annotations.forEach(ann => expect(ann.traceId.parentSpanId.getOrElse())
.to.have.lengthOf(16).and
.to.equal(rootId.traceId, 'all spans should have the root as their parent'));

Expand Down
2 changes: 1 addition & 1 deletion packages/zipkin/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare namespace zipkin {

class TraceId {
readonly traceId: string;
readonly parentId: option.IOption<string>;
readonly parentSpanId: option.IOption<string>;
readonly spanId: string;
readonly sampled: option.IOption<boolean>;

Expand Down
2 changes: 1 addition & 1 deletion packages/zipkin/src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Annotation.prototype.toString = function toString() {

function Span(traceId) {
this.traceId = traceId.traceId;
traceId._parentId.ifPresent((id) => {
traceId.parentSpanId.ifPresent((id) => {
this.parentId = id;
});
this.id = traceId.spanId;
Expand Down
2 changes: 1 addition & 1 deletion packages/zipkin/src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function appendZipkinHeaders(req, traceId) {
headers[HttpHeaders.TraceId] = traceId.traceId;
headers[HttpHeaders.SpanId] = traceId.spanId;

traceId.parentId.ifPresent(psid => {
traceId.parentSpanId.ifPresent(psid => {
headers[HttpHeaders.ParentSpanId] = psid;
});
traceId.sampled.ifPresent(sampled => {
Expand Down
18 changes: 16 additions & 2 deletions packages/zipkin/src/tracer/TraceId.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,19 @@ class TraceId {
return this._traceId;
}

get parentId() {
get parentSpanId() {
return this._parentId;
}

/**
* Please use parentSpanId instead as this can return confusing results (the span ID when absent).
*
* @deprecated since version v0.19
*/
get parentId() {
return this._parentId.getOrElse(this._spanId);
}

get spanId() {
return this._spanId;
}
Expand All @@ -54,6 +63,11 @@ class TraceId {
return this._sampled;
}

/**
* Please use isDebug instead.
*
* @deprecated since version v0.19
*/
get flags() {
return this._debug ? 1 : 0;
}
Expand All @@ -68,7 +82,7 @@ class TraceId {

toString() {
return `TraceId(spanId=${this.spanId.toString()}` +
`, parentId=${this.parentId.toString()}` +
`, parentSpanId=${this.parentSpanId.toString()}` +
`, traceId=${this.traceId.toString()})`;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/zipkin/test-types/TraceId.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('TraceId', () => {
expect(sampled.map).to.be.a('function');
expect(sampled).to.equal(option.None);

const parentId: option.IOption<string> = traceId.parentId;
const parentId: option.IOption<string> = traceId.parentSpanId;
expect(parentId.map).to.be.a('function');
});
});
2 changes: 1 addition & 1 deletion packages/zipkin/test/httpServerInstrumentation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ describe('Http Server Instrumentation', () => {
const annotations = record.args.map(args => args[0]);

annotations.forEach(ann => expect(ann.traceId.traceId).to.equal('aaa'));
annotations.forEach(ann => expect(ann.traceId.parentId.getOrElse()).to.equal('bbb'));
annotations.forEach(ann => expect(ann.traceId.parentSpanId.getOrElse()).to.equal('bbb'));
annotations.forEach(ann => expect(ann.traceId.spanId).to.not.equal('bbb'));
annotations.forEach(ann => expect(ann.traceId.isShared()).to.equal(false));

Expand Down
6 changes: 3 additions & 3 deletions packages/zipkin/test/trace.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ describe('Tracer', () => {
tracer.setId(childId);

expect(tracer.id.traceId).to.equal(parentId.traceId);
expect(tracer.id.parentId.getOrElse()).to.equal(parentId.spanId);
expect(tracer.id.parentSpanId.getOrElse()).to.equal(parentId.spanId);

ctxImpl.scoped(() => {
const grandChildId = tracer.createChildId();
tracer.setId(grandChildId);

expect(tracer.id.traceId).to.equal(childId.traceId);
expect(tracer.id.parentId.getOrElse()).to.equal(childId.spanId);
expect(tracer.id.parentSpanId.getOrElse()).to.equal(childId.spanId);
});
});
});
Expand Down Expand Up @@ -401,7 +401,7 @@ describe('Tracer', () => {

const newTraceId = tracer.join(rootTraceId);
expect(newTraceId.traceId).to.eql(rootTraceId.traceId);
expect(newTraceId.parentId).to.eql(new Some(rootTraceId.spanId));
expect(newTraceId.parentSpanId).to.eql(new Some(rootTraceId.spanId));
expect(newTraceId.sampled).to.eql(rootTraceId.sampled);
expect(newTraceId.flags).to.eql(rootTraceId.flags);
});
Expand Down

0 comments on commit 1249b2d

Please sign in to comment.