Created
June 16, 2019 02:43
-
-
Save benawad/7abb41c179b050b476fdad4e5a561161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.use("/graphql", (req, res, next) => { | |
const startHrTime = process.hrtime(); | |
res.on("finish", () => { | |
if (req.body && req.body.operationName) { | |
const elapsedHrTime = process.hrtime(startHrTime); | |
const elapsedTimeInMs = | |
elapsedHrTime[0] * 1000 + elapsedHrTime[1] / 1e6; | |
logger.info({ | |
type: "timing", | |
name: req.body.operationName, | |
ms: elapsedTimeInMs | |
}); | |
} | |
}); | |
next(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment