dd-trace 5.87.0 → 5.89.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 +60 -32
- package/ext/exporters.d.ts +1 -0
- package/ext/exporters.js +1 -0
- package/ext/tags.js +2 -0
- package/index.d.ts +234 -4
- package/package.json +18 -11
- package/packages/datadog-instrumentations/src/ai.js +54 -90
- package/packages/datadog-instrumentations/src/helpers/hook.js +17 -11
- package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +27 -110
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/ai.js +103 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.js +108 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +2 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/compiler.js +74 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/index.js +43 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/matcher.js +49 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/orchestrion/transformer.js +121 -0
- package/packages/datadog-instrumentations/src/helpers/rewriter/{transforms.js → orchestrion/transforms.js} +143 -17
- package/packages/datadog-instrumentations/src/jest.js +176 -54
- package/packages/datadog-instrumentations/src/kafkajs.js +20 -17
- package/packages/datadog-instrumentations/src/playwright.js +1 -1
- package/packages/datadog-plugin-amqplib/src/consumer.js +14 -10
- package/packages/datadog-plugin-amqplib/src/producer.js +23 -19
- package/packages/datadog-plugin-bullmq/src/consumer.js +33 -11
- package/packages/datadog-plugin-bullmq/src/producer.js +60 -31
- package/packages/datadog-plugin-cucumber/src/index.js +9 -6
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +62 -5
- package/packages/datadog-plugin-cypress/src/source-map-utils.js +297 -0
- package/packages/datadog-plugin-cypress/src/support.js +52 -9
- package/packages/datadog-plugin-jest/src/index.js +12 -2
- package/packages/datadog-plugin-jest/src/util.js +2 -1
- package/packages/datadog-plugin-kafkajs/src/consumer.js +22 -12
- package/packages/datadog-plugin-kafkajs/src/producer.js +33 -22
- package/packages/datadog-plugin-mocha/src/index.js +9 -6
- package/packages/datadog-plugin-playwright/src/index.js +10 -6
- package/packages/datadog-plugin-vitest/src/index.js +13 -8
- package/packages/dd-trace/src/aiguard/sdk.js +5 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/cookie-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/unvalidated-redirect-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +4 -5
- package/packages/dd-trace/src/appsec/iast/path-line.js +36 -25
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +3 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +3 -2
- package/packages/dd-trace/src/azure_metadata.js +0 -2
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +3 -0
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -1
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +4 -1
- package/packages/dd-trace/src/ci-visibility/requests/request.js +236 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
- package/packages/dd-trace/src/config/defaults.js +148 -197
- package/packages/dd-trace/src/config/helper.js +43 -1
- package/packages/dd-trace/src/config/index.js +38 -14
- package/packages/dd-trace/src/config/supported-configurations.json +4125 -512
- package/packages/dd-trace/src/constants.js +0 -2
- package/packages/dd-trace/src/crashtracking/crashtracker.js +10 -3
- package/packages/dd-trace/src/datastreams/checkpointer.js +13 -0
- package/packages/dd-trace/src/datastreams/index.js +3 -0
- package/packages/dd-trace/src/datastreams/manager.js +9 -0
- package/packages/dd-trace/src/datastreams/pathway.js +22 -3
- package/packages/dd-trace/src/datastreams/processor.js +140 -4
- package/packages/dd-trace/src/encode/agentless-json.js +155 -0
- package/packages/dd-trace/src/exporter.js +2 -0
- package/packages/dd-trace/src/exporters/agent/writer.js +21 -8
- package/packages/dd-trace/src/exporters/agentless/index.js +89 -0
- package/packages/dd-trace/src/exporters/agentless/writer.js +184 -0
- package/packages/dd-trace/src/exporters/common/request.js +4 -4
- package/packages/dd-trace/src/llmobs/plugins/ai/index.js +5 -3
- package/packages/dd-trace/src/opentelemetry/context_manager.js +19 -46
- package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +3 -4
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +3 -5
- package/packages/dd-trace/src/opentracing/span.js +6 -4
- package/packages/dd-trace/src/pkg.js +1 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +57 -5
- package/packages/dd-trace/src/plugins/database.js +15 -2
- package/packages/dd-trace/src/plugins/util/test.js +48 -0
- package/packages/dd-trace/src/profiling/exporter_cli.js +1 -0
- package/packages/dd-trace/src/propagation-hash/index.js +145 -0
- package/packages/dd-trace/src/proxy.js +6 -1
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +1 -1
- package/packages/dd-trace/src/startup-log.js +53 -19
- package/vendor/dist/@datadog/sketches-js/index.js +1 -1
- package/vendor/dist/@datadog/source-map/index.js +1 -1
- package/vendor/dist/@isaacs/ttlcache/index.js +1 -1
- package/vendor/dist/@opentelemetry/core/index.js +1 -1
- package/vendor/dist/@opentelemetry/resources/index.js +1 -1
- package/vendor/dist/astring/index.js +1 -1
- package/vendor/dist/crypto-randomuuid/index.js +1 -1
- package/vendor/dist/escape-string-regexp/index.js +1 -1
- package/vendor/dist/esquery/index.js +1 -1
- package/vendor/dist/ignore/index.js +1 -1
- package/vendor/dist/istanbul-lib-coverage/index.js +1 -1
- package/vendor/dist/jest-docblock/index.js +1 -1
- package/vendor/dist/jsonpath-plus/index.js +1 -1
- package/vendor/dist/limiter/index.js +1 -1
- package/vendor/dist/lodash.sortby/index.js +1 -1
- package/vendor/dist/lru-cache/index.js +1 -1
- package/vendor/dist/meriyah/index.js +1 -1
- package/vendor/dist/module-details-from-path/index.js +1 -1
- package/vendor/dist/mutexify/promise/index.js +1 -1
- package/vendor/dist/opentracing/index.js +1 -1
- package/vendor/dist/path-to-regexp/index.js +1 -1
- package/vendor/dist/pprof-format/index.js +1 -1
- package/vendor/dist/protobufjs/index.js +1 -1
- package/vendor/dist/protobufjs/minimal/index.js +1 -1
- package/vendor/dist/retry/index.js +1 -1
- package/vendor/dist/rfdc/index.js +1 -1
- package/vendor/dist/semifies/index.js +1 -1
- package/vendor/dist/shell-quote/index.js +1 -1
- package/vendor/dist/source-map/index.js +1 -1
- package/vendor/dist/source-map/lib/util/index.js +1 -1
- package/vendor/dist/tlhunter-sorted-set/index.js +1 -1
- package/vendor/dist/ttl-set/index.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/rewriter/compiler.js +0 -33
- package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/bullmq.json +0 -106
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +0 -741
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +0 -11
- package/packages/dd-trace/src/scope/noop/scope.js +0 -21
|
@@ -145,6 +145,10 @@ const DD_CAPABILITIES_TEST_MANAGEMENT_QUARANTINE = '_dd.library_capabilities.tes
|
|
|
145
145
|
const DD_CAPABILITIES_TEST_MANAGEMENT_DISABLE = '_dd.library_capabilities.test_management.disable'
|
|
146
146
|
const DD_CAPABILITIES_TEST_MANAGEMENT_ATTEMPT_TO_FIX = '_dd.library_capabilities.test_management.attempt_to_fix'
|
|
147
147
|
const DD_CAPABILITIES_FAILED_TEST_REPLAY = '_dd.library_capabilities.failed_test_replay'
|
|
148
|
+
|
|
149
|
+
// Library configuration request error tag
|
|
150
|
+
const DD_CI_LIBRARY_CONFIGURATION_ERROR = '_dd.ci.library_configuration_error'
|
|
151
|
+
|
|
148
152
|
const UNSUPPORTED_TIA_FRAMEWORKS = new Set(['playwright', 'vitest'])
|
|
149
153
|
const UNSUPPORTED_TIA_FRAMEWORKS_PARALLEL_MODE = new Set(['cucumber', 'mocha'])
|
|
150
154
|
const MINIMUM_FRAMEWORK_VERSION_FOR_EFD = {
|
|
@@ -202,6 +206,22 @@ const TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED = 'test.test_management.attempt_to_f
|
|
|
202
206
|
const POSSIBLE_BASE_BRANCHES = ['main', 'master', 'preprod', 'prod', 'dev', 'development', 'trunk']
|
|
203
207
|
const BASE_LIKE_BRANCH_FILTER = /^(main|master|preprod|prod|dev|development|trunk|release\/.*|hotfix\/.*)$/
|
|
204
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Returns request error tags from a test session span for propagation to child events.
|
|
211
|
+
* @param {{ context: () => { _tags?: Record<string, string> } } | undefined} sessionSpan
|
|
212
|
+
* @returns {Record<string, string>}
|
|
213
|
+
*/
|
|
214
|
+
function getSessionRequestErrorTags (sessionSpan) {
|
|
215
|
+
const tags = sessionSpan?.context()._tags
|
|
216
|
+
if (!tags || typeof tags !== 'object') return {}
|
|
217
|
+
if (tags[DD_CI_LIBRARY_CONFIGURATION_ERROR] === 'true') {
|
|
218
|
+
return {
|
|
219
|
+
[DD_CI_LIBRARY_CONFIGURATION_ERROR]: 'true',
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return {}
|
|
223
|
+
}
|
|
224
|
+
|
|
205
225
|
module.exports = {
|
|
206
226
|
TEST_CODE_OWNERS,
|
|
207
227
|
TEST_SESSION_NAME,
|
|
@@ -278,6 +298,7 @@ module.exports = {
|
|
|
278
298
|
removeInvalidMetadata,
|
|
279
299
|
parseAnnotations,
|
|
280
300
|
getIsFaultyEarlyFlakeDetection,
|
|
301
|
+
getEfdRetryCount,
|
|
281
302
|
TEST_BROWSER_DRIVER,
|
|
282
303
|
TEST_BROWSER_DRIVER_VERSION,
|
|
283
304
|
TEST_BROWSER_NAME,
|
|
@@ -308,6 +329,8 @@ module.exports = {
|
|
|
308
329
|
TEST_MANAGEMENT_ENABLED,
|
|
309
330
|
TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED,
|
|
310
331
|
getLibraryCapabilitiesTags,
|
|
332
|
+
getSessionRequestErrorTags,
|
|
333
|
+
DD_CI_LIBRARY_CONFIGURATION_ERROR,
|
|
311
334
|
checkShaDiscrepancies,
|
|
312
335
|
getPullRequestDiff,
|
|
313
336
|
getPullRequestBaseBranch,
|
|
@@ -846,6 +869,31 @@ function parseAnnotations (annotations) {
|
|
|
846
869
|
}, {})
|
|
847
870
|
}
|
|
848
871
|
|
|
872
|
+
/**
|
|
873
|
+
* Given a test's first-execution duration (ms) and the slow_test_retries map
|
|
874
|
+
* from the backend, return how many EFD retries to run.
|
|
875
|
+
*
|
|
876
|
+
* Returns 0 when the test is too slow to retry (≥ 5 min).
|
|
877
|
+
*
|
|
878
|
+
* @param {number} durationMs
|
|
879
|
+
* @param {Record<string, number>} slowTestRetries e.g. { '5s': 10, '10s': 5, '30s': 3, '5m': 2 }
|
|
880
|
+
* @returns {number}
|
|
881
|
+
*/
|
|
882
|
+
function getEfdRetryCount (durationMs, slowTestRetries) {
|
|
883
|
+
const thresholds = [
|
|
884
|
+
{ limitMs: 5 * 1000, key: '5s' },
|
|
885
|
+
{ limitMs: 10 * 1000, key: '10s' },
|
|
886
|
+
{ limitMs: 30 * 1000, key: '30s' },
|
|
887
|
+
{ limitMs: 5 * 60 * 1000, key: '5m' },
|
|
888
|
+
]
|
|
889
|
+
for (const { limitMs, key } of thresholds) {
|
|
890
|
+
if (durationMs < limitMs) {
|
|
891
|
+
return slowTestRetries[key] ?? 0
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return 0 // ≥ 5 min — abort
|
|
895
|
+
}
|
|
896
|
+
|
|
849
897
|
function getIsFaultyEarlyFlakeDetection (projectSuites, testsBySuiteName, faultyThresholdPercentage) {
|
|
850
898
|
let newSuites = 0
|
|
851
899
|
for (const suite of projectSuites) {
|
|
@@ -17,6 +17,7 @@ function exporterFromURL (url) {
|
|
|
17
17
|
if (url.protocol === 'file:') {
|
|
18
18
|
return new FileExporter({ pprofPrefix: fileURLToPath(url) })
|
|
19
19
|
}
|
|
20
|
+
// TODO: Why is DD_INJECTION_ENABLED a comma separated list?
|
|
20
21
|
const injectionEnabled = (getValueFromEnvSources('DD_INJECTION_ENABLED') ?? '').split(',')
|
|
21
22
|
const libraryInjected = injectionEnabled.length > 0
|
|
22
23
|
const profilingEnabled = (getValueFromEnvSources('DD_PROFILING_ENABLED') ?? '').toLowerCase()
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { fnv64 } = require('../datastreams/fnv')
|
|
4
|
+
const log = require('../log')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* PropagationHashManager is a singleton that manages the propagation hash computation.
|
|
8
|
+
* The propagation hash is an FNV-1a 64-bit hash combining:
|
|
9
|
+
* - Process tags (entrypoint info, package.json name, etc.)
|
|
10
|
+
* - Container tags hash (received from the Datadog agent)
|
|
11
|
+
*
|
|
12
|
+
* This hash is used to correlate traces with database operations (DBM) and
|
|
13
|
+
* data stream pathways (DSM) for enhanced observability.
|
|
14
|
+
*/
|
|
15
|
+
class PropagationHashManager {
|
|
16
|
+
_containerTagsHash = null
|
|
17
|
+
_cachedHash = null
|
|
18
|
+
_cachedHashString = null
|
|
19
|
+
_cachedHashBase64 = null
|
|
20
|
+
_config = null
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Configure the propagation hash manager with tracer config
|
|
24
|
+
* @param {object} config - Tracer configuration
|
|
25
|
+
*/
|
|
26
|
+
configure (config) {
|
|
27
|
+
this._config = config
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Check if process tags propagation is enabled
|
|
32
|
+
* @returns {boolean}
|
|
33
|
+
*/
|
|
34
|
+
isEnabled () {
|
|
35
|
+
return this._config?.propagateProcessTags?.enabled === true
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Update the container tags hash received from the agent
|
|
40
|
+
* @param {string} hash - Container tags hash from agent response
|
|
41
|
+
*/
|
|
42
|
+
updateContainerTagsHash (hash) {
|
|
43
|
+
if (hash !== this._containerTagsHash) {
|
|
44
|
+
log.debug('Updating container tags hash: %s', hash)
|
|
45
|
+
this._containerTagsHash = hash
|
|
46
|
+
this._invalidateCache()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get the propagation hash as a BigInt
|
|
52
|
+
* @returns {bigint | null} The propagation hash or null if disabled/unavailable
|
|
53
|
+
*/
|
|
54
|
+
getHash () {
|
|
55
|
+
if (!this.isEnabled()) {
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
if (this._cachedHash) {
|
|
59
|
+
return this._cachedHash
|
|
60
|
+
}
|
|
61
|
+
this._computeHash()
|
|
62
|
+
return this._cachedHash
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get the propagation hash as a hexadecimal string
|
|
67
|
+
* @returns {string|null} The propagation hash in hex format or null if disabled/unavailable
|
|
68
|
+
*/
|
|
69
|
+
getHashString () {
|
|
70
|
+
const hash = this.getHash()
|
|
71
|
+
if (!hash) {
|
|
72
|
+
return null
|
|
73
|
+
}
|
|
74
|
+
if (!this._cachedHashString) {
|
|
75
|
+
this._cachedHashString = hash.toString(16)
|
|
76
|
+
}
|
|
77
|
+
return this._cachedHashString
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get the propagation hash as a base64 string
|
|
82
|
+
* @returns {string|null} The propagation hash in base64 format or null if disabled/unavailable
|
|
83
|
+
*/
|
|
84
|
+
getHashBase64 () {
|
|
85
|
+
const hash = this.getHash()
|
|
86
|
+
if (!hash) {
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
if (!this._cachedHashBase64) {
|
|
90
|
+
// Convert BigInt to 8-byte buffer (64-bit hash)
|
|
91
|
+
const buffer = Buffer.allocUnsafe(8)
|
|
92
|
+
// Write as big-endian 64-bit unsigned integer
|
|
93
|
+
buffer.writeBigUInt64BE(hash, 0)
|
|
94
|
+
this._cachedHashBase64 = buffer.toString('base64')
|
|
95
|
+
}
|
|
96
|
+
return this._cachedHashBase64
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Compute the propagation hash using FNV-1a algorithm
|
|
101
|
+
* @private
|
|
102
|
+
*/
|
|
103
|
+
_computeHash () {
|
|
104
|
+
try {
|
|
105
|
+
const processTags = require('../process-tags')
|
|
106
|
+
|
|
107
|
+
// Combine process tags and container tags hash
|
|
108
|
+
// Process tags are already serialized as a comma-separated string
|
|
109
|
+
const input = processTags.serialized + (this._containerTagsHash || '')
|
|
110
|
+
|
|
111
|
+
if (!input) {
|
|
112
|
+
// If both are empty, don't compute a hash
|
|
113
|
+
this._cachedHash = null
|
|
114
|
+
this._cachedHashString = null
|
|
115
|
+
this._cachedHashBase64 = null
|
|
116
|
+
return
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Compute FNV-1a 64-bit hash
|
|
120
|
+
this._cachedHash = fnv64(input)
|
|
121
|
+
this._cachedHashString = null // Will be computed on demand
|
|
122
|
+
this._cachedHashBase64 = null // Will be computed on demand
|
|
123
|
+
|
|
124
|
+
log.debug('Computed propagation hash from input (length=%s): "%s"', input.length, this._cachedHash.toString(16))
|
|
125
|
+
} catch (e) {
|
|
126
|
+
log.error('Error computing propagation hash', e)
|
|
127
|
+
this._cachedHash = null
|
|
128
|
+
this._cachedHashString = null
|
|
129
|
+
this._cachedHashBase64 = null
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Invalidate the cached hash
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
_invalidateCache () {
|
|
138
|
+
this._cachedHash = null
|
|
139
|
+
this._cachedHashString = null
|
|
140
|
+
this._cachedHashBase64 = null
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Export singleton instance
|
|
145
|
+
module.exports = new PropagationHashManager()
|
|
@@ -6,7 +6,7 @@ const DatadogTracer = require('./tracer')
|
|
|
6
6
|
const getConfig = require('./config')
|
|
7
7
|
const runtimeMetrics = require('./runtime_metrics')
|
|
8
8
|
const log = require('./log')
|
|
9
|
-
const { setStartupLogPluginManager } = require('./startup-log')
|
|
9
|
+
const { setStartupLogPluginManager, startupLog } = require('./startup-log')
|
|
10
10
|
const DynamicInstrumentation = require('./debugger')
|
|
11
11
|
const telemetry = require('./telemetry')
|
|
12
12
|
const nomenclature = require('./service-naming')
|
|
@@ -102,6 +102,10 @@ class Tracer extends NoopProxy {
|
|
|
102
102
|
try {
|
|
103
103
|
const config = getConfig(options) // TODO: support dynamic code config
|
|
104
104
|
|
|
105
|
+
// Configure propagation hash manager for process tags + container tags
|
|
106
|
+
const propagationHash = require('./propagation-hash')
|
|
107
|
+
propagationHash.configure(config)
|
|
108
|
+
|
|
105
109
|
if (config.crashtracking.enabled) {
|
|
106
110
|
require('./crashtracking').start(config)
|
|
107
111
|
}
|
|
@@ -288,6 +292,7 @@ class Tracer extends NoopProxy {
|
|
|
288
292
|
this._pluginManager.configure(config)
|
|
289
293
|
DynamicInstrumentation.configure(config)
|
|
290
294
|
setStartupLogPluginManager(this._pluginManager)
|
|
295
|
+
startupLog()
|
|
291
296
|
}
|
|
292
297
|
}
|
|
293
298
|
|
|
@@ -238,7 +238,7 @@ function captureHeapSpace () {
|
|
|
238
238
|
const stats = v8.getHeapSpaceStatistics()
|
|
239
239
|
|
|
240
240
|
for (let i = 0, l = stats.length; i < l; i++) {
|
|
241
|
-
const tags = [`
|
|
241
|
+
const tags = [`heap_space:${stats[i].space_name}`]
|
|
242
242
|
|
|
243
243
|
client.gauge('runtime.node.heap.size.by.space', stats[i].space_size, tags)
|
|
244
244
|
client.gauge('runtime.node.heap.used_size.by.space', stats[i].space_used_size, tags)
|
|
@@ -11,41 +11,66 @@ let config
|
|
|
11
11
|
let pluginManager
|
|
12
12
|
/** @type {import('./sampling_rule')[]} */
|
|
13
13
|
let samplingRules = []
|
|
14
|
-
let
|
|
14
|
+
let configAlreadyRan = false
|
|
15
|
+
let integrationsAlreadyRan = false
|
|
16
|
+
let agentErrorAlreadyRan = false
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
19
|
+
* Logs DATADOG TRACER CONFIGURATION immediately at init time.
|
|
20
|
+
* Excludes integrations_loaded since plugins haven't loaded yet.
|
|
18
21
|
*/
|
|
19
|
-
function startupLog (
|
|
20
|
-
if (
|
|
22
|
+
function startupLog () {
|
|
23
|
+
if (configAlreadyRan || !config || !config.startupLogs) {
|
|
21
24
|
return
|
|
22
25
|
}
|
|
23
26
|
|
|
24
|
-
|
|
27
|
+
configAlreadyRan = true
|
|
25
28
|
|
|
26
|
-
const out =
|
|
29
|
+
const out = configInfo()
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
warn('DATADOG TRACER CONFIGURATION - ' + out)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Logs loaded integrations. Called from writer.js on first agent payload,
|
|
36
|
+
* by which time the app has loaded its dependencies.
|
|
37
|
+
*/
|
|
38
|
+
function logIntegrations () {
|
|
39
|
+
if (integrationsAlreadyRan || !config || !config.startupLogs || !pluginManager) {
|
|
40
|
+
return
|
|
30
41
|
}
|
|
31
42
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
integrationsAlreadyRan = true
|
|
44
|
+
|
|
45
|
+
warn('DATADOG TRACER INTEGRATIONS LOADED - ' + JSON.stringify(Object.keys(pluginManager._pluginsByName)))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Logs agent error diagnostic.
|
|
50
|
+
* @param {{ status: number, message: string }} agentError
|
|
51
|
+
*/
|
|
52
|
+
function logAgentError (agentError) {
|
|
53
|
+
if (agentErrorAlreadyRan || !config || !config.startupLogs) {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
agentErrorAlreadyRan = true
|
|
58
|
+
|
|
59
|
+
warn('DATADOG TRACER DIAGNOSTIC - Agent Error: ' + agentError.message)
|
|
60
|
+
errors.agentError = {
|
|
61
|
+
code: agentError.status,
|
|
62
|
+
message: `Agent Error: ${agentError.message}`,
|
|
39
63
|
}
|
|
40
64
|
}
|
|
41
65
|
|
|
42
66
|
/**
|
|
67
|
+
* Returns config info without integrations (used by startupLog).
|
|
43
68
|
* @returns {Record<string, unknown>}
|
|
44
69
|
*/
|
|
45
|
-
function
|
|
70
|
+
function configInfo () {
|
|
46
71
|
const url = getAgentUrl(config)
|
|
47
72
|
|
|
48
|
-
|
|
73
|
+
return {
|
|
49
74
|
[inspect.custom] () {
|
|
50
75
|
return String(this)
|
|
51
76
|
},
|
|
@@ -73,11 +98,18 @@ function tracerInfo () {
|
|
|
73
98
|
log_injection_enabled: !!config.logInjection,
|
|
74
99
|
runtime_metrics_enabled: !!config.runtimeMetrics,
|
|
75
100
|
profiling_enabled: config.profiling?.enabled === 'true' || config.profiling?.enabled === 'auto',
|
|
76
|
-
|
|
77
|
-
appsec_enabled: !!config.appsec.enabled,
|
|
101
|
+
appsec_enabled: config.appsec.enabled,
|
|
78
102
|
data_streams_enabled: !!config.dsmEnabled,
|
|
79
103
|
}
|
|
104
|
+
}
|
|
80
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Returns full tracer info including integrations (used by flare module).
|
|
108
|
+
* @returns {Record<string, unknown>}
|
|
109
|
+
*/
|
|
110
|
+
function tracerInfo () {
|
|
111
|
+
const out = configInfo()
|
|
112
|
+
out.integrations_loaded = Object.keys(pluginManager._pluginsByName)
|
|
81
113
|
return out
|
|
82
114
|
}
|
|
83
115
|
|
|
@@ -104,6 +136,8 @@ function setSamplingRules (theRules) {
|
|
|
104
136
|
|
|
105
137
|
module.exports = {
|
|
106
138
|
startupLog,
|
|
139
|
+
logIntegrations,
|
|
140
|
+
logAgentError,
|
|
107
141
|
setStartupLogConfig,
|
|
108
142
|
setStartupLogPluginManager,
|
|
109
143
|
setSamplingRules,
|