Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@benawad
Created June 16, 2019 02:43
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save benawad/7abb41c179b050b476fdad4e5a561161 to your computer and use it in GitHub Desktop.
Save benawad/7abb41c179b050b476fdad4e5a561161 to your computer and use it in GitHub Desktop.
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