Introduction to Traceo with NodeJS

Hey guys! Traceo is a self-hosted bug tracking and performance monitoring system that can help you catch incidents and performance issues before they become major problems. With Traceo, you can easily track errors and exceptions, monitor server and app…


This content originally appeared on DEV Community and was authored by Satoru Gojo

Hey guys! Traceo is a self-hosted bug tracking and performance monitoring system that can help you catch incidents and performance issues before they become major problems. With Traceo, you can easily track errors and exceptions, monitor server and application metrics, and get insights into web vitals data.

How to start?

Due to fact that Traceo is currently not available online, you need to install your own Traceo instance on your machine. The fastest way to do this is to use docker compose. Full installation instructions can be found here.

Once the installation is complete, we can move on.

Traceo works by implementing an SDK in your application. Currently, Traceo provides SDKs for NodeJS, React, and Vue. In this article, we will focus on installing the SDK for NodeJS application.

To get started you need to install package from npm:

npm i @traceo-sdk/node

Once you have installed the SDK, you can start using it in your application. To use the SDK, you first need to initialize it with your API key generated in project created in Traceo Instance. You can do this using the following code:

new TraceoClient(<api_key>, {  
    host: "http://localhost:3000" //depend on your installation
});

Once you initialize SDK in your application, the easiest way to start tracking errors is to use ExceptionsHandlers.catchException() in try-catch clause like below:

import { ExceptionHandlers } from "@traceo-sdk/node";

try {    
//your code
} catch (error) {    
    ExceptionHandlers.catchException(error);
}

If you use NestJS then you can also create Interceptor to catch exceptions like below:

traceo.interceptor.ts

import { ExceptionHandlers } from "@traceo-sdk/node";
//other imports

@Injectable()
export class TraceoInterceptor implements NestInterceptor {
  intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
    return next.handle().pipe(
      tap(null, (exception) => {
        ExceptionHandlers.catchException(exception);
      }),
    );
  }
}

main.ts

  app.useGlobalInterceptors(new TraceoInterceptor());

And that's all. When an error occurs in your software, it will be caught by the SDK and sent to the Traceo platform. Your error will be available in the Incidents section.

What's next?

Once you have data flowing into Traceo, you can start using the platform to track incidents and performance issues. Traceo provides a dashboard where you can view and analyze your data. The dashboard provides a variety of charts and graphs that allow you to visualize trends and identify issues.

Traceo also provides detailed performance monitoring capabilities. You can track server and application metrics, such as CPU usage, memory usage, and network traffic. You can also track web vitals data, such as page load times, user interactions, and browser performance.

Conclusion

If you're looking for a self-hosted monitoring solution for your application, give Traceo a try and remember to leave a ⭐ on Github!


This content originally appeared on DEV Community and was authored by Satoru Gojo


Print Share Comment Cite Upload Translate Updates
APA

Satoru Gojo | Sciencx (2023-05-02T11:01:11+00:00) Introduction to Traceo with NodeJS. Retrieved from https://www.scien.cx/2023/05/02/introduction-to-traceo-with-nodejs/

MLA
" » Introduction to Traceo with NodeJS." Satoru Gojo | Sciencx - Tuesday May 2, 2023, https://www.scien.cx/2023/05/02/introduction-to-traceo-with-nodejs/
HARVARD
Satoru Gojo | Sciencx Tuesday May 2, 2023 » Introduction to Traceo with NodeJS., viewed ,<https://www.scien.cx/2023/05/02/introduction-to-traceo-with-nodejs/>
VANCOUVER
Satoru Gojo | Sciencx - » Introduction to Traceo with NodeJS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/05/02/introduction-to-traceo-with-nodejs/
CHICAGO
" » Introduction to Traceo with NodeJS." Satoru Gojo | Sciencx - Accessed . https://www.scien.cx/2023/05/02/introduction-to-traceo-with-nodejs/
IEEE
" » Introduction to Traceo with NodeJS." Satoru Gojo | Sciencx [Online]. Available: https://www.scien.cx/2023/05/02/introduction-to-traceo-with-nodejs/. [Accessed: ]
rf:citation
» Introduction to Traceo with NodeJS | Satoru Gojo | Sciencx | https://www.scien.cx/2023/05/02/introduction-to-traceo-with-nodejs/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.