Skip to content

Commit 4d6e346

Browse files
committed
feat(trace): add node_red.msg.new attribute for parent span
1 parent be78c4a commit 4d6e346

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ Distributed tracing with OpenTelemetry SDK and Prometheus metrics exporter for N
2626
- optional `exception`,
2727
- optional custom attributes based on message data.
2828

29-
![Example](https://raw.githubusercontent.com/nioc/node-red-contrib-opentelemetry/master/docs/Screenshot_01.png "Example")
29+
![Example spans in JaegerUI](https://raw.githubusercontent.com/nioc/node-red-contrib-opentelemetry/master/docs/Screenshot_01.png "Example spans")
30+
31+
![Example spans to metrics in Grafana](https://raw.githubusercontent.com/nioc/node-red-contrib-opentelemetry/master/docs/Screenshot_02.png "Example spans to metrics")
3032

3133
### Metrics
3234

docs/Screenshot_02.png

273 KB
Loading

lib/opentelemetry-node.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const ATTR_FLOW_ID = 'node_red.flow.id'
2727
const ATTR_NODE_ID = 'node_red.node.id'
2828
const ATTR_NODE_TYPE = 'node_red.node.type'
2929
const ATTR_NODE_NAME = 'node_red.node.name'
30+
const ATTR_IS_MESSAGE_CREATION = 'node_red.msg.new'
3031
const ORPHAN_NODE_TYPES = ['switch', 'rbe']
3132
const fakeSpan = {
3233
end: () => {},
@@ -247,6 +248,7 @@ function createSpan (tracer, msg, nodeDefinition, node, isNotTraced) {
247248
// create the parent span
248249
parentSpan = tracer.startSpan(_rootPrefix + spanName, {
249250
attributes: {
251+
[ATTR_IS_MESSAGE_CREATION]: true,
250252
[ATTR_SERVICE_NAME]: nodeDefinition.type,
251253
...commonAttributes,
252254
},
@@ -282,6 +284,7 @@ function createSpan (tracer, msg, nodeDefinition, node, isNotTraced) {
282284
const span = tracer.startSpan(spanName, {
283285
attributes: {
284286
[ATTR_CODE_FUNCTION]: nodeDefinition.type,
287+
[ATTR_IS_MESSAGE_CREATION]: false,
285288
...commonAttributes,
286289
...localAttributes,
287290
},

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-contrib-opentelemetry",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "Distributed tracing with OpenTelemetry SDK and Prometheus metrics exporter for Node-RED",
55
"scripts": {
66
"lint": "eslint . --fix"
@@ -11,7 +11,12 @@
1111
"keywords": [
1212
"node-red",
1313
"opentelemetry",
14-
"tracing"
14+
"tracing",
15+
"profiling",
16+
"instrumentation",
17+
"stats",
18+
"metrics",
19+
"prometheus"
1520
],
1621
"author": "nioc <[email protected]>",
1722
"license": "AGPL-3.0-or-later",

0 commit comments

Comments
 (0)