Cody  Osinski

Cody Osinski

1620521460

NodeSource brings C++ API to N|Solid!

NodeSource is excited to announce C++ API - Beta! 🥳 With this new API, you will be able to use all the features and power of N|Solid with your own C++ code.

In case you missed it, NodeSource also launched JS API which allows you to have all the metrics and functionality of the N|Solid console using your own JavaScript code programmatically.

The C++ API differs from our JS API because this new C++ API works at a lower level, is more performant, and it doesn’t block the event loop. Using a native C++ API will allow you to configure your code as preferred, create and pause the metrics and consume it whenever necessary, generate heap snapshots or CPU profiles and use all the N|Solid metrics with no overhead - eliminating the JavaScript level of extraction which will ultimately be faster and more performant.

In the following example, we present a simple native add-on that demonstrates the use of the C++ API. This add-on spawns a thread and from there it creates a repeating timer. In the first timer callback, it gathers the thread specific metrics from the main JS thread whereas in the second callback it takes a 5-second CPU profile. Finally the timer is closed and the thread gracefully exits. Notice the importance of running the C++ API from a non-JS thread to avoid having a performance hit.

#c++ #api

NodeSource brings C++ API to N|Solid!