diff --git a/lib/trace-agent.js b/lib/trace-agent.js index d70c56e61..f90548ca8 100644 --- a/lib/trace-agent.js +++ b/lib/trace-agent.js @@ -172,7 +172,7 @@ TraceAgent.prototype.shouldTrace = function(name) { */ TraceAgent.prototype.createRootSpanData = function(name, traceId, parentId) { traceId = traceId || (uuid.v4().split('-').join('')); - parentId = parentId || 0; + parentId = parentId || '0'; var trace = new Trace(0, traceId); // project number added later var spanData = new SpanData(this, trace, name, parentId, true); cls.setRootContext(spanData); @@ -208,7 +208,7 @@ TraceAgent.prototype.parseContextFromHeader = function(str) { } return { traceId: matches[1], - spanId: Number(matches[2]), + spanId: matches[2], options: matches[3] }; }; diff --git a/test/test-trace-agent.js b/test/test-trace-agent.js index 482c6802a..f79406c9e 100644 --- a/test/test-trace-agent.js +++ b/test/test-trace-agent.js @@ -65,7 +65,7 @@ describe('Trace Agent', function() { options.headers[constants.TRACE_CONTEXT_HEADER_NAME]); assert.equal(parsed.traceId, 1); assert.equal(parsed.spanId, spanId); - assert.equal(typeof parsed.spanId, 'number'); + assert.equal(typeof parsed.spanId, 'string'); assert.equal(parsed.options, 1); }); }); @@ -92,6 +92,16 @@ describe('Trace Agent', function() { assert.equal(result.options, '1'); }); + it('should return expected values:' + + '123456/123456123456123456123456123456123456;o=1', function() { + var result = agent.parseContextFromHeader( + '123456/123456123456123456123456123456123456;o=1'); + assert(result); + assert.equal(result.traceId, '123456'); + assert.equal(result.spanId, '123456123456123456123456123456123456'); + assert.equal(result.options, '1'); + }); + it('should return expected values: 123456/667', function() { var result = agent.parseContextFromHeader( '123456/667');