Skip to content

Commit

Permalink
Update to reflect changes to the plugin API
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicKramer committed Feb 17, 2017
1 parent b7e0995 commit 4e3ae53
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/plugins/plugin-hapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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
Expand All @@ -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;
};
Expand Down

0 comments on commit 4e3ae53

Please sign in to comment.