egg-plugin-server-timing
v0.0.2
Published
egg plugin to add 'Server-Timing' header
Downloads
29
Maintainers
Readme
egg-plugin-server-timing
A Egg Plugin for Server Timing
Usage
Install
$ npm install egg-plugin-server-timing
# or
$ yarn add egg-plugin-server-timing
Config
// config/plugin.ts
export default {
serverTiming: {
enable: true,
package: "egg-plugin-server-timing",
},
};
// config/config.default.ts
config.serverTiming = {
name: "Total", // The name of the total metric to be set.
description: "Total Response Time", // The description of the total metric to be set.
total: true, // Whether to set the total metric automatically.
enabled: true, // Whether to enable the plugin.
autoEnd: true, // Whether to set the metric automatically when the request ends.
precision: +Infinity, // Number of digits after the decimal point of the statistical time
};
Timing
ctx.serverTimer.startTime("all");
await new Promise((resolve) => setTimeout(resolve, 100));
ctx.serverTimer.endTime("all");