Skip to content

Commit

Permalink
[pinpoint-apm#86] trace guard
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed Sep 12, 2023
1 parent a88bfe8 commit 035399b
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/instrumentation/module/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,23 @@ module.exports = function (agent, version, express) {
} else {
handle = function (err, req, res, next) {
const trace = agent.traceContext.currentTraceObject()
let spanEventRecorder = null
if (shouldReport(err, trace)) {

spanEventRecorder = trace.traceBlockBegin()
spanEventRecorder.recordServiceType(ServiceTypeCode.express)
spanEventRecorder.recordException(err, true)
const methodDescriptor = getMethodDescriptor(objectName, layerName, req.method)
if (methodDescriptor) {
spanEventRecorder.recordApi(getMethodDescriptor(objectName, layerName, req.method))
} else {
spanEventRecorder.recordApiDesc(getDescriptionText(objectName, layerName, req.method))
}
}
return origin.apply(this, arguments)
const result = origin.apply(this, arguments)
if (trace) {
trace.traceBlockEnd(spanEventRecorder)
}
return result
}
}

Expand Down

0 comments on commit 035399b

Please sign in to comment.