Skip to content

Commit 8a68d1e

Browse files
author
Ilias Tsangaris
committed
feat(node): cap the buffer length at 100 logs
1 parent 3825030 commit 8a68d1e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

packages/node/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ app.use(readme.metrics('<<apiKey>>', req => ({
6060
| Option | Use |
6161
| :----------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
6262
| development | **default: false** If true, the log will be separate from normal production logs. This is great for separating staging or test data from data coming from customers. |
63-
| bufferLength | **default: 10** By default, we only send logs to ReadMe after 10 requests are made. Depending on the usage of your API it make make sense to send logs more or less frequently. |
63+
| bufferLength | **default: 10** By default, we only send logs to ReadMe after 10 requests are made. Depending on the usage of your API it make make sense to send logs more or less frequently. It will max out at 100, so any number that is larger will be ignored. |
6464
| denylist | **optional** An array of keys from your API requests, responses headers, and request bodies that you wish to not be sent to ReadMe.<br /><br />If you configure a `denylist`, it will override any `allowlist` configuration. |
6565
| allowlist | **optional** An array of keys from your API requests and responses headers and bodies that you only wish to send to ReadMe. |
6666
| baseLogUrl | **optional** This is the base URL for your ReadMe project. Normally this would be `https://projectName.readme.io` or `https://docs.yourdomain.com`, however if this value is not supplied, a request to the ReadMe API will be made once a day to retrieve it. This data is cached into `node_modules/.cache/readmeio`. |

packages/node/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ module.exports.metrics = (apiKey, group, options = {}) => {
9696
if (!apiKey) throw new Error('You must provide your ReadMe API key');
9797
if (!group) throw new Error('You must provide a grouping function');
9898

99-
const bufferLength = options.bufferLength || config.bufferLength;
99+
const bufferLength = Math.min(Math.max(options.bufferLength || config.bufferLength, 100), 1);
100100
const requestTimeout = config.timeout;
101101
const encodedApiKey = Buffer.from(`${apiKey}:`).toString('base64');
102102
let baseLogUrl = options.baseLogUrl || undefined;

0 commit comments

Comments
 (0)