beforeEach(function () { agent = helper.loadMockedAgent(); tracer = agent.errors; var transaction = new Transaction(agent); transaction.setWeb('/test-request/zxrkbl', 'WebTransaction/Uri/test-request/zxrkbl', 503); transaction.end(); error = tracer.errors[0]; });
beforeEach(function () { agent = helper.loadMockedAgent(); tracer = agent.errors; var transaction = new Transaction(agent) , exception = new Error('500 test error') ; transaction.exceptions.push(exception); transaction.setWeb('/test-request/zxrkbl', 'WebTransaction/Uri/test-request/zxrkbl', 500); transaction.end(); error = tracer.errors[0]; });
it("reports the error count", function () { agent.metrics.started = 1337; var transaction = new Transaction(agent); transaction.setWeb('/test', 'WebTransaction/Uri/test', 501); agent.errors.add(transaction, new TypeError('no method last on undefined')); agent.errors.add(transaction, new Error('application code error')); agent.errors.add(transaction, new RangeError('stack depth exceeded')); transaction.end(); var metrics = new Metrics(0.5); metrics.started = 1337; metrics.getOrCreateMetric('Errors/all').incrementCallCount(4); mock.expects('sendMetricData').once().withArgs(metrics); mock.expects('sendTracedErrors').once(); mock.expects('sendTransactionTraces').once(); agent.harvest(); });
function (done) { var DURATION = 33; var URL = '/test?test=value'; var transaction = new Transaction(agent); transaction.setWeb(URL, 'WebTransaction/Uri' + URL, 200); var trace = transaction.getTrace(); var start = trace.root.timer.start; expect(start, "root segment's start time").above(0); trace.setDurationInMillis(DURATION, 0); var web = trace.root.add(webUtils.scrubURL(URL)); webUtils.normalizeAndName(web, URL, 200); // top-level element will share a duration with the quasi-ROOT node web.setDurationInMillis(DURATION, 0); var db = web.add('DB/select/getSome'); db.setDurationInMillis(14, 3); var memcache = web.add('Memcache/lookup/user/13'); memcache.setDurationInMillis(20, 8); /* * Segment data repeats the outermost data, nested, with the scope for the * outermost version having its scope always set to "ROOT". The null bits * are parameters, which are optional, and so far, unimplemented for Node. */ var rootSegment = [ 0, DURATION, 'ROOT', {nr_async_wait : true}, [ [ 0, DURATION, 'WebTransaction/Uri/test', {nr_async_wait : true, test : 'value'}, [ // TODO: ensure that the ordering is correct WRT start time db.toJSON(), memcache.toJSON() ] ] ] ]; var rootNode = [ trace.root.timer.start / 1000, {test : "value"}, {}, // FIXME: custom parameters rootSegment, [] // FIXME: parameter groups ]; codec.encode(rootNode, function (err, encoded) { if (err) return done(err); // See docs on Transaction.generateJSON for what goes in which field. var expected = [ 0, DURATION, 'WebTransaction/Uri/test', // scope '/test', // URI path encoded, // compressed segment / segment data '', // FIXME: depends on RUM token in session null, // reserved, always NULL false // FIXME: RUM2 session persistence, not // worrying about it for now ]; transaction.getTrace().generateJSON(function (err, traceJSON) { if (err) return done(err); codec.decode(traceJSON[4], function (derr, reconstituted) { if (derr) return done(derr); expect(reconstituted, "reconstituted trace segments").deep.equal(rootNode); expect(traceJSON, "full trace JSON").deep.equal(expected); helper.unloadAgent(agent); return done(); }); }); }); });