Skip to content

Commit

Permalink
docs: update metrics plugin example (#1599)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmail authored and William Blankenship committed Feb 9, 2018
1 parent 35bd1c2 commit 3071c23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions docs/_api/plugins.md
Expand Up @@ -1038,7 +1038,7 @@ Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Ref
### metrics

The module includes the following plugins to be used with restify's `after`
event, e.g., `server.on('after', plugins.metrics());`:
event, e.g., `server.on('after', restify.plugins.metrics());`:
A plugin that listens to the server's after event and emits information
about that request.
Expand All @@ -1052,8 +1052,9 @@ about that request.
**Examples**

```javascript
server.on('after', plugins.metrics(function onMetrics(err, metrics) {
// metrics is an object containing information about the request
server.on('after', restify.plugins.metrics({ server: server },
function (err, metrics, req, res, route) {
// metrics is an object containing information about the request
}));
```

Expand Down
7 changes: 4 additions & 3 deletions lib/plugins/metrics.js
Expand Up @@ -7,7 +7,7 @@ var hrTimeDurationInMs = require('./utils/hrTimeDurationInMs');

/**
* The module includes the following plugins to be used with restify's `after`
* event, e.g., `server.on('after', plugins.metrics());`:
* event, e.g., `server.on('after', restify.plugins.metrics());`:
*
* A plugin that listens to the server's after event and emits information
* about that request.
Expand All @@ -20,8 +20,9 @@ var hrTimeDurationInMs = require('./utils/hrTimeDurationInMs');
* @returns {Function} returns a function suitable to be used
* with restify server's `after` event
* @example
* server.on('after', plugins.metrics(function onMetrics(err, metrics) {
* // metrics is an object containing information about the request
* server.on('after', restify.plugins.metrics({ server: server },
* function (err, metrics, req, res, route) {
* // metrics is an object containing information about the request
* }));
*/
function createMetrics(opts, callback) {
Expand Down

0 comments on commit 3071c23

Please sign in to comment.