fastify-server-timing
v1.0.3
Published
> Server-Timing API for fastify.
Downloads
48
Maintainers
Readme
fastify-server-timing
Server-Timing API for fastify.
Expose Server-Timing to communicate one or more metrics and descriptions for a given request-response cycle. It is used to surface any backend server timing metrics (e.g. database read/write, CPU time, file system access, etc.) in the developer tools in the user's browser or in the PerformanceServerTiming interface.
Installation
npm install fastify-server-timing
Usage
Register the plugin and if needed pass to it some custom options.
const fastify = require('fastify')()
// using the defaults
fastify.register(require('fastify-server-timing'))
// with custom options
fastify.register(require('fastify-server-timing'), { /* ... Options ... */ })
// use reply.addServerTiming to report a metric
fastify.get('/', (request, reply) => {
reply.addServerTiming('cache', 23.2, 'Cache Read')
return {}
})
- Options
- reply.addServerTiming(
name
: string,duration?
: undefined | number,description?
: undefined | string): void
Sponsors
Support
This project is free and open-source, so if you think this project can help you or anyone else, you may star it on GitHub. Feel free to open an issue if you have any idea, question, or you've found a bug.
Contribute
Thanks for being willing to contribute!
Working on your first Pull Request? You can learn how from this free series How to Contribute to an Open Source Project on GitHub
We are following the Conventional Commits convention.
Develop
npm test
: Run test suitenpm run build
: Generate bundlesnpm run lint
: Lints code
NPM Statistics
License
fastify-server-timing
is open source software licensed as MIT.