I want to add a Sentry breadcrumb with the node ID so when an error occurs I know what path was taken. For example,
Sentry.addBreadcrumb({ nodeId, flowId })
Is there some kind of node middleware that I can add this code to? So that this code runs onStart for every node?
Hi @watadarkstar
A search on https://flows.nodered.org reveals a node that may help.
use this along with the built in catch
node?
Disclaimer : I dont use sentry
EDIT.
Oh hang on - you already using it - my bad
1 Like
Have a look at the messaging hooks api: Messaging Hooks : Node-RED
2 Likes
Yeah I'm already using that. It only shows me the last node where the error occurred. I want to see every node that was "visited" to lead up to the error so I have more context.
Thank you! That's what I was looking for, awesome!
Is this for a node your developing?
Nope but may potentially add this to that package you mentioned.
Ok, unless @knolleary can correct me?
The Hooks API is only for custom node development.
I'm using patch-package - npm to patch the sentry library .
Here is the patch for future readers:
diff --git a/node_modules/node-red-contrib-sentrynode/sentry/sentry.js b/node_modules/node-red-contrib-sentrynode/sentry/sentry.js
index cb8508f..5a1ca07 100644
--- a/node_modules/node-red-contrib-sentrynode/sentry/sentry.js
+++ b/node_modules/node-red-contrib-sentrynode/sentry/sentry.js
@@ -110,11 +110,12 @@ module.exports = function(RED) {
function SentryNode(config) {
RED.nodes.createNode(this, config);
var node = this;
+ var ENVIRONMENT = RED.util.getSetting(node, 'ENVIRONMENT')
/**
* init the sentry only on deployment
*/
- Sentry.init({ dsn: config.dsn, environment: config.environment || 'debug' });
+ Sentry.init({ dsn: config.dsn, environment: ENVIRONMENT || config.environment || 'debug' });
node.on('input', function(msg, send, done) {
@@ -157,4 +158,11 @@ module.exports = function(RED) {
});
}
RED.nodes.registerType("sentry", SentryNode);
+ RED.hooks.add("postReceive", (receiveEvent) => {
+ Sentry.addBreadcrumb({
+ category: 'node-red',
+ level: 'info',
+ message: `Message received for Node ID: ${receiveEvent.destination.id}`
+ });
+ });
}
\ No newline at end of file
Or, PR the enhancement with the developer/fork and update it
Patching nodes (I feel) shouldn't be required, and an update will benefit all users who install such node.
system
Closed
16 February 2023 21:43
13
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.