server.ext('onPreResponse', (request, h) => { const traceId = request._trace_id; if (!traceId) return h.continue; // TODO: make a realistic test that could skip this tracer.setId(sentinelTraceId); // stop any scope const {response} = request; const statusCode = response.isBoom ? response.output.statusCode : response.statusCode; tracer.scoped(() => instrumentation.recordResponse(traceId, statusCode)); return h.continue; });
tracer.scoped(() => { const method = ctx.request.method.toUpperCase(); const id = instrumentation.recordRequest(method, ctx.request.href, readHeader); Object.defineProperty(ctx.request, '_trace_id', {configurable: false, get: () => id}); const recordResponse = () => { tracer.letId(id, () => { // support koa-route and koa-router const matchedPath = ctx.routePath || ctx._matchedRoute; tracer.recordRpc(instrumentation.spanNameFromRoute(method, matchedPath, ctx.status)); instrumentation.recordResponse(id, ctx.status); }); }; return next() .then(recordResponse) .catch(recordResponse); })
tracer.scoped(() => { const id = instrumentation.recordRequest(req.method, formatRequestUrl(req), readHeader); Object.defineProperty(req, '_trace_id', {configurable: false, get: () => id}); /** * records response on finish or close (whichever happens first) * @listens close * @listens finish */ const onCloseOrFinish = () => { res.removeListener('close', onCloseOrFinish); res.removeListener('finish', onCloseOrFinish); tracer.scoped(() => instrumentation.recordResponse(id, res.statusCode)); }; res.once('close', onCloseOrFinish); res.once('finish', onCloseOrFinish); next(); });
tracer.scoped(() => { const id = instrumentation.recordRequest(req.method, formatRequestUrl(req), readHeader); Object.defineProperty(req, '_trace_id', {configurable: false, get: () => id}); /** * records response on finish or close (whichever happens first) * @listens close * @listens finish */ const onCloseOrFinish = () => { res.removeListener('close', onCloseOrFinish); res.removeListener('finish', onCloseOrFinish); tracer.letId(id, () => { // if route is terminated on middleware req.route won't be available const route = req.route && req.route.path; tracer.recordRpc(instrumentation.spanNameFromRoute(req.method, route, res.statusCode)); instrumentation.recordResponse(id, res.statusCode); }); }; res.once('close', onCloseOrFinish); res.once('finish', onCloseOrFinish); next(); });
server.ext('onPreResponse', (request, h) => { const traceId = request._trace_id; if (!traceId) return h.continue; // TODO: make a realistic test that could skip this tracer.setId(sentinelTraceId); // stop any scope const {response} = request; const statusCode = response.isBoom ? response.output.statusCode : response.statusCode; tracer.scoped(() => instrumentation.recordResponse(traceId, statusCode)); return h.continue; });
tracer.scoped(() => { const id = instrumentation.recordRequest(req.method, formatRequestUrl(req), readHeader); Object.defineProperty(req, '_trace_id', {configurable: false, get: () => id}); /** * records response on finish or close (whichever happens first) * @listens close * @listens finish */ const onCloseOrFinish = () => { res.removeListener('close', onCloseOrFinish); res.removeListener('finish', onCloseOrFinish); tracer.scoped(() => instrumentation.recordResponse(id, res.statusCode)); }; res.once('close', onCloseOrFinish); res.once('finish', onCloseOrFinish); next(); });
tracer.scoped(() => { const method = ctx.request.method.toUpperCase(); const id = instrumentation.recordRequest(method, ctx.request.href, readHeader); Object.defineProperty(ctx.request, '_trace_id', {configurable: false, get: () => id}); const recordResponse = () => { tracer.letId(id, () => { // support koa-route and koa-router const matchedPath = ctx.routePath || ctx._matchedRoute; tracer.recordRpc(instrumentation.spanNameFromRoute(method, matchedPath, ctx.status)); instrumentation.recordResponse(id, ctx.status); }); }; return next() .then(recordResponse) .catch(recordResponse); })
tracer.scoped(() => { const id = instrumentation.recordRequest(req.method, formatRequestUrl(req), readHeader); Object.defineProperty(req, '_trace_id', {configurable: false, get: () => id}); /** * records response on finish or close (whichever happens first) * @listens close * @listens finish */ const onCloseOrFinish = () => { res.removeListener('close', onCloseOrFinish); res.removeListener('finish', onCloseOrFinish); tracer.scoped(() => instrumentation.recordResponse(id, res.statusCode)); }; res.once('close', onCloseOrFinish); res.once('finish', onCloseOrFinish); next(); });
tracer.scoped(() => { const id = instrumentation.recordRequest(req.method, formatRequestUrl(req), readHeader); Object.defineProperty(req, '_trace_id', {configurable: false, get: () => id}); /** * records response on finish or close (whichever happens first) * @listens close * @listens finish */ const onCloseOrFinish = () => { res.removeListener('close', onCloseOrFinish); res.removeListener('finish', onCloseOrFinish); tracer.scoped(() => instrumentation.recordResponse(id, res.statusCode)); }; res.once('close', onCloseOrFinish); res.once('finish', onCloseOrFinish); next(); });
tracer.scoped(() => { const id = instrumentation.recordRequest(req.method, formatRequestUrl(req), readHeader); Object.defineProperty(req, '_trace_id', {configurable: false, get: () => id}); /** * records response on finish or close (whichever happens first) * @listens close * @listens finish */ const onCloseOrFinish = () => { res.removeListener('close', onCloseOrFinish); res.removeListener('finish', onCloseOrFinish); tracer.letId(id, () => { // if route is terminated on middleware req.route won't be available const route = req.route && req.route.path; tracer.recordRpc(instrumentation.spanNameFromRoute(req.method, route, res.statusCode)); instrumentation.recordResponse(id, res.statusCode); }); }; res.once('close', onCloseOrFinish); res.once('finish', onCloseOrFinish); next(); });
tracer.scoped(function () { var id = instrumentation.recordRequest(req.method, formatRequestUrl(req), readHeader); Object.defineProperty(req, '_trace_id', { configurable: false, get: function get() { return id; } }); /** * records response on finish or close (whichever happens first) * @listens close * @listens finish */ var onCloseOrFinish = function onCloseOrFinish() { res.removeListener('close', onCloseOrFinish); res.removeListener('finish', onCloseOrFinish); tracer.scoped(function () { return instrumentation.recordResponse(id, res.statusCode); }); }; res.once('close', onCloseOrFinish); res.once('finish', onCloseOrFinish); next(); });
tracer.scoped(function () { var id = instrumentation.recordRequest(req.method, formatRequestUrl(req), readHeader); Object.defineProperty(req, '_trace_id', { configurable: false, get: function get() { return id; } }); /** * records response on finish or close (whichever happens first) * @listens close * @listens finish */ var onCloseOrFinish = function onCloseOrFinish() { res.removeListener('close', onCloseOrFinish); res.removeListener('finish', onCloseOrFinish); tracer.scoped(function () { return instrumentation.recordResponse(id, res.statusCode); }); }; res.once('close', onCloseOrFinish); res.once('finish', onCloseOrFinish); next(); });