new Promise(done => setTimeout(() => { tracer.letId(request._trace_id, () => { addTag(tracer, request, 'city', 'shenzhen'); done(); }); }, 10)).then(() => responseCallback({}))
// As long as we call this on afterEach, and tests are executed sequentially. // we can reuse this tracer for any number of tests expectNoLeaks() { expect(this._tracer.id).to.equal(this._sentinelTraceId); // no context leaks expect(this._spans).to.be.empty; // eslint-disable-line no-unused-expressions }
describe('Tracer', () => { it('should have correct type', () => { const recorder = { record: () => {} }; const ctxImpl = new ExplicitContext(); const tracer: Tracer = new Tracer({ctxImpl, recorder}); expect(tracer.recordRpc).to.be.a('function'); }); });
const triggerPublish = (logger) => { const ctxImpl = new ExplicitContext(); const recorder = new BatchRecorder({logger}); const tracer = new Tracer({recorder, ctxImpl}); ctxImpl.scoped(() => { tracer.recordAnnotation(new Annotation.ServerRecv()); tracer.recordServiceName('my-service'); tracer.recordRpc('GET'); tracer.recordBinary('http.url', 'http://example.com'); tracer.recordBinary('http.response_code', '200'); tracer.recordAnnotation(new Annotation.ServerSend()); }); }
runInDebugTrace(callback) { return this._tracer.letId(this._debugId, callback); }
const makeTraceId = () => tracer.createRootId()
const triggerLargePublish = (logger) => { const ctxImpl = new ExplicitContext(); const recorder = new BatchRecorder({logger}); const tracer = new Tracer({recorder, ctxImpl}); ctxImpl.scoped(() => { tracer.recordAnnotation(new Annotation.ServerRecv()); tracer.recordServiceName('my-service'); tracer.recordRpc('GET'); tracer.recordBinary('http.url', 'http://example.com'); tracer.recordBinary('http.response_code', '200'); for (let i = 0; i < 5000; i += 1) { tracer.recordAnnotation(new Annotation.Message(`Message ${i + 1}`)); } tracer.recordAnnotation(new Annotation.ServerSend()); }); }
describe('Tracer', () => { it('should have correct type', () => { const recorder = { record: () => {} }; const ctxImpl = new ExplicitContext(); const tracer: Tracer = new Tracer({ctxImpl, recorder}); expect(tracer.recordRpc).to.be.a('function'); }); });
const triggerPublish = (logger) => { const ctxImpl = new ExplicitContext(); const recorder = new BatchRecorder({logger}); const tracer = new Tracer({recorder, ctxImpl}); ctxImpl.scoped(() => { tracer.recordAnnotation(new Annotation.ServerRecv()); tracer.recordServiceName('my-service'); tracer.recordRpc('GET'); tracer.recordBinary('http.url', 'http://example.com'); tracer.recordBinary('http.response_code', '200'); tracer.recordAnnotation(new Annotation.ServerSend()); }); }
const triggerPublish = (logger) => { const ctxImpl = new ExplicitContext(); const recorder = new BatchRecorder({logger}); const tracer = new Tracer({recorder, ctxImpl}); ctxImpl.scoped(() => { tracer.recordAnnotation(new Annotation.ServerRecv()); tracer.recordServiceName('my-service'); tracer.recordRpc('GET'); tracer.recordBinary('http.url', 'http://example.com'); tracer.recordBinary('http.response_code', '200'); tracer.recordAnnotation(new Annotation.ServerSend()); }); }
const triggerPublish = (logger) => { const ctxImpl = new ExplicitContext(); const recorder = new BatchRecorder({logger}); const tracer = new Tracer({recorder, ctxImpl}); ctxImpl.scoped(() => { tracer.recordAnnotation(new Annotation.ServerRecv()); tracer.recordServiceName('my-service'); tracer.recordRpc('GET'); tracer.recordBinary('http.url', 'http://example.com'); tracer.recordBinary('http.response_code', '200'); tracer.recordAnnotation(new Annotation.ServerSend()); }); }
const triggerLargePublish = (logger) => { const ctxImpl = new ExplicitContext(); const recorder = new BatchRecorder({logger}); const tracer = new Tracer({recorder, ctxImpl}); ctxImpl.scoped(() => { tracer.recordAnnotation(new Annotation.ServerRecv()); tracer.recordServiceName('my-service'); tracer.recordRpc('GET'); tracer.recordBinary('http.url', 'http://example.com'); tracer.recordBinary('http.response_code', '200'); for (let i = 0; i < 5000; i += 1) { tracer.recordAnnotation(new Annotation.Message(`Message ${i + 1}`)); } tracer.recordAnnotation(new Annotation.ServerSend()); }); }
const triggerLargePublish = (logger) => { const ctxImpl = new ExplicitContext(); const recorder = new BatchRecorder({logger}); const tracer = new Tracer({recorder, ctxImpl}); ctxImpl.scoped(() => { tracer.recordAnnotation(new Annotation.ServerRecv()); tracer.recordServiceName('my-service'); tracer.recordRpc('GET'); tracer.recordBinary('http.url', 'http://example.com'); tracer.recordBinary('http.response_code', '200'); for (let i = 0; i < 20; i += 1) { tracer.recordAnnotation(new Annotation.Message(`Message ${i + 1}`)); } tracer.recordAnnotation(new Annotation.ServerSend()); }); }
const triggerLargePublish = (logger) => { const ctxImpl = new ExplicitContext(); const recorder = new BatchRecorder({logger}); const tracer = new Tracer({recorder, ctxImpl}); ctxImpl.scoped(() => { tracer.recordAnnotation(new Annotation.ServerRecv()); tracer.recordServiceName('my-service'); tracer.recordRpc('GET'); tracer.recordBinary('http.url', 'http://example.com'); tracer.recordBinary('http.response_code', '200'); for (let i = 0; i < 20; i += 1) { tracer.recordAnnotation(new Annotation.Message(`Message ${i + 1}`)); } tracer.recordAnnotation(new Annotation.ServerSend()); }); }
const makeTraceId = () => tracer.createRootId()