@bugrecorder/sdk
v1.1.39
Published
A lightweight package for monitoring server-side performance metrics and catching errors.
Maintainers
Keywords
Readme
@bugrecorder/sdk
A lightweight package for monitoring server-side performance metrics and catching errors.
LIMITATION
Please note that this package will work on your self hosted App (Node.js, Bun, Next.js, Deno on a VPS) means it will not work on any serverless platform Like (Vercel, AWS Lambda, Netlify, etc.).
Features
- Server-side error catching and reporting
- Real-time performance metrics monitoring (Specifickly to your Application server not whole server)
- CPU usage tracking (percentage%)
- Memory usage monitoring (Application Server usage)
- Network metrics (how much network sent/recived from your Application server)
- File Read and Write (how much megabyte read/write by your Application)
Installation
npm i @bugrecorder/sdk --save
This package can be used in :
- Node.js
- Next.js
- Bun
- Deno
"npm:@bugrecorder/sdk"
First, initialize the SDK with your API key and domain:
client.init({
apiKey: "1234567890",
domain: "test.bugrecorder.com"
});Track CPU, MEMORY, FILE (read/write), Network metrics
This will send the metric to the dashboard automatickly
client.monitor({
serverName: "server_dev_1",
onData: (data) => {
console.log("data from monitor", data);
},
onError: (error) => {
console.log("error from monitor", error);
}
});Send Server Side Errors
client.sendError({
domain: "test.bugrecorder.com",
message: "test",
stack: "test",
context: "test"
});Notes:
for the File System metrics (disk_read,disk_write): it needs to be any Linux system to get the vales for mac or windows you will get disk_read:0 and disk_read:0
if you are using pm2 with cluster ( exec_mode: 'cluster', // enables load balancing), in order to track each instance it needs to have a seprate name so add instance_var: 'INSTANCE_ID' either into ecosystem.config.js file or cli
client.monitor({
serverName: `server-${
isNotEmpty(process.env.INSTANCE_ID) ? process.env.INSTANCE_ID : 'dev'
}`})this way you will have server-0 server-1 server-1 ....
Server Side Logging
You can use the logger to send logs to the dashboard. The logs will be stored and searchable in the dashboard.
import { logger } from '@bugrecorder/sdk';
logger.error(args);
logger.info(args);
logger.warning(args);
logger.debug(args);
logger.fatal(args);
logger.success(args);
logger.test(args);
logger.console(args);
Support
if you have any issue, or need support contact us at dev @ bugrecorder.com (remove space it was added to prevent spam)
