dd-trace 4.11.1 → 4.12.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/index.d.ts +43 -0
- package/package.json +2 -1
- package/packages/datadog-esbuild/index.js +10 -4
- package/packages/datadog-instrumentations/src/cucumber.js +30 -11
- package/packages/datadog-instrumentations/src/jest.js +22 -11
- package/packages/datadog-instrumentations/src/mocha.js +30 -8
- package/packages/datadog-instrumentations/src/next.js +16 -14
- package/packages/datadog-instrumentations/src/pg.js +46 -0
- package/packages/datadog-plugin-cucumber/src/index.js +14 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +17 -8
- package/packages/datadog-plugin-jest/src/index.js +10 -2
- package/packages/datadog-plugin-jest/src/util.js +10 -4
- package/packages/datadog-plugin-mocha/src/index.js +14 -2
- package/packages/datadog-plugin-next/src/index.js +11 -3
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +19 -4
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +1 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/index.js +14 -5
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +120 -10
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +0 -1
- package/packages/dd-trace/src/dogstatsd.js +65 -5
- package/packages/dd-trace/src/exporters/agent/writer.js +9 -9
- package/packages/dd-trace/src/opentracing/span.js +13 -13
- package/packages/dd-trace/src/opentracing/tracer.js +3 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +22 -1
- package/packages/dd-trace/src/plugins/util/test.js +18 -1
- package/packages/dd-trace/src/profiling/profilers/wall.js +7 -5
- package/packages/dd-trace/src/proxy.js +23 -2
- package/packages/dd-trace/src/ritm.js +10 -2
- /package/packages/dd-trace/src/{metrics.js → runtime_metrics.js} +0 -0
|
@@ -47,6 +47,7 @@ const TEST_SESSION_ID = 'test_session_id'
|
|
|
47
47
|
const TEST_MODULE_ID = 'test_module_id'
|
|
48
48
|
const TEST_SUITE_ID = 'test_suite_id'
|
|
49
49
|
const TEST_TOOLCHAIN = 'test.toolchain'
|
|
50
|
+
const TEST_SKIPPED_BY_ITR = 'test.skipped_by_itr'
|
|
50
51
|
|
|
51
52
|
const CI_APP_ORIGIN = 'ciapp-test'
|
|
52
53
|
|
|
@@ -54,6 +55,8 @@ const JEST_TEST_RUNNER = 'test.jest.test_runner'
|
|
|
54
55
|
|
|
55
56
|
const TEST_ITR_TESTS_SKIPPED = '_dd.ci.itr.tests_skipped'
|
|
56
57
|
const TEST_ITR_SKIPPING_ENABLED = 'test.itr.tests_skipping.enabled'
|
|
58
|
+
const TEST_ITR_SKIPPING_TYPE = 'test.itr.tests_skipping.type'
|
|
59
|
+
const TEST_ITR_SKIPPING_COUNT = 'test.itr.tests_skipping.count'
|
|
57
60
|
const TEST_CODE_COVERAGE_ENABLED = 'test.code_coverage.enabled'
|
|
58
61
|
|
|
59
62
|
const TEST_CODE_COVERAGE_LINES_PCT = 'test.code_coverage.lines_pct'
|
|
@@ -80,6 +83,7 @@ module.exports = {
|
|
|
80
83
|
JEST_WORKER_TRACE_PAYLOAD_CODE,
|
|
81
84
|
JEST_WORKER_COVERAGE_PAYLOAD_CODE,
|
|
82
85
|
TEST_SOURCE_START,
|
|
86
|
+
TEST_SKIPPED_BY_ITR,
|
|
83
87
|
getTestEnvironmentMetadata,
|
|
84
88
|
getTestParametersString,
|
|
85
89
|
finishAllTraceSpans,
|
|
@@ -99,6 +103,8 @@ module.exports = {
|
|
|
99
103
|
TEST_ITR_TESTS_SKIPPED,
|
|
100
104
|
TEST_MODULE,
|
|
101
105
|
TEST_ITR_SKIPPING_ENABLED,
|
|
106
|
+
TEST_ITR_SKIPPING_TYPE,
|
|
107
|
+
TEST_ITR_SKIPPING_COUNT,
|
|
102
108
|
TEST_CODE_COVERAGE_ENABLED,
|
|
103
109
|
TEST_CODE_COVERAGE_LINES_PCT,
|
|
104
110
|
addIntelligentTestRunnerSpanTags,
|
|
@@ -354,14 +360,25 @@ function getTestSuiteCommonTags (command, testFrameworkVersion, testSuite, testF
|
|
|
354
360
|
function addIntelligentTestRunnerSpanTags (
|
|
355
361
|
testSessionSpan,
|
|
356
362
|
testModuleSpan,
|
|
357
|
-
{
|
|
363
|
+
{
|
|
364
|
+
isSuitesSkipped,
|
|
365
|
+
isSuitesSkippingEnabled,
|
|
366
|
+
isCodeCoverageEnabled,
|
|
367
|
+
testCodeCoverageLinesTotal,
|
|
368
|
+
skippingCount,
|
|
369
|
+
skippingType = 'suite'
|
|
370
|
+
}
|
|
358
371
|
) {
|
|
359
372
|
testSessionSpan.setTag(TEST_ITR_TESTS_SKIPPED, isSuitesSkipped ? 'true' : 'false')
|
|
360
373
|
testSessionSpan.setTag(TEST_ITR_SKIPPING_ENABLED, isSuitesSkippingEnabled ? 'true' : 'false')
|
|
374
|
+
testSessionSpan.setTag(TEST_ITR_SKIPPING_TYPE, skippingType)
|
|
375
|
+
testSessionSpan.setTag(TEST_ITR_SKIPPING_COUNT, skippingCount)
|
|
361
376
|
testSessionSpan.setTag(TEST_CODE_COVERAGE_ENABLED, isCodeCoverageEnabled ? 'true' : 'false')
|
|
362
377
|
|
|
363
378
|
testModuleSpan.setTag(TEST_ITR_TESTS_SKIPPED, isSuitesSkipped ? 'true' : 'false')
|
|
364
379
|
testModuleSpan.setTag(TEST_ITR_SKIPPING_ENABLED, isSuitesSkippingEnabled ? 'true' : 'false')
|
|
380
|
+
testModuleSpan.setTag(TEST_ITR_SKIPPING_TYPE, skippingType)
|
|
381
|
+
testModuleSpan.setTag(TEST_ITR_SKIPPING_COUNT, skippingCount)
|
|
365
382
|
testModuleSpan.setTag(TEST_CODE_COVERAGE_ENABLED, isCodeCoverageEnabled ? 'true' : 'false')
|
|
366
383
|
|
|
367
384
|
// If suites have been skipped we don't want to report the total coverage, as it will be wrong
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const { storage } = require('../../../../datadog-core')
|
|
4
4
|
|
|
5
5
|
const dc = require('../../../../diagnostics_channel')
|
|
6
|
+
const { HTTP_METHOD, HTTP_ROUTE, RESOURCE_NAME, SPAN_TYPE } = require('../../../../../ext/tags')
|
|
7
|
+
const { WEB } = require('../../../../../ext/types')
|
|
6
8
|
|
|
7
9
|
const beforeCh = dc.channel('dd-trace:storage:before')
|
|
8
10
|
const enterCh = dc.channel('dd-trace:storage:enter')
|
|
@@ -41,13 +43,13 @@ function getSpanContextTags (span) {
|
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
function isWebServerSpan (tags) {
|
|
44
|
-
return tags[
|
|
46
|
+
return tags[SPAN_TYPE] === WEB
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
function endpointNameFromTags (tags) {
|
|
48
|
-
return tags[
|
|
49
|
-
tags[
|
|
50
|
-
tags[
|
|
50
|
+
return tags[RESOURCE_NAME] || [
|
|
51
|
+
tags[HTTP_METHOD],
|
|
52
|
+
tags[HTTP_ROUTE]
|
|
51
53
|
].filter(v => v).join(' ')
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -99,7 +101,7 @@ class NativeWallProfiler {
|
|
|
99
101
|
|
|
100
102
|
if (this._codeHotspotsEnabled && !this._emittedFFMessage && this._logger) {
|
|
101
103
|
this._logger.debug(
|
|
102
|
-
`Wall profiler: Enable
|
|
104
|
+
`Wall profiler: Enable trace_show_breakdown_profiling_for_node feature flag to see code hotspots.`)
|
|
103
105
|
this._emittedFFMessage = true
|
|
104
106
|
}
|
|
105
107
|
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
const NoopProxy = require('./noop/proxy')
|
|
3
3
|
const DatadogTracer = require('./tracer')
|
|
4
4
|
const Config = require('./config')
|
|
5
|
-
const
|
|
5
|
+
const runtimeMetrics = require('./runtime_metrics')
|
|
6
6
|
const log = require('./log')
|
|
7
7
|
const { setStartupLogPluginManager } = require('./startup-log')
|
|
8
8
|
const telemetry = require('./telemetry')
|
|
9
9
|
const PluginManager = require('./plugin_manager')
|
|
10
10
|
const remoteConfig = require('./appsec/remote_config')
|
|
11
11
|
const AppsecSdk = require('./appsec/sdk')
|
|
12
|
+
const dogstatsd = require('./dogstatsd')
|
|
12
13
|
|
|
13
14
|
class Tracer extends NoopProxy {
|
|
14
15
|
constructor () {
|
|
@@ -16,6 +17,7 @@ class Tracer extends NoopProxy {
|
|
|
16
17
|
|
|
17
18
|
this._initialized = false
|
|
18
19
|
this._pluginManager = new PluginManager(this)
|
|
20
|
+
this.dogstatsd = new dogstatsd.NoopDogStatsDClient()
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
init (options) {
|
|
@@ -26,6 +28,25 @@ class Tracer extends NoopProxy {
|
|
|
26
28
|
try {
|
|
27
29
|
const config = new Config(options) // TODO: support dynamic code config
|
|
28
30
|
|
|
31
|
+
if (config.dogstatsd) {
|
|
32
|
+
// Custom Metrics
|
|
33
|
+
this.dogstatsd = new dogstatsd.CustomMetrics({
|
|
34
|
+
host: config.dogstatsd.hostname,
|
|
35
|
+
port: config.dogstatsd.port,
|
|
36
|
+
tags: [
|
|
37
|
+
// these are the Runtime Metrics default tags
|
|
38
|
+
// Python also uses these as default Custom Metrics tags
|
|
39
|
+
`service:${config.tags.service}`,
|
|
40
|
+
`env:${config.tags.env}`,
|
|
41
|
+
`version:${config.tags.version}`
|
|
42
|
+
]
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
setInterval(() => {
|
|
46
|
+
this.dogstatsd.flush()
|
|
47
|
+
}, 10 * 1000).unref()
|
|
48
|
+
}
|
|
49
|
+
|
|
29
50
|
if (config.remoteConfig.enabled && !config.isCiVisibility) {
|
|
30
51
|
const rc = remoteConfig.enable(config)
|
|
31
52
|
|
|
@@ -58,7 +79,7 @@ class Tracer extends NoopProxy {
|
|
|
58
79
|
}
|
|
59
80
|
|
|
60
81
|
if (config.runtimeMetrics) {
|
|
61
|
-
|
|
82
|
+
runtimeMetrics.start(config)
|
|
62
83
|
}
|
|
63
84
|
|
|
64
85
|
if (config.tracing) {
|
|
@@ -117,8 +117,16 @@ function Hook (modules, options, onrequire) {
|
|
|
117
117
|
// abort if _resolveLookupPaths return null
|
|
118
118
|
return exports
|
|
119
119
|
}
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
|
|
121
|
+
let res
|
|
122
|
+
try {
|
|
123
|
+
res = Module._findPath(name, [basedir, ...paths])
|
|
124
|
+
} catch (e) {
|
|
125
|
+
// case where the file specified in package.json "main" doesn't exist
|
|
126
|
+
// in this case, the file is treated as module-internal
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!res || res !== filename) {
|
|
122
130
|
// this is a module-internal file
|
|
123
131
|
// use the module-relative path to the file, prefixed by original module name
|
|
124
132
|
name = name + path.sep + path.relative(basedir, filename)
|
|
File without changes
|