diff --git a/src/plugins/plugin-hapi.js b/src/plugins/plugin-hapi.js index 8e79e8cc0..1fe5e272c 100644 --- a/src/plugins/plugin-hapi.js +++ b/src/plugins/plugin-hapi.js @@ -37,8 +37,8 @@ function middleware(api, request, reply) { traceContext: req.headers[api.constants.TRACE_CONTEXT_HEADER_NAME], skipFrames: 3 }; - api.runInRootSpan(options, function(transaction) { - if (!transaction) { + api.runInRootSpan(options, function(root) { + if (!root) { return reply.continue(); } @@ -51,11 +51,11 @@ function middleware(api, request, reply) { // we use the path part of the url as the span name and add the full // url as a label // req.path would be more desirable but is not set at the time our middlewear runs. - transaction.addLabel(api.labels.HTTP_METHOD_LABEL_KEY, req.method); - transaction.addLabel(api.labels.HTTP_URL_LABEL_KEY, url); - transaction.addLabel(api.labels.HTTP_SOURCE_IP, req.connection.remoteAddress); + root.addLabel(api.labels.HTTP_METHOD_LABEL_KEY, req.method); + root.addLabel(api.labels.HTTP_URL_LABEL_KEY, url); + root.addLabel(api.labels.HTTP_SOURCE_IP, req.connection.remoteAddress); - var context = transaction.getTraceContext(); + var context = root.getTraceContext(); res.setHeader(api.constants.TRACE_CONTEXT_HEADER_NAME, context); // wrap end @@ -64,12 +64,12 @@ function middleware(api, request, reply) { var returned = res.end(chunk, encoding); if (req.route && req.route.path) { - transaction.addLabel( + root.addLabel( 'hapi/request.route.path', req.route.path); } - transaction.addLabel( + root.addLabel( api.labels.HTTP_RESPONSE_CODE_LABEL_KEY, res.statusCode); - transaction.endSpan(); + root.endSpan(); return returned; };