netra-sdk 1.11.0 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -40,6 +40,27 @@ await Netra.init({
40
40
 
41
41
  > **Note**: Always `await` the `init()` call to ensure all instrumentations (like OpenAI, Anthropic, LangGraph) are fully patched before your application starts using them. This is especially important in frameworks like NestJS where modules are loaded after initialization.
42
42
 
43
+ #### Shutdown
44
+
45
+ By default, `init()` flushes pending spans (for up to 5 seconds) when the process receives `SIGINT`/`SIGTERM`, crashes, or exits naturally. If your app handles these events itself, it stays in control; otherwise Node's default behaviour applies after the flush. To manage shutdown yourself, opt out and call `Netra.shutdown()`:
46
+
47
+ ```typescript
48
+ await Netra.init({ appName: "my-ai-app", registerShutdownHooks: false });
49
+
50
+ process.on("SIGTERM", async () => {
51
+ await new Promise((resolve) => server.close(resolve));
52
+ await Netra.shutdown(); // flush pending spans
53
+ process.exit(0);
54
+ });
55
+ ```
56
+
57
+ `Netra.shutdown()` is safe to call more than once or from several places at the same time.
58
+
59
+ > **Notes**
60
+ > - If your app has its own `uncaughtException` handler, the SDK leaves crashes to it and does not flush; call `Netra.shutdown()` there before exiting.
61
+ > - If a library keeps a permanent signal listener (e.g. via `signal-exit`), `SIGTERM` may not stop the process. Use `registerShutdownHooks: false` and call `Netra.shutdown()` yourself.
62
+ > - With `registerShutdownHooks: false`, a running simulation still listens for these events briefly so an interrupted run is marked `failed`.
63
+
43
64
  ## 🎯 Decorators
44
65
 
45
66
  Use decorators to automatically trace your functions and classes.