newrelic 4.5.0 → 4.8.0

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.
@@ -49,30 +49,48 @@ function Trace(transaction) {
49
49
  * segments that support recording.
50
50
  */
51
51
  Trace.prototype.end = function end() {
52
+ var segments = [this.root]
53
+
54
+ while (segments.length) {
55
+ var segment = segments.pop()
56
+ _softEndSegment(segment)
57
+ Array.prototype.push.apply(segments, segment.getChildren())
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Iterates over the trace tree and generates a span event for each segment.
63
+ */
64
+ Trace.prototype.generateSpanEvents = function generateSpanEvents() {
52
65
  var config = this.transaction.agent.config
53
- var segments = []
54
- var processFn
55
66
 
56
67
  if (
57
68
  this.transaction.sampled &&
58
69
  config.span_events.enabled &&
59
- config.feature_flag.distributed_tracing
70
+ config.distributed_tracing.enabled
60
71
  ) {
72
+ var toProcess = []
61
73
  // Root segment does not become a span, so we need to process it separately.
62
- _softEndSegment(this.root)
74
+ const spanAggregator = this.transaction.agent.spans
63
75
  const children = this.root.getChildren()
64
76
  for (let i = 0; i < children.length; ++i) {
65
- segments.push(new DTTraceNode(children[i], this.transaction.parentSpanId))
77
+ toProcess.push(new DTTraceNode(children[i], this.transaction.parentSpanId))
66
78
  }
67
- processFn = makeDTNodeProcessor(this.transaction.agent.spans)
68
- } else {
69
- segments.push(this.root)
70
- processFn = processNode
71
- }
72
79
 
73
- while (segments.length) {
74
- var segment = segments.pop()
75
- processFn(segment, segments)
80
+ while (toProcess.length) {
81
+ var segmentInfo = toProcess.pop()
82
+ var segment = segmentInfo.segment
83
+
84
+ // Even though at some point we might want to stop adding events
85
+ // because all the priorities should be the same, we need to count
86
+ // the spans as seen.
87
+ spanAggregator.addSegment(segment, segmentInfo.parentId)
88
+
89
+ Array.prototype.push.apply(
90
+ toProcess,
91
+ segment.getChildren().map(child => new DTTraceNode(child, segment.id))
92
+ )
93
+ }
76
94
  }
77
95
  }
78
96
 
@@ -90,31 +108,6 @@ function _softEndSegment(segment) {
90
108
  }
91
109
  }
92
110
 
93
- function makeDTNodeProcessor(spanAggregator) {
94
- var addMoreSpans = true
95
- return function processNodeDT(segmentInfo, segments) {
96
- var segment = segmentInfo.segment
97
- _softEndSegment(segment)
98
-
99
- // This assumes that spans will have their transaction's priority. If insertion of
100
- // one event fails, all following will fail due to having the same priority.
101
- if (addMoreSpans && segment.name !== 'ROOT') {
102
- addMoreSpans = spanAggregator.addSegment(segment, segmentInfo.parentId)
103
- }
104
-
105
- var children = segment.getChildren()
106
- Array.prototype.push.apply(
107
- segments,
108
- children.map(child => new DTTraceNode(child, segment.id))
109
- )
110
- }
111
- }
112
-
113
- function processNode(segment, segments) {
114
- _softEndSegment(segment)
115
- Array.prototype.push.apply(segments, segment.getChildren())
116
- }
117
-
118
111
  /**
119
112
  * Add a child to the list of segments.
120
113
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "newrelic",
3
- "version": "4.5.0",
3
+ "version": "4.8.0",
4
4
  "author": "New Relic Node.js agent team <nodejs@newrelic.com>",
5
5
  "licenses": [
6
6
  {
@@ -96,7 +96,7 @@
96
96
  ],
97
97
  "homepage": "http://github.com/newrelic/node-newrelic",
98
98
  "engines": {
99
- "node": ">=4.0.0",
99
+ "node": ">=4.0.0 <11.0.0",
100
100
  "npm": ">=2.0.0"
101
101
  },
102
102
  "directories": {
@@ -105,6 +105,7 @@
105
105
  "scripts": {
106
106
  "bench": "node ./bin/run-bench.js",
107
107
  "versioned-tests": "./bin/run-versioned-tests.sh",
108
+ "versioned": "./bin/run-versioned-tests.sh",
108
109
  "test": "make test"
109
110
  },
110
111
  "bin": {
package/.npmignore DELETED
@@ -1,4 +0,0 @@
1
- test
2
- examples
3
- out
4
- Makefile