dd-trace 4.13.0 → 4.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "4.13.0",
3
+ "version": "4.13.1",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -15,15 +15,14 @@ const consumerStartCh = channel('apm:kafkajs:consume:start')
15
15
  const consumerFinishCh = channel('apm:kafkajs:consume:finish')
16
16
  const consumerErrorCh = channel('apm:kafkajs:consume:error')
17
17
 
18
- addHook({ name: 'kafkajs', versions: ['>=1.4'] }, (obj) => {
19
- class Kafka extends obj.Kafka {
18
+ addHook({ name: 'kafkajs', file: 'src/index.js', versions: ['>=1.4'] }, (BaseKafka) => {
19
+ class Kafka extends BaseKafka {
20
20
  constructor (options) {
21
21
  super(options)
22
22
  this._brokers = (options.brokers && typeof options.brokers !== 'function')
23
23
  ? options.brokers.join(',') : undefined
24
24
  }
25
25
  }
26
- obj.Kafka = Kafka
27
26
 
28
27
  shimmer.wrap(Kafka.prototype, 'producer', createProducer => function () {
29
28
  const producer = createProducer.apply(this, arguments)
@@ -117,5 +116,5 @@ addHook({ name: 'kafkajs', versions: ['>=1.4'] }, (obj) => {
117
116
  }
118
117
  return consumer
119
118
  })
120
- return obj
119
+ return Kafka
121
120
  })
@@ -36,10 +36,14 @@ class MongodbCorePlugin extends DatabasePlugin {
36
36
  }
37
37
  }
38
38
 
39
+ function sanitizeBigInt (data) {
40
+ return JSON.stringify(data, (_key, value) => typeof value === 'bigint' ? value.toString() : value)
41
+ }
42
+
39
43
  function getQuery (cmd) {
40
44
  if (!cmd || typeof cmd !== 'object' || Array.isArray(cmd)) return
41
- if (cmd.query) return JSON.stringify(limitDepth(cmd.query))
42
- if (cmd.filter) return JSON.stringify(limitDepth(cmd.filter))
45
+ if (cmd.query) return sanitizeBigInt(limitDepth(cmd.query))
46
+ if (cmd.filter) return sanitizeBigInt(limitDepth(cmd.filter))
43
47
  }
44
48
 
45
49
  function getResource (plugin, ns, query, operationName) {
@@ -76,7 +76,18 @@ class SensitiveHandler {
76
76
  while (nextSensitive != null && contains(nextTainted, nextSensitive)) {
77
77
  const redactionStart = nextSensitive.start - nextTainted.start
78
78
  const redactionEnd = nextSensitive.end - nextTainted.start
79
- this.redactSource(sources, redactedSources, redactedSourcesContext, sourceIndex, redactionStart, redactionEnd)
79
+ if (redactionStart === redactionEnd) {
80
+ this.writeRedactedValuePart(valueParts, 0)
81
+ } else {
82
+ this.redactSource(
83
+ sources,
84
+ redactedSources,
85
+ redactedSourcesContext,
86
+ sourceIndex,
87
+ redactionStart,
88
+ redactionEnd
89
+ )
90
+ }
80
91
  nextSensitive = sensitive.shift()
81
92
  }
82
93
 
@@ -15,6 +15,7 @@ const FILE_URI_START = `file://`
15
15
  const moduleLoadStartChannel = dc.channel('dd-trace:moduleLoadStart')
16
16
 
17
17
  let immediate, config, application, host
18
+ let isFirstModule = true
18
19
 
19
20
  function waitAndSend (config, application, host) {
20
21
  if (!immediate) {
@@ -36,7 +37,21 @@ function waitAndSend (config, application, host) {
36
37
  }
37
38
  }
38
39
 
40
+ function loadAllTheLoadedModules () {
41
+ if (require.cache) {
42
+ const filenames = Object.keys(require.cache)
43
+ filenames.forEach(filename => {
44
+ onModuleLoad({ filename })
45
+ })
46
+ }
47
+ }
48
+
39
49
  function onModuleLoad (data) {
50
+ if (isFirstModule) {
51
+ isFirstModule = false
52
+ loadAllTheLoadedModules()
53
+ }
54
+
40
55
  if (data) {
41
56
  let filename = data.filename
42
57
  if (filename && filename.startsWith(FILE_URI_START)) {
@@ -17,6 +17,7 @@ let pluginManager
17
17
  let application
18
18
  let host
19
19
  let interval
20
+ let heartbeatTimeout
20
21
  let heartbeatInterval
21
22
  const sentIntegrations = new Set()
22
23
 
@@ -110,6 +111,14 @@ function getTelemetryData () {
110
111
  return { config, application, host, heartbeatInterval }
111
112
  }
112
113
 
114
+ function heartbeat (config, application, host) {
115
+ heartbeatTimeout = setTimeout(() => {
116
+ sendData(config, application, host, 'app-heartbeat')
117
+ heartbeat(config, application, host)
118
+ }, heartbeatInterval).unref()
119
+ return heartbeatTimeout
120
+ }
121
+
113
122
  function start (aConfig, thePluginManager) {
114
123
  if (!aConfig.telemetry.enabled) {
115
124
  return
@@ -122,9 +131,9 @@ function start (aConfig, thePluginManager) {
122
131
 
123
132
  dependencies.start(config, application, host)
124
133
  sendData(config, application, host, 'app-started', appStarted())
134
+ heartbeat(config, application, host)
125
135
  interval = setInterval(() => {
126
136
  metricsManager.send(config, application, host)
127
- sendData(config, application, host, 'app-heartbeat')
128
137
  }, heartbeatInterval)
129
138
  interval.unref()
130
139
  process.on('beforeExit', onBeforeExit)
@@ -137,6 +146,7 @@ function stop () {
137
146
  return
138
147
  }
139
148
  clearInterval(interval)
149
+ clearTimeout(heartbeatTimeout)
140
150
  process.removeListener('beforeExit', onBeforeExit)
141
151
 
142
152
  telemetryStopChannel.publish(getTelemetryData())