Simplify Error Reporting with Sentry Tracing Decorator in Node.js
The article introduces a Typescript package called sentry-traced
that provides a decorator to annotate class methods with Sentry tracing information. This package aims to simplify the process of adding Sentry error reporting to a Node.js application by automating the generation of Sentry tracing information for class methods.
To use the sentry-traced
decorator, developers need to import it into their project and annotate the desired class methods with the @SentryTraced
decorator. This will automatically generate and send the Sentry tracing information to Sentry whenever the annotated methods are called.
The article also mentions the usage of nested methods and how the sentry-traced
package handles them by generating a tree-like structure of spans in the call stack. Additionally, developers can use the @SentryParam()
decorator to add named parameters to the Sentry transaction.
For those interested in distributed tracing, the sentry-traced
package provides the withTracing
function, which enables following and analyzing the path of requests as they move through various components or services.