dd-trace 4.18.0 → 4.23.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.
- package/LICENSE-3rdparty.csv +3 -2
- package/README.md +3 -3
- package/ext/kinds.d.ts +1 -0
- package/ext/kinds.js +2 -1
- package/ext/tags.d.ts +2 -1
- package/ext/tags.js +6 -1
- package/index.d.ts +29 -0
- package/package.json +12 -11
- package/packages/datadog-core/src/storage/async_resource.js +1 -1
- package/packages/datadog-esbuild/index.js +1 -20
- package/packages/datadog-instrumentations/src/aerospike.js +47 -0
- package/packages/datadog-instrumentations/src/apollo-server-core.js +41 -0
- package/packages/datadog-instrumentations/src/apollo-server.js +83 -0
- package/packages/datadog-instrumentations/src/child-process.js +4 -5
- package/packages/datadog-instrumentations/src/couchbase.js +5 -4
- package/packages/datadog-instrumentations/src/crypto.js +2 -1
- package/packages/datadog-instrumentations/src/dns.js +2 -1
- package/packages/datadog-instrumentations/src/graphql.js +18 -4
- package/packages/datadog-instrumentations/src/helpers/bundler-register.js +1 -2
- package/packages/datadog-instrumentations/src/helpers/hooks.js +10 -2
- package/packages/datadog-instrumentations/src/helpers/instrument.js +9 -4
- package/packages/datadog-instrumentations/src/helpers/register.js +19 -3
- package/packages/datadog-instrumentations/src/http/client.js +12 -2
- package/packages/datadog-instrumentations/src/http/server.js +7 -4
- package/packages/datadog-instrumentations/src/http2/client.js +3 -1
- package/packages/datadog-instrumentations/src/http2/server.js +3 -1
- package/packages/datadog-instrumentations/src/jest.js +12 -6
- package/packages/datadog-instrumentations/src/kafkajs.js +27 -0
- package/packages/datadog-instrumentations/src/net.js +10 -2
- package/packages/datadog-instrumentations/src/next.js +18 -6
- package/packages/datadog-instrumentations/src/restify.js +14 -1
- package/packages/datadog-instrumentations/src/rhea.js +15 -9
- package/packages/datadog-plugin-aerospike/src/index.js +113 -0
- package/packages/datadog-plugin-cucumber/src/index.js +34 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +60 -8
- package/packages/datadog-plugin-graphql/src/resolve.js +26 -18
- package/packages/datadog-plugin-http/src/client.js +19 -2
- package/packages/datadog-plugin-jest/src/index.js +38 -4
- package/packages/datadog-plugin-kafkajs/src/consumer.js +59 -6
- package/packages/datadog-plugin-kafkajs/src/producer.js +64 -6
- package/packages/datadog-plugin-mocha/src/index.js +32 -1
- package/packages/datadog-plugin-next/src/index.js +40 -14
- package/packages/datadog-plugin-playwright/src/index.js +17 -1
- package/packages/dd-trace/src/appsec/activation.js +29 -0
- package/packages/dd-trace/src/appsec/addresses.js +3 -1
- package/packages/dd-trace/src/appsec/api_security_sampler.js +48 -0
- package/packages/dd-trace/src/appsec/blocked_templates.js +4 -1
- package/packages/dd-trace/src/appsec/blocking.js +95 -43
- package/packages/dd-trace/src/appsec/channels.js +5 -2
- package/packages/dd-trace/src/appsec/graphql.js +146 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +1 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +105 -0
- package/packages/dd-trace/src/appsec/iast/iast-log.js +1 -1
- package/packages/dd-trace/src/appsec/iast/iast-plugin.js +1 -1
- package/packages/dd-trace/src/appsec/iast/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/path-line.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/constants.js +7 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +12 -19
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/header-sensitive-analyzer.js +20 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/json-sensitive-analyzer.js +6 -10
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +18 -25
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +79 -85
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +27 -36
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +14 -11
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +1 -0
- package/packages/dd-trace/src/appsec/index.js +33 -32
- package/packages/dd-trace/src/appsec/recommended.json +1737 -120
- package/packages/dd-trace/src/appsec/remote_config/capabilities.js +6 -1
- package/packages/dd-trace/src/appsec/remote_config/index.js +40 -15
- package/packages/dd-trace/src/appsec/reporter.js +50 -34
- package/packages/dd-trace/src/appsec/rule_manager.js +9 -6
- package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +28 -13
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +0 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +30 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +30 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +17 -1
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +110 -59
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +40 -7
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +26 -1
- package/packages/dd-trace/src/ci-visibility/telemetry.js +130 -0
- package/packages/dd-trace/src/config.js +145 -63
- package/packages/dd-trace/src/datastreams/processor.js +166 -26
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +14 -1
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +14 -0
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +4 -0
- package/packages/dd-trace/src/exporters/common/form-data.js +4 -0
- package/packages/dd-trace/src/format.js +6 -1
- package/packages/dd-trace/src/id.js +12 -0
- package/packages/dd-trace/src/iitm.js +1 -1
- package/packages/dd-trace/src/log/channels.js +1 -1
- package/packages/dd-trace/src/noop/proxy.js +4 -0
- package/packages/dd-trace/src/opentelemetry/span.js +95 -2
- package/packages/dd-trace/src/opentelemetry/tracer.js +9 -10
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +14 -5
- package/packages/dd-trace/src/opentracing/span.js +6 -0
- package/packages/dd-trace/src/opentracing/span_context.js +5 -2
- package/packages/dd-trace/src/opentracing/tracer.js +2 -2
- package/packages/dd-trace/src/plugin_manager.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +46 -9
- package/packages/dd-trace/src/plugins/database.js +1 -1
- package/packages/dd-trace/src/plugins/index.js +6 -0
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +6 -19
- package/packages/dd-trace/src/plugins/util/exec.js +23 -2
- package/packages/dd-trace/src/plugins/util/git.js +98 -22
- package/packages/dd-trace/src/plugins/util/ip_extractor.js +7 -6
- package/packages/dd-trace/src/plugins/util/test.js +3 -2
- package/packages/dd-trace/src/plugins/util/url.js +26 -0
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +4 -16
- package/packages/dd-trace/src/priority_sampler.js +30 -38
- package/packages/dd-trace/src/profiler.js +5 -3
- package/packages/dd-trace/src/profiling/config.js +26 -2
- package/packages/dd-trace/src/profiling/exporters/agent.js +1 -0
- package/packages/dd-trace/src/profiling/profiler.js +17 -10
- package/packages/dd-trace/src/profiling/profilers/events.js +264 -0
- package/packages/dd-trace/src/profiling/profilers/shared.js +39 -0
- package/packages/dd-trace/src/profiling/profilers/space.js +2 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +121 -58
- package/packages/dd-trace/src/proxy.js +25 -1
- package/packages/dd-trace/src/ritm.js +1 -1
- package/packages/dd-trace/src/sampling_rule.js +130 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -0
- package/packages/dd-trace/src/span_processor.js +4 -0
- package/packages/dd-trace/src/span_sampler.js +6 -64
- package/packages/dd-trace/src/spanleak.js +98 -0
- package/packages/dd-trace/src/startup-log.js +7 -1
- package/packages/dd-trace/src/telemetry/dependencies.js +56 -10
- package/packages/dd-trace/src/telemetry/index.js +171 -41
- package/packages/dd-trace/src/telemetry/logs/index.js +2 -2
- package/packages/dd-trace/src/telemetry/send-data.js +47 -5
- package/packages/dd-trace/src/tracer.js +8 -2
- package/scripts/install_plugin_modules.js +11 -3
- package/packages/diagnostics_channel/index.js +0 -3
- package/packages/diagnostics_channel/src/index.js +0 -121
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
|
|
3
2
|
const tracerVersion = require('../../../../package.json').version
|
|
4
|
-
const dc = require('
|
|
3
|
+
const dc = require('dc-polyfill')
|
|
5
4
|
const os = require('os')
|
|
6
5
|
const dependencies = require('./dependencies')
|
|
7
6
|
const { sendData } = require('./send-data')
|
|
8
|
-
|
|
7
|
+
const { errors } = require('../startup-log')
|
|
9
8
|
const { manager: metricsManager } = require('./metrics')
|
|
10
|
-
const logs = require('./logs')
|
|
11
9
|
|
|
12
10
|
const telemetryStartChannel = dc.channel('datadog:telemetry:start')
|
|
13
11
|
const telemetryStopChannel = dc.channel('datadog:telemetry:stop')
|
|
@@ -17,11 +15,53 @@ let pluginManager
|
|
|
17
15
|
|
|
18
16
|
let application
|
|
19
17
|
let host
|
|
20
|
-
let interval
|
|
21
18
|
let heartbeatTimeout
|
|
22
19
|
let heartbeatInterval
|
|
20
|
+
let extendedInterval
|
|
21
|
+
let integrations
|
|
22
|
+
let retryData = null
|
|
23
|
+
const extendedHeartbeatPayload = {}
|
|
24
|
+
|
|
23
25
|
const sentIntegrations = new Set()
|
|
24
26
|
|
|
27
|
+
function getRetryData () {
|
|
28
|
+
return retryData
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function updateRetryData (error, retryObj) {
|
|
32
|
+
if (error) {
|
|
33
|
+
if (retryObj.reqType === 'message-batch') {
|
|
34
|
+
const payload = retryObj.payload[0].payload
|
|
35
|
+
const reqType = retryObj.payload[0].request_type
|
|
36
|
+
retryData = { payload: payload, reqType: reqType }
|
|
37
|
+
|
|
38
|
+
// Since this payload failed twice it now gets save in to the extended heartbeat
|
|
39
|
+
const failedPayload = retryObj.payload[1].payload
|
|
40
|
+
const failedReqType = retryObj.payload[1].request_type
|
|
41
|
+
|
|
42
|
+
// save away the dependencies and integration request for extended heartbeat.
|
|
43
|
+
if (failedReqType === 'app-integrations-change') {
|
|
44
|
+
if (extendedHeartbeatPayload['integrations']) {
|
|
45
|
+
extendedHeartbeatPayload['integrations'].push(failedPayload)
|
|
46
|
+
} else {
|
|
47
|
+
extendedHeartbeatPayload['integrations'] = [failedPayload]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (failedReqType === 'app-dependencies-loaded') {
|
|
51
|
+
if (extendedHeartbeatPayload['dependencies']) {
|
|
52
|
+
extendedHeartbeatPayload['dependencies'].push(failedPayload)
|
|
53
|
+
} else {
|
|
54
|
+
extendedHeartbeatPayload['dependencies'] = [failedPayload]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
retryData = retryObj
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
retryData = null
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
25
65
|
function getIntegrations () {
|
|
26
66
|
const newIntegrations = []
|
|
27
67
|
for (const pluginName in pluginManager._pluginsByName) {
|
|
@@ -38,6 +78,23 @@ function getIntegrations () {
|
|
|
38
78
|
return newIntegrations
|
|
39
79
|
}
|
|
40
80
|
|
|
81
|
+
function getProducts (config) {
|
|
82
|
+
const products = {
|
|
83
|
+
appsec: {
|
|
84
|
+
enabled: config.appsec.enabled
|
|
85
|
+
},
|
|
86
|
+
profiler: {
|
|
87
|
+
version: tracerVersion,
|
|
88
|
+
enabled: config.profiling.enabled
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (errors.profilingError) {
|
|
92
|
+
products.profiler.error = errors.profilingError
|
|
93
|
+
errors.profilingError = {}
|
|
94
|
+
}
|
|
95
|
+
return products
|
|
96
|
+
}
|
|
97
|
+
|
|
41
98
|
function flatten (input, result = [], prefix = [], traversedObjects = null) {
|
|
42
99
|
traversedObjects = traversedObjects || new WeakSet()
|
|
43
100
|
if (traversedObjects.has(input)) {
|
|
@@ -48,33 +105,49 @@ function flatten (input, result = [], prefix = [], traversedObjects = null) {
|
|
|
48
105
|
if (typeof value === 'object' && value !== null) {
|
|
49
106
|
flatten(value, result, [...prefix, key], traversedObjects)
|
|
50
107
|
} else {
|
|
51
|
-
|
|
108
|
+
// TODO: add correct origin value
|
|
109
|
+
result.push({ name: [...prefix, key].join('.'), value, origin: 'unknown' })
|
|
52
110
|
}
|
|
53
111
|
}
|
|
54
112
|
return result
|
|
55
113
|
}
|
|
56
114
|
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
115
|
+
function getInstallSignature (config) {
|
|
116
|
+
const { installSignature: sig } = config
|
|
117
|
+
if (sig && (sig.id || sig.time || sig.type)) {
|
|
118
|
+
return {
|
|
119
|
+
install_id: sig.id,
|
|
120
|
+
install_time: sig.time,
|
|
121
|
+
install_type: sig.type
|
|
122
|
+
}
|
|
63
123
|
}
|
|
64
124
|
}
|
|
65
125
|
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
126
|
+
function appStarted (config) {
|
|
127
|
+
const app = {
|
|
128
|
+
products: getProducts(config),
|
|
129
|
+
configuration: flatten(config)
|
|
130
|
+
}
|
|
131
|
+
const installSignature = getInstallSignature(config)
|
|
132
|
+
if (installSignature) {
|
|
133
|
+
app.install_signature = installSignature
|
|
134
|
+
}
|
|
135
|
+
// TODO: add app.error with correct error codes
|
|
136
|
+
// if (errors.agentError) {
|
|
137
|
+
// app.error = errors.agentError
|
|
138
|
+
// errors.agentError = {}
|
|
139
|
+
// }
|
|
140
|
+
return app
|
|
73
141
|
}
|
|
74
142
|
|
|
75
143
|
function onBeforeExit () {
|
|
76
144
|
process.removeListener('beforeExit', onBeforeExit)
|
|
77
|
-
|
|
145
|
+
const { reqType, payload } = createPayload('app-closing')
|
|
146
|
+
sendData(config, application, host, reqType, payload)
|
|
147
|
+
// we flush before shutting down. Only in CI Visibility
|
|
148
|
+
if (config.isCiVisibility) {
|
|
149
|
+
metricsManager.send(config, application, host)
|
|
150
|
+
}
|
|
78
151
|
}
|
|
79
152
|
|
|
80
153
|
function createAppObject (config) {
|
|
@@ -121,14 +194,52 @@ function getTelemetryData () {
|
|
|
121
194
|
return { config, application, host, heartbeatInterval }
|
|
122
195
|
}
|
|
123
196
|
|
|
197
|
+
function createBatchPayload (payload) {
|
|
198
|
+
const batchPayload = []
|
|
199
|
+
payload.map(item => {
|
|
200
|
+
batchPayload.push({
|
|
201
|
+
request_type: item.reqType,
|
|
202
|
+
payload: item.payload
|
|
203
|
+
})
|
|
204
|
+
})
|
|
205
|
+
|
|
206
|
+
return batchPayload
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function createPayload (currReqType, currPayload = {}) {
|
|
210
|
+
if (getRetryData()) {
|
|
211
|
+
const payload = { reqType: currReqType, payload: currPayload }
|
|
212
|
+
const batchPayload = createBatchPayload([payload, retryData])
|
|
213
|
+
return { 'reqType': 'message-batch', 'payload': batchPayload }
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return { 'reqType': currReqType, 'payload': currPayload }
|
|
217
|
+
}
|
|
218
|
+
|
|
124
219
|
function heartbeat (config, application, host) {
|
|
125
220
|
heartbeatTimeout = setTimeout(() => {
|
|
126
|
-
|
|
221
|
+
metricsManager.send(config, application, host)
|
|
222
|
+
|
|
223
|
+
const { reqType, payload } = createPayload('app-heartbeat')
|
|
224
|
+
sendData(config, application, host, reqType, payload, updateRetryData)
|
|
127
225
|
heartbeat(config, application, host)
|
|
128
226
|
}, heartbeatInterval).unref()
|
|
129
227
|
return heartbeatTimeout
|
|
130
228
|
}
|
|
131
229
|
|
|
230
|
+
function extendedHeartbeat (config) {
|
|
231
|
+
extendedInterval = setInterval(() => {
|
|
232
|
+
const appPayload = appStarted(config)
|
|
233
|
+
const payload = {
|
|
234
|
+
...appPayload,
|
|
235
|
+
...extendedHeartbeatPayload
|
|
236
|
+
}
|
|
237
|
+
sendData(config, application, host, 'app-extended-heartbeat', payload)
|
|
238
|
+
Object.keys(extendedHeartbeatPayload).forEach(key => delete extendedHeartbeatPayload[key])
|
|
239
|
+
}, 1000 * 60 * 60 * 24).unref()
|
|
240
|
+
return extendedInterval
|
|
241
|
+
}
|
|
242
|
+
|
|
132
243
|
function start (aConfig, thePluginManager) {
|
|
133
244
|
if (!aConfig.telemetry.enabled) {
|
|
134
245
|
return
|
|
@@ -138,19 +249,22 @@ function start (aConfig, thePluginManager) {
|
|
|
138
249
|
application = createAppObject(config)
|
|
139
250
|
host = createHostObject()
|
|
140
251
|
heartbeatInterval = config.telemetry.heartbeatInterval
|
|
252
|
+
integrations = getIntegrations()
|
|
253
|
+
|
|
254
|
+
dependencies.start(config, application, host, getRetryData, updateRetryData)
|
|
141
255
|
|
|
142
|
-
|
|
143
|
-
|
|
256
|
+
sendData(config, application, host, 'app-started', appStarted(config))
|
|
257
|
+
|
|
258
|
+
if (integrations.length > 0) {
|
|
259
|
+
sendData(config, application, host, 'app-integrations-change',
|
|
260
|
+
{ integrations }, updateRetryData)
|
|
261
|
+
}
|
|
144
262
|
|
|
145
|
-
sendData(config, application, host, 'app-started', appStarted())
|
|
146
263
|
heartbeat(config, application, host)
|
|
147
|
-
interval = setInterval(() => {
|
|
148
|
-
metricsManager.send(config, application, host)
|
|
149
|
-
logs.send(config, application, host)
|
|
150
|
-
}, heartbeatInterval)
|
|
151
|
-
interval.unref()
|
|
152
|
-
process.on('beforeExit', onBeforeExit)
|
|
153
264
|
|
|
265
|
+
extendedHeartbeat(config)
|
|
266
|
+
|
|
267
|
+
process.on('beforeExit', onBeforeExit)
|
|
154
268
|
telemetryStartChannel.publish(getTelemetryData())
|
|
155
269
|
}
|
|
156
270
|
|
|
@@ -158,7 +272,7 @@ function stop () {
|
|
|
158
272
|
if (!config) {
|
|
159
273
|
return
|
|
160
274
|
}
|
|
161
|
-
clearInterval(
|
|
275
|
+
clearInterval(extendedInterval)
|
|
162
276
|
clearTimeout(heartbeatTimeout)
|
|
163
277
|
process.removeListener('beforeExit', onBeforeExit)
|
|
164
278
|
|
|
@@ -175,7 +289,10 @@ function updateIntegrations () {
|
|
|
175
289
|
if (integrations.length === 0) {
|
|
176
290
|
return
|
|
177
291
|
}
|
|
178
|
-
|
|
292
|
+
|
|
293
|
+
const { reqType, payload } = createPayload('app-integrations-change', { integrations })
|
|
294
|
+
|
|
295
|
+
sendData(config, application, host, reqType, payload, updateRetryData)
|
|
179
296
|
}
|
|
180
297
|
|
|
181
298
|
function updateConfig (changes, config) {
|
|
@@ -191,18 +308,31 @@ function updateConfig (changes, config) {
|
|
|
191
308
|
const names = {
|
|
192
309
|
sampleRate: 'DD_TRACE_SAMPLE_RATE',
|
|
193
310
|
logInjection: 'DD_LOG_INJECTION',
|
|
194
|
-
headerTags: 'DD_TRACE_HEADER_TAGS'
|
|
311
|
+
headerTags: 'DD_TRACE_HEADER_TAGS',
|
|
312
|
+
tags: 'DD_TAGS'
|
|
195
313
|
}
|
|
196
314
|
|
|
197
|
-
const configuration =
|
|
198
|
-
name: names[change.name],
|
|
199
|
-
value: Array.isArray(change.value) ? change.value.join(',') : change.value,
|
|
200
|
-
origin: change.origin
|
|
201
|
-
}))
|
|
315
|
+
const configuration = []
|
|
202
316
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
317
|
+
for (const change of changes) {
|
|
318
|
+
if (!names.hasOwnProperty(change.name)) continue
|
|
319
|
+
|
|
320
|
+
const name = names[change.name]
|
|
321
|
+
const { origin, value } = change
|
|
322
|
+
const entry = { name, origin, value }
|
|
323
|
+
|
|
324
|
+
if (Array.isArray(value)) {
|
|
325
|
+
entry.value = value.join(',')
|
|
326
|
+
} else if (name === 'DD_TAGS') {
|
|
327
|
+
entry.value = Object.entries(value).map(([key, value]) => `${key}:${value}`)
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
configuration.push(entry)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const { reqType, payload } = createPayload('app-client-configuration-change', { configuration })
|
|
334
|
+
|
|
335
|
+
sendData(config, application, host, reqType, payload, updateRetryData)
|
|
206
336
|
}
|
|
207
337
|
|
|
208
338
|
module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const dc = require('
|
|
3
|
+
const dc = require('dc-polyfill')
|
|
4
4
|
const logCollector = require('./log-collector')
|
|
5
5
|
const { sendData } = require('../send-data')
|
|
6
6
|
|
|
@@ -52,7 +52,7 @@ function stop () {
|
|
|
52
52
|
function send (config, application, host) {
|
|
53
53
|
if (!enabled) return
|
|
54
54
|
|
|
55
|
-
const logs = logCollector.drain()
|
|
55
|
+
const logs = { 'logs': logCollector.drain() }
|
|
56
56
|
if (logs) {
|
|
57
57
|
sendData(config, application, host, 'logs', logs)
|
|
58
58
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
|
|
1
2
|
const request = require('../exporters/common/request')
|
|
3
|
+
const log = require('../log')
|
|
4
|
+
let agentTelemetry = true
|
|
2
5
|
|
|
3
6
|
function getHeaders (config, application, reqType) {
|
|
4
7
|
const headers = {
|
|
5
8
|
'content-type': 'application/json',
|
|
6
|
-
'dd-telemetry-api-version': '
|
|
9
|
+
'dd-telemetry-api-version': 'v2',
|
|
7
10
|
'dd-telemetry-request-type': reqType,
|
|
8
11
|
'dd-client-library-language': application.language_name,
|
|
9
12
|
'dd-client-library-version': application.tracer_version
|
|
@@ -28,7 +31,7 @@ function getPayload (payload) {
|
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
|
|
31
|
-
function sendData (config, application, host, reqType, payload = {}) {
|
|
34
|
+
function sendData (config, application, host, reqType, payload = {}, cb = () => {}) {
|
|
32
35
|
const {
|
|
33
36
|
hostname,
|
|
34
37
|
port,
|
|
@@ -44,7 +47,8 @@ function sendData (config, application, host, reqType, payload = {}) {
|
|
|
44
47
|
headers: getHeaders(config, application, reqType)
|
|
45
48
|
}
|
|
46
49
|
const data = JSON.stringify({
|
|
47
|
-
api_version: '
|
|
50
|
+
api_version: 'v2',
|
|
51
|
+
naming_schema_version: config.spanAttributeSchema ? config.spanAttributeSchema : '',
|
|
48
52
|
request_type: reqType,
|
|
49
53
|
tracer_time: Math.floor(Date.now() / 1000),
|
|
50
54
|
runtime_id: config.tags['runtime-id'],
|
|
@@ -54,8 +58,46 @@ function sendData (config, application, host, reqType, payload = {}) {
|
|
|
54
58
|
host
|
|
55
59
|
})
|
|
56
60
|
|
|
57
|
-
request(data, options, () => {
|
|
58
|
-
|
|
61
|
+
request(data, options, (error) => {
|
|
62
|
+
if (error && process.env.DD_API_KEY && config.site) {
|
|
63
|
+
if (agentTelemetry) {
|
|
64
|
+
log.warn('Agent telemetry failed, started agentless telemetry')
|
|
65
|
+
agentTelemetry = false
|
|
66
|
+
}
|
|
67
|
+
// figure out which data center to send to
|
|
68
|
+
let backendUrl
|
|
69
|
+
const dataCenters = [
|
|
70
|
+
'datadoghq.com',
|
|
71
|
+
'us3.datadoghq.com',
|
|
72
|
+
'us5.datadoghq.com',
|
|
73
|
+
'ap1.datadoghq.com',
|
|
74
|
+
'eu1.datadoghq.com'
|
|
75
|
+
]
|
|
76
|
+
if (config.site === 'datad0g.com') { // staging
|
|
77
|
+
backendUrl = 'https://all-http-intake.logs.datad0g.com/api/v2/apmtelemetry'
|
|
78
|
+
} else if (dataCenters.includes(config.site)) {
|
|
79
|
+
backendUrl = 'https://instrumentation-telemetry-intake.' + config.site + '/api/v2/apmtelemetry'
|
|
80
|
+
}
|
|
81
|
+
const backendHeader = { ...options.headers, 'DD-API-KEY': process.env.DD_API_KEY }
|
|
82
|
+
const backendOptions = {
|
|
83
|
+
...options,
|
|
84
|
+
url: backendUrl,
|
|
85
|
+
headers: backendHeader
|
|
86
|
+
}
|
|
87
|
+
if (backendUrl) {
|
|
88
|
+
request(data, backendOptions, (error) => { log.error(error) })
|
|
89
|
+
} else {
|
|
90
|
+
log.error('Invalid Telemetry URL')
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (!error && !agentTelemetry) {
|
|
95
|
+
agentTelemetry = true
|
|
96
|
+
log.info('Started agent telemetry')
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// call the callback function so that we can track the error and payload
|
|
100
|
+
cb(error, { payload, reqType })
|
|
59
101
|
})
|
|
60
102
|
}
|
|
61
103
|
|
|
@@ -31,8 +31,10 @@ class DatadogTracer extends Tracer {
|
|
|
31
31
|
|
|
32
32
|
// todo[piochelepiotr] These two methods are not related to the tracer, but to data streams monitoring.
|
|
33
33
|
// They should be moved outside of the tracer in the future.
|
|
34
|
-
setCheckpoint (edgeTags) {
|
|
35
|
-
const ctx = this._dataStreamsProcessor.setCheckpoint(
|
|
34
|
+
setCheckpoint (edgeTags, span, payloadSize = 0) {
|
|
35
|
+
const ctx = this._dataStreamsProcessor.setCheckpoint(
|
|
36
|
+
edgeTags, span, DataStreamsContext.getDataStreamsContext(), payloadSize
|
|
37
|
+
)
|
|
36
38
|
DataStreamsContext.setDataStreamsContext(ctx)
|
|
37
39
|
return ctx
|
|
38
40
|
}
|
|
@@ -44,6 +46,10 @@ class DatadogTracer extends Tracer {
|
|
|
44
46
|
return ctx
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
setOffset (offsetData) {
|
|
50
|
+
return this._dataStreamsProcessor.setOffset(offsetData)
|
|
51
|
+
}
|
|
52
|
+
|
|
47
53
|
trace (name, options, fn) {
|
|
48
54
|
options = Object.assign({
|
|
49
55
|
childOf: this.scope().active()
|
|
@@ -80,7 +80,9 @@ async function assertVersions () {
|
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
async function assertInstrumentation (instrumentation, external) {
|
|
83
|
-
const versions =
|
|
83
|
+
const versions = process.env.PACKAGE_VERSION_RANGE ? [process.env.PACKAGE_VERSION_RANGE]
|
|
84
|
+
: [].concat(instrumentation.versions || [])
|
|
85
|
+
|
|
84
86
|
for (const version of versions) {
|
|
85
87
|
if (version) {
|
|
86
88
|
await assertModules(instrumentation.name, semver.coerce(version).version, external)
|
|
@@ -130,8 +132,14 @@ async function assertPackage (name, version, dependency, external) {
|
|
|
130
132
|
}
|
|
131
133
|
|
|
132
134
|
if (!external) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
+
if (name === 'aerospike') {
|
|
136
|
+
pkg.installConfig = {
|
|
137
|
+
'hoistingLimits': 'workspaces'
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
pkg.workspaces = {
|
|
141
|
+
nohoist: ['**/**']
|
|
142
|
+
}
|
|
135
143
|
}
|
|
136
144
|
}
|
|
137
145
|
fs.writeFileSync(filename(name, version, 'package.json'), JSON.stringify(pkg, null, 2) + '\n')
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
Channel,
|
|
5
|
-
channel
|
|
6
|
-
} = require('diagnostics_channel') // eslint-disable-line n/no-restricted-require
|
|
7
|
-
|
|
8
|
-
const [major, minor] = process.versions.node.split('.')
|
|
9
|
-
const channels = new WeakSet()
|
|
10
|
-
|
|
11
|
-
// Our own DC with a limited subset of functionality stable across Node versions.
|
|
12
|
-
// TODO: Move the rest of the polyfill here.
|
|
13
|
-
// TODO: Switch to using global subscribe/unsubscribe/hasSubscribers.
|
|
14
|
-
const dc = { channel }
|
|
15
|
-
|
|
16
|
-
// Prevent going to 0 subscribers to avoid bug in Node.
|
|
17
|
-
// See https://github.com/nodejs/node/pull/47520
|
|
18
|
-
if (major === '19' && minor === '9') {
|
|
19
|
-
dc.channel = function () {
|
|
20
|
-
const ch = channel.apply(this, arguments)
|
|
21
|
-
|
|
22
|
-
if (!channels.has(ch)) {
|
|
23
|
-
const subscribe = ch.subscribe
|
|
24
|
-
const unsubscribe = ch.unsubscribe
|
|
25
|
-
|
|
26
|
-
ch.subscribe = function () {
|
|
27
|
-
delete ch.subscribe
|
|
28
|
-
delete ch.unsubscribe
|
|
29
|
-
|
|
30
|
-
const result = subscribe.apply(this, arguments)
|
|
31
|
-
|
|
32
|
-
this.subscribe(() => {}) // Keep it active forever.
|
|
33
|
-
|
|
34
|
-
return result
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (ch.unsubscribe === Channel.prototype.unsubscribe) {
|
|
38
|
-
// Needed because another subscriber could have subscribed to something
|
|
39
|
-
// that we unsubscribe to before the library is loaded.
|
|
40
|
-
ch.unsubscribe = function () {
|
|
41
|
-
delete ch.subscribe
|
|
42
|
-
delete ch.unsubscribe
|
|
43
|
-
|
|
44
|
-
this.subscribe(() => {}) // Keep it active forever.
|
|
45
|
-
|
|
46
|
-
return unsubscribe.apply(this, arguments)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
channels.add(ch)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return ch
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (!Channel.prototype.runStores) {
|
|
58
|
-
const ActiveChannelPrototype = getActiveChannelPrototype()
|
|
59
|
-
|
|
60
|
-
Channel.prototype.bindStore = ActiveChannelPrototype.bindStore = function (store, transform) {
|
|
61
|
-
if (!this._stores) {
|
|
62
|
-
this._stores = new Map()
|
|
63
|
-
}
|
|
64
|
-
this._stores.set(store, transform)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
Channel.prototype.unbindStore = ActiveChannelPrototype.unbindStore = function (store) {
|
|
68
|
-
if (!this._stores) return
|
|
69
|
-
this._stores.delete(store)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
Channel.prototype.runStores = ActiveChannelPrototype.runStores = function (data, fn, thisArg, ...args) {
|
|
73
|
-
if (!this._stores) return Reflect.apply(fn, thisArg, args)
|
|
74
|
-
|
|
75
|
-
let run = () => {
|
|
76
|
-
this.publish(data)
|
|
77
|
-
return Reflect.apply(fn, thisArg, args)
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
for (const entry of this._stores.entries()) {
|
|
81
|
-
const store = entry[0]
|
|
82
|
-
const transform = entry[1]
|
|
83
|
-
run = wrapStoreRun(store, data, run, transform)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return run()
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function defaultTransform (data) {
|
|
91
|
-
return data
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function wrapStoreRun (store, data, next, transform = defaultTransform) {
|
|
95
|
-
return () => {
|
|
96
|
-
let context
|
|
97
|
-
try {
|
|
98
|
-
context = transform(data)
|
|
99
|
-
} catch (err) {
|
|
100
|
-
process.nextTick(() => {
|
|
101
|
-
throw err
|
|
102
|
-
})
|
|
103
|
-
return next()
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return store.run(context, next)
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function getActiveChannelPrototype () {
|
|
111
|
-
const dummyChannel = channel('foo')
|
|
112
|
-
const listener = () => {}
|
|
113
|
-
|
|
114
|
-
dummyChannel.subscribe(listener)
|
|
115
|
-
const ActiveChannelPrototype = Object.getPrototypeOf(dummyChannel)
|
|
116
|
-
dummyChannel.unsubscribe(listener)
|
|
117
|
-
|
|
118
|
-
return ActiveChannelPrototype
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
module.exports = dc
|