dd-trace 5.57.1 → 5.59.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 -1
- package/ci/cypress/after-run.js +2 -0
- package/ci/cypress/after-spec.js +2 -0
- package/ci/cypress/plugin.js +2 -0
- package/ci/cypress/polyfills.js +2 -0
- package/ci/cypress/support.js +2 -0
- package/ci/init.js +2 -0
- package/index.d.ts +7 -0
- package/init.js +1 -6
- package/initialize.mjs +2 -0
- package/package.json +40 -9
- package/packages/datadog-code-origin/index.js +14 -9
- package/packages/datadog-instrumentations/src/apollo.js +7 -10
- package/packages/datadog-instrumentations/src/avsc.js +2 -0
- package/packages/datadog-instrumentations/src/azure-functions.js +1 -1
- package/packages/datadog-instrumentations/src/child_process.js +22 -43
- package/packages/datadog-instrumentations/src/cucumber.js +10 -8
- package/packages/datadog-instrumentations/src/cypress.js +2 -0
- package/packages/datadog-instrumentations/src/fastify.js +19 -1
- package/packages/datadog-instrumentations/src/graphql.js +9 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/helpers/register.js +2 -2
- package/packages/datadog-instrumentations/src/hono.js +102 -0
- package/packages/datadog-instrumentations/src/jest.js +1 -1
- package/packages/datadog-instrumentations/src/langchain.js +21 -0
- package/packages/datadog-instrumentations/src/mocha/common.js +2 -0
- package/packages/datadog-instrumentations/src/mocha.js +2 -0
- package/packages/datadog-instrumentations/src/mysql2.js +6 -6
- package/packages/datadog-instrumentations/src/next.js +3 -1
- package/packages/datadog-instrumentations/src/nyc.js +2 -0
- package/packages/datadog-instrumentations/src/oracledb.js +24 -2
- package/packages/datadog-instrumentations/src/orchestrion-config/index.js +32 -0
- package/packages/datadog-instrumentations/src/playwright.js +5 -1
- package/packages/datadog-instrumentations/src/protobufjs.js +2 -0
- package/packages/datadog-instrumentations/src/selenium.js +2 -0
- package/packages/datadog-instrumentations/src/tedious.js +12 -17
- package/packages/datadog-instrumentations/src/vitest.js +2 -0
- package/packages/datadog-plugin-avsc/src/index.js +2 -0
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +51 -1
- package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +2 -0
- package/packages/datadog-plugin-child_process/src/index.js +30 -10
- package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +1 -1
- package/packages/datadog-plugin-cypress/src/after-run.js +2 -0
- package/packages/datadog-plugin-cypress/src/after-spec.js +2 -0
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +8 -3
- package/packages/datadog-plugin-cypress/src/index.js +2 -0
- package/packages/datadog-plugin-cypress/src/plugin.js +2 -0
- package/packages/datadog-plugin-cypress/src/support.js +21 -25
- package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +2 -0
- package/packages/datadog-plugin-graphql/src/tools/index.js +0 -2
- package/packages/datadog-plugin-graphql/src/tools/signature.js +0 -2
- package/packages/datadog-plugin-graphql/src/tools/transforms.js +0 -2
- package/packages/datadog-plugin-graphql/src/utils.js +2 -0
- package/packages/datadog-plugin-hono/src/index.js +28 -0
- package/packages/datadog-plugin-http/src/client.js +3 -4
- package/packages/datadog-plugin-http2/src/client.js +9 -8
- package/packages/datadog-plugin-jest/src/index.js +2 -0
- package/packages/datadog-plugin-jest/src/util.js +2 -0
- package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -0
- package/packages/datadog-plugin-langchain/src/handlers/chain.js +1 -1
- package/packages/datadog-plugin-langchain/src/handlers/language_models/chat_model.js +1 -1
- package/packages/datadog-plugin-langchain/src/handlers/language_models/llm.js +1 -1
- package/packages/datadog-plugin-langchain/src/tracing.js +36 -4
- package/packages/datadog-plugin-nyc/src/index.js +2 -0
- package/packages/datadog-plugin-oracledb/src/connection-parser.js +37 -0
- package/packages/datadog-plugin-oracledb/src/index.js +15 -17
- package/packages/datadog-plugin-protobufjs/src/index.js +2 -0
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -0
- package/packages/datadog-plugin-selenium/src/index.js +2 -0
- package/packages/datadog-plugin-tedious/src/index.js +10 -9
- package/packages/datadog-plugin-vitest/src/index.js +2 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +6 -4
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +9 -0
- package/packages/dd-trace/src/appsec/iast/iast-context.js +5 -1
- package/packages/dd-trace/src/appsec/iast/index.js +2 -0
- package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +5 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +0 -2
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/index.js +1 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
- package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +18 -11
- package/packages/dd-trace/src/appsec/rasp/utils.js +1 -1
- package/packages/dd-trace/src/appsec/recommended.json +88 -2
- package/packages/dd-trace/src/appsec/reporter.js +68 -14
- package/packages/dd-trace/src/appsec/rule_manager.js +63 -171
- package/packages/dd-trace/src/appsec/sdk/track_event.js +3 -5
- package/packages/dd-trace/src/appsec/stack_trace.js +11 -11
- package/packages/dd-trace/src/appsec/telemetry/common.js +2 -2
- package/packages/dd-trace/src/appsec/telemetry/index.js +8 -0
- package/packages/dd-trace/src/appsec/telemetry/waf.js +5 -3
- package/packages/dd-trace/src/appsec/waf/diagnostics.js +15 -0
- package/packages/dd-trace/src/appsec/waf/index.js +47 -6
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +22 -12
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +3 -3
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -0
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -1
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -0
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -0
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -0
- package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -0
- package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +2 -0
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +7 -3
- package/packages/dd-trace/src/config.js +15 -4
- package/packages/dd-trace/src/config_stable.js +2 -0
- package/packages/dd-trace/src/constants.js +1 -2
- package/packages/dd-trace/src/datastreams/checkpointer.js +2 -0
- package/packages/dd-trace/src/datastreams/context.js +2 -0
- package/packages/dd-trace/src/datastreams/encoding.js +2 -0
- package/packages/dd-trace/src/datastreams/fnv.js +2 -0
- package/packages/dd-trace/src/datastreams/pathway.js +11 -9
- package/packages/dd-trace/src/datastreams/processor.js +8 -7
- package/packages/dd-trace/src/datastreams/schemas/schema.js +2 -0
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +45 -36
- package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +2 -0
- package/packages/dd-trace/src/datastreams/writer.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/index.js +12 -4
- package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
- package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +8 -5
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
- package/packages/dd-trace/src/debugger/index.js +36 -9
- package/packages/dd-trace/src/encode/tags-processors.js +2 -0
- package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -0
- package/packages/dd-trace/src/exporters/common/request.js +1 -1
- package/packages/dd-trace/src/exporters/common/util.js +2 -0
- package/packages/dd-trace/src/exporters/span-stats/index.js +2 -0
- package/packages/dd-trace/src/exporters/span-stats/writer.js +2 -0
- package/packages/dd-trace/src/external-logger/src/index.js +2 -0
- package/packages/dd-trace/src/git_metadata_tagger.js +2 -0
- package/packages/dd-trace/src/git_properties.js +2 -0
- package/packages/dd-trace/src/guardrails/index.js +3 -4
- package/packages/dd-trace/src/guardrails/log.js +2 -2
- package/packages/dd-trace/src/guardrails/telemetry.js +16 -14
- package/packages/dd-trace/src/guardrails/util.js +0 -2
- package/packages/dd-trace/src/heap_snapshots.js +58 -0
- package/packages/dd-trace/src/llmobs/noop.js +1 -1
- package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +2 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
- package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +47 -4
- package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
- package/packages/dd-trace/src/llmobs/tagger.js +10 -1
- package/packages/dd-trace/src/log/log.js +1 -1
- package/packages/dd-trace/src/noop/dogstatsd.js +2 -0
- package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
- package/packages/dd-trace/src/opentracing/span.js +1 -1
- package/packages/dd-trace/src/payload-tagging/config/index.js +2 -0
- package/packages/dd-trace/src/payload-tagging/index.js +3 -1
- package/packages/dd-trace/src/payload-tagging/tagging.js +4 -2
- package/packages/dd-trace/src/plugins/apollo.js +2 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +8 -3
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/outbound.js +7 -0
- package/packages/dd-trace/src/plugins/util/ci.js +2 -0
- package/packages/dd-trace/src/plugins/util/env.js +2 -0
- package/packages/dd-trace/src/plugins/util/git.js +40 -5
- package/packages/dd-trace/src/plugins/util/inferred_proxy.js +2 -0
- package/packages/dd-trace/src/plugins/util/llm.js +2 -0
- package/packages/dd-trace/src/plugins/util/serverless.js +2 -0
- package/packages/dd-trace/src/plugins/util/stacktrace.js +178 -50
- package/packages/dd-trace/src/plugins/util/tags.js +17 -1
- package/packages/dd-trace/src/plugins/util/test.js +9 -4
- package/packages/dd-trace/src/plugins/util/url.js +2 -0
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -0
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +4 -0
- package/packages/dd-trace/src/profiling/profiler.js +89 -70
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/events.js +2 -0
- package/packages/dd-trace/src/profiling/profilers/wall.js +2 -2
- package/packages/dd-trace/src/profiling/webspan-utils.js +2 -0
- package/packages/dd-trace/src/proxy.js +4 -0
- package/packages/dd-trace/src/remote_config/capabilities.js +3 -1
- package/packages/dd-trace/src/remote_config/index.js +4 -0
- package/packages/dd-trace/src/service-naming/index.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/definition.js +4 -9
- package/packages/dd-trace/src/service-naming/schemas/util.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +2 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -1
- package/packages/dd-trace/src/service-naming/schemas/v1/web.js +2 -0
- package/packages/dd-trace/src/span_stats.js +2 -0
- package/packages/dd-trace/src/supported-configurations.json +5 -0
- package/packages/dd-trace/src/telemetry/send-data.js +2 -0
- package/register.js +4 -0
- package/version.js +0 -3
- package/packages/dd-trace/src/payload-tagging/jsonpath-plus.js +0 -2094
|
@@ -42,15 +42,20 @@ function findWebSpan (startedSpans, spanId) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
class Profiler extends EventEmitter {
|
|
45
|
+
#compressionFn
|
|
46
|
+
#compressionOptions
|
|
47
|
+
#enabled = false
|
|
48
|
+
#endpointCounts = new Map()
|
|
49
|
+
#lastStart
|
|
50
|
+
#logger
|
|
51
|
+
#profileSeq = 0
|
|
52
|
+
#spanFinishListener
|
|
53
|
+
#timer
|
|
54
|
+
|
|
45
55
|
constructor () {
|
|
46
56
|
super()
|
|
47
|
-
this._enabled = false
|
|
48
|
-
this._logger = undefined
|
|
49
57
|
this._config = undefined
|
|
50
|
-
this._timer = undefined
|
|
51
|
-
this._lastStart = undefined
|
|
52
58
|
this._timeoutInterval = undefined
|
|
53
|
-
this.endpointCounts = new Map()
|
|
54
59
|
}
|
|
55
60
|
|
|
56
61
|
start (options) {
|
|
@@ -61,17 +66,21 @@ class Profiler extends EventEmitter {
|
|
|
61
66
|
})
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
get enabled () {
|
|
70
|
+
return this.#enabled
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#logError (err) {
|
|
74
|
+
logError(this.#logger, err)
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
async _start (options) {
|
|
69
|
-
if (this.
|
|
78
|
+
if (this.enabled) return true
|
|
70
79
|
|
|
71
80
|
const config = this._config = new Config(options)
|
|
72
81
|
|
|
73
|
-
this
|
|
74
|
-
this
|
|
82
|
+
this.#logger = config.logger
|
|
83
|
+
this.#enabled = true
|
|
75
84
|
this._setInterval()
|
|
76
85
|
|
|
77
86
|
// Log errors if the source map finder fails, but don't prevent the rest
|
|
@@ -83,7 +92,7 @@ class Profiler extends EventEmitter {
|
|
|
83
92
|
|
|
84
93
|
mapper = await maybeSourceMap(config.sourceMap, SourceMapper, config.debugSourceMaps)
|
|
85
94
|
if (config.sourceMap && config.debugSourceMaps) {
|
|
86
|
-
this.
|
|
95
|
+
this.#logger.debug(() => {
|
|
87
96
|
return mapper.infoMap.size === 0
|
|
88
97
|
? 'Found no source maps'
|
|
89
98
|
: `Found source maps for following files: [${[...mapper.infoMap.keys()].join(', ')}]`
|
|
@@ -93,18 +102,18 @@ class Profiler extends EventEmitter {
|
|
|
93
102
|
const clevel = config.uploadCompression.level
|
|
94
103
|
switch (config.uploadCompression.method) {
|
|
95
104
|
case 'gzip':
|
|
96
|
-
this
|
|
105
|
+
this.#compressionFn = promisify(zlib.gzip)
|
|
97
106
|
if (clevel !== undefined) {
|
|
98
|
-
this
|
|
107
|
+
this.#compressionOptions = {
|
|
99
108
|
level: clevel
|
|
100
109
|
}
|
|
101
110
|
}
|
|
102
111
|
break
|
|
103
112
|
case 'zstd':
|
|
104
113
|
if (typeof zlib.zstdCompress === 'function') {
|
|
105
|
-
this
|
|
114
|
+
this.#compressionFn = promisify(zlib.zstdCompress)
|
|
106
115
|
if (clevel !== undefined) {
|
|
107
|
-
this
|
|
116
|
+
this.#compressionOptions = {
|
|
108
117
|
params: {
|
|
109
118
|
[zlib.constants.ZSTD_c_compressionLevel]: clevel
|
|
110
119
|
}
|
|
@@ -113,43 +122,44 @@ class Profiler extends EventEmitter {
|
|
|
113
122
|
} else {
|
|
114
123
|
const zstdCompress = require('@datadog/libdatadog').load('datadog-js-zstd').zstd_compress
|
|
115
124
|
const level = clevel ?? 0 // 0 is zstd default compression level
|
|
116
|
-
this
|
|
125
|
+
this.#compressionFn = (buffer) => Promise.resolve(Buffer.from(zstdCompress(buffer, level)))
|
|
117
126
|
}
|
|
118
127
|
break
|
|
119
128
|
}
|
|
120
129
|
} catch (err) {
|
|
121
|
-
this
|
|
130
|
+
this.#logError(err)
|
|
122
131
|
}
|
|
123
132
|
|
|
124
133
|
try {
|
|
125
134
|
const start = new Date()
|
|
135
|
+
const nearOOMCallback = this.#nearOOMExport.bind(this)
|
|
126
136
|
for (const profiler of config.profilers) {
|
|
127
137
|
// TODO: move this out of Profiler when restoring sourcemap support
|
|
128
138
|
profiler.start({
|
|
129
139
|
mapper,
|
|
130
|
-
nearOOMCallback
|
|
140
|
+
nearOOMCallback
|
|
131
141
|
})
|
|
132
|
-
this.
|
|
142
|
+
this.#logger.debug(`Started ${profiler.type} profiler in ${threadNamePrefix} thread`)
|
|
133
143
|
}
|
|
134
144
|
|
|
135
145
|
if (config.endpointCollectionEnabled) {
|
|
136
|
-
this
|
|
137
|
-
spanFinishedChannel.subscribe(this
|
|
146
|
+
this.#spanFinishListener = this.#onSpanFinish.bind(this)
|
|
147
|
+
spanFinishedChannel.subscribe(this.#spanFinishListener)
|
|
138
148
|
}
|
|
139
149
|
|
|
140
150
|
this._capture(this._timeoutInterval, start)
|
|
141
151
|
return true
|
|
142
152
|
} catch (e) {
|
|
143
|
-
this
|
|
144
|
-
this
|
|
153
|
+
this.#logError(e)
|
|
154
|
+
this.#stop()
|
|
145
155
|
return false
|
|
146
156
|
}
|
|
147
157
|
}
|
|
148
158
|
|
|
149
|
-
|
|
150
|
-
const start = this
|
|
159
|
+
#nearOOMExport (profileType, encodedProfile) {
|
|
160
|
+
const start = this.#lastStart
|
|
151
161
|
const end = new Date()
|
|
152
|
-
this
|
|
162
|
+
this.#submit({
|
|
153
163
|
[profileType]: encodedProfile
|
|
154
164
|
}, start, end, snapshotKinds.ON_OUT_OF_MEMORY)
|
|
155
165
|
}
|
|
@@ -159,45 +169,45 @@ class Profiler extends EventEmitter {
|
|
|
159
169
|
}
|
|
160
170
|
|
|
161
171
|
stop () {
|
|
162
|
-
if (!this.
|
|
172
|
+
if (!this.enabled) return
|
|
163
173
|
|
|
164
174
|
// collect and export current profiles
|
|
165
175
|
// once collect returns, profilers can be safely stopped
|
|
166
176
|
this._collect(snapshotKinds.ON_SHUTDOWN, false)
|
|
167
|
-
this
|
|
177
|
+
this.#stop()
|
|
168
178
|
}
|
|
169
179
|
|
|
170
|
-
|
|
171
|
-
if (!this.
|
|
180
|
+
#stop () {
|
|
181
|
+
if (!this.enabled) return
|
|
172
182
|
|
|
173
|
-
this
|
|
183
|
+
this.#enabled = false
|
|
174
184
|
|
|
175
|
-
if (this
|
|
176
|
-
spanFinishedChannel.unsubscribe(this
|
|
177
|
-
this
|
|
185
|
+
if (this.#spanFinishListener !== undefined) {
|
|
186
|
+
spanFinishedChannel.unsubscribe(this.#spanFinishListener)
|
|
187
|
+
this.#spanFinishListener = undefined
|
|
178
188
|
}
|
|
179
189
|
|
|
180
190
|
for (const profiler of this._config.profilers) {
|
|
181
191
|
profiler.stop()
|
|
182
|
-
this.
|
|
192
|
+
this.#logger.debug(`Stopped ${profiler.type} profiler in ${threadNamePrefix} thread`)
|
|
183
193
|
}
|
|
184
194
|
|
|
185
|
-
clearTimeout(this
|
|
186
|
-
this
|
|
195
|
+
clearTimeout(this.#timer)
|
|
196
|
+
this.#timer = undefined
|
|
187
197
|
}
|
|
188
198
|
|
|
189
199
|
_capture (timeout, start) {
|
|
190
|
-
if (!this.
|
|
191
|
-
this
|
|
192
|
-
if (!this
|
|
193
|
-
this
|
|
194
|
-
this.
|
|
200
|
+
if (!this.enabled) return
|
|
201
|
+
this.#lastStart = start
|
|
202
|
+
if (!this.#timer || timeout !== this._timeoutInterval) {
|
|
203
|
+
this.#timer = setTimeout(() => this._collect(snapshotKinds.PERIODIC), timeout)
|
|
204
|
+
this.#timer.unref()
|
|
195
205
|
} else {
|
|
196
|
-
this.
|
|
206
|
+
this.#timer.refresh()
|
|
197
207
|
}
|
|
198
208
|
}
|
|
199
209
|
|
|
200
|
-
|
|
210
|
+
#onSpanFinish (span) {
|
|
201
211
|
const context = span.context()
|
|
202
212
|
const tags = context._tags
|
|
203
213
|
if (!isWebServerSpan(tags)) return
|
|
@@ -208,19 +218,19 @@ class Profiler extends EventEmitter {
|
|
|
208
218
|
// Make sure this is the outermost web span, just in case so we don't overcount
|
|
209
219
|
if (findWebSpan(getStartedSpans(context), context._parentId)) return
|
|
210
220
|
|
|
211
|
-
let counter = this
|
|
221
|
+
let counter = this.#endpointCounts.get(endpointName)
|
|
212
222
|
if (counter === undefined) {
|
|
213
223
|
counter = { count: 1 }
|
|
214
|
-
this
|
|
224
|
+
this.#endpointCounts.set(endpointName, counter)
|
|
215
225
|
} else {
|
|
216
226
|
counter.count++
|
|
217
227
|
}
|
|
218
228
|
}
|
|
219
229
|
|
|
220
230
|
async _collect (snapshotKind, restart = true) {
|
|
221
|
-
if (!this.
|
|
231
|
+
if (!this.enabled) return
|
|
222
232
|
|
|
223
|
-
const startDate = this
|
|
233
|
+
const startDate = this.#lastStart
|
|
224
234
|
const endDate = new Date()
|
|
225
235
|
const profiles = []
|
|
226
236
|
const encodedProfiles = {}
|
|
@@ -235,7 +245,7 @@ class Profiler extends EventEmitter {
|
|
|
235
245
|
for (const profiler of this._config.profilers) {
|
|
236
246
|
const profile = profiler.profile(restart, startDate, endDate)
|
|
237
247
|
if (!restart) {
|
|
238
|
-
this.
|
|
248
|
+
this.#logger.debug(`Stopped ${profiler.type} profiler in ${threadNamePrefix} thread`)
|
|
239
249
|
}
|
|
240
250
|
if (!profile) continue
|
|
241
251
|
profiles.push({ profiler, profile })
|
|
@@ -252,11 +262,11 @@ class Profiler extends EventEmitter {
|
|
|
252
262
|
await Promise.all(profiles.map(async ({ profiler, profile }) => {
|
|
253
263
|
try {
|
|
254
264
|
const encoded = await profiler.encode(profile)
|
|
255
|
-
const compressed = encoded instanceof Buffer && this
|
|
256
|
-
? await this
|
|
265
|
+
const compressed = encoded instanceof Buffer && this.#compressionFn !== undefined
|
|
266
|
+
? await this.#compressionFn(encoded, this.#compressionOptions)
|
|
257
267
|
: encoded
|
|
258
268
|
encodedProfiles[profiler.type] = compressed
|
|
259
|
-
this.
|
|
269
|
+
this.#logger.debug(() => {
|
|
260
270
|
const profileJson = JSON.stringify(profile, (key, value) => {
|
|
261
271
|
return typeof value === 'bigint' ? value.toString() : value
|
|
262
272
|
})
|
|
@@ -266,37 +276,38 @@ class Profiler extends EventEmitter {
|
|
|
266
276
|
} catch (err) {
|
|
267
277
|
// If encoding one of the profile types fails, we should still try to
|
|
268
278
|
// encode and submit the other profile types.
|
|
269
|
-
this
|
|
279
|
+
this.#logError(err)
|
|
270
280
|
}
|
|
271
281
|
}))
|
|
272
282
|
|
|
273
283
|
if (hasEncoded) {
|
|
274
|
-
await this
|
|
284
|
+
await this.#submit(encodedProfiles, startDate, endDate, snapshotKind)
|
|
275
285
|
profileSubmittedChannel.publish()
|
|
276
|
-
this.
|
|
286
|
+
this.#logger.debug('Submitted profiles')
|
|
277
287
|
}
|
|
278
288
|
} catch (err) {
|
|
279
|
-
this
|
|
280
|
-
this
|
|
289
|
+
this.#logError(err)
|
|
290
|
+
this.#stop()
|
|
281
291
|
}
|
|
282
292
|
}
|
|
283
293
|
|
|
284
|
-
|
|
294
|
+
#submit (profiles, start, end, snapshotKind) {
|
|
285
295
|
const { tags } = this._config
|
|
286
296
|
|
|
287
297
|
// Flatten endpoint counts
|
|
288
298
|
const endpointCounts = {}
|
|
289
|
-
for (const [endpoint, { count }] of this
|
|
299
|
+
for (const [endpoint, { count }] of this.#endpointCounts) {
|
|
290
300
|
endpointCounts[endpoint] = count
|
|
291
301
|
}
|
|
292
|
-
this
|
|
302
|
+
this.#endpointCounts.clear()
|
|
293
303
|
|
|
294
304
|
tags.snapshot = snapshotKind
|
|
305
|
+
tags.profile_seq = this.#profileSeq++
|
|
295
306
|
const exportSpec = { profiles, start, end, tags, endpointCounts }
|
|
296
307
|
const tasks = this._config.exporters.map(exporter =>
|
|
297
308
|
exporter.export(exportSpec).catch(err => {
|
|
298
|
-
if (this
|
|
299
|
-
this.
|
|
309
|
+
if (this.#logger) {
|
|
310
|
+
this.#logger.warn(err)
|
|
300
311
|
}
|
|
301
312
|
})
|
|
302
313
|
)
|
|
@@ -306,24 +317,32 @@ class Profiler extends EventEmitter {
|
|
|
306
317
|
}
|
|
307
318
|
|
|
308
319
|
class ServerlessProfiler extends Profiler {
|
|
320
|
+
#profiledIntervals = 0
|
|
321
|
+
#interval = 1 // seconds
|
|
322
|
+
#flushAfterIntervals
|
|
323
|
+
|
|
309
324
|
constructor () {
|
|
310
325
|
super()
|
|
311
|
-
this
|
|
312
|
-
this
|
|
313
|
-
this
|
|
326
|
+
this.#profiledIntervals = 0
|
|
327
|
+
this.#interval = 1
|
|
328
|
+
this.#flushAfterIntervals = undefined
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
get profiledIntervals () {
|
|
332
|
+
return this.#profiledIntervals
|
|
314
333
|
}
|
|
315
334
|
|
|
316
335
|
_setInterval () {
|
|
317
|
-
this._timeoutInterval = this
|
|
318
|
-
this
|
|
336
|
+
this._timeoutInterval = this.#interval * 1000
|
|
337
|
+
this.#flushAfterIntervals = this._config.flushInterval / 1000
|
|
319
338
|
}
|
|
320
339
|
|
|
321
340
|
async _collect (snapshotKind, restart = true) {
|
|
322
|
-
if (this
|
|
323
|
-
this
|
|
341
|
+
if (this.#profiledIntervals >= this.#flushAfterIntervals || !restart) {
|
|
342
|
+
this.#profiledIntervals = 0
|
|
324
343
|
await super._collect(snapshotKind, restart)
|
|
325
344
|
} else {
|
|
326
|
-
this
|
|
345
|
+
this.#profiledIntervals += 1
|
|
327
346
|
this._capture(this._timeoutInterval, new Date())
|
|
328
347
|
// Don't submit profile until 65 (flushAfterIntervals) intervals have elapsed
|
|
329
348
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
const { performance, constants, PerformanceObserver } = require('perf_hooks')
|
|
2
4
|
const { END_TIMESTAMP_LABEL, SPAN_ID_LABEL, LOCAL_ROOT_SPAN_ID_LABEL, encodeProfileAsync } = require('./shared')
|
|
3
5
|
const { Function, Label, Line, Location, Profile, Sample, StringTable, ValueType } = require('pprof-format')
|
|
@@ -213,10 +213,10 @@ class NativeWallProfiler {
|
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
_updateContext (context) {
|
|
216
|
-
if (typeof context.spanId === 'object') {
|
|
216
|
+
if (context.spanId !== null && typeof context.spanId === 'object') {
|
|
217
217
|
context.spanId = context.spanId.toString(10)
|
|
218
218
|
}
|
|
219
|
-
if (typeof context.rootSpanId === 'object') {
|
|
219
|
+
if (context.rootSpanId !== null && typeof context.rootSpanId === 'object') {
|
|
220
220
|
context.rootSpanId = context.rootSpanId.toString(10)
|
|
221
221
|
}
|
|
222
222
|
if (context.webTags !== undefined && context.endpoint === undefined) {
|
|
@@ -100,6 +100,10 @@ class Tracer extends NoopProxy {
|
|
|
100
100
|
require('./crashtracking').start(config)
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
if (config.heapSnapshot.count > 0) {
|
|
104
|
+
require('./heap_snapshots').start(config)
|
|
105
|
+
}
|
|
106
|
+
|
|
103
107
|
telemetry.start(config, this._pluginManager)
|
|
104
108
|
|
|
105
109
|
if (config.dogstatsd) {
|
|
@@ -16,6 +16,7 @@ module.exports = {
|
|
|
16
16
|
APM_TRACING_LOGS_INJECTION: 1n << 13n,
|
|
17
17
|
APM_TRACING_HTTP_HEADER_TAGS: 1n << 14n,
|
|
18
18
|
APM_TRACING_CUSTOM_TAGS: 1n << 15n,
|
|
19
|
+
ASM_EXCLUSION_DATA: 1n << 18n,
|
|
19
20
|
APM_TRACING_ENABLED: 1n << 19n,
|
|
20
21
|
ASM_RASP_SQLI: 1n << 21n,
|
|
21
22
|
ASM_RASP_LFI: 1n << 22n,
|
|
@@ -27,5 +28,6 @@ module.exports = {
|
|
|
27
28
|
ASM_SESSION_FINGERPRINT: 1n << 33n,
|
|
28
29
|
ASM_NETWORK_FINGERPRINT: 1n << 34n,
|
|
29
30
|
ASM_HEADER_FINGERPRINT: 1n << 35n,
|
|
30
|
-
ASM_RASP_CMDI: 1n << 37n
|
|
31
|
+
ASM_RASP_CMDI: 1n << 37n,
|
|
32
|
+
ASM_DD_MULTICONFIG: 1n << 42n
|
|
31
33
|
}
|
|
@@ -89,10 +89,12 @@ function enableWafUpdate (appsecConfig) {
|
|
|
89
89
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_CUSTOM_RULES, true)
|
|
90
90
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_CUSTOM_BLOCKING_RESPONSE, true)
|
|
91
91
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_TRUSTED_IPS, true)
|
|
92
|
+
rc.updateCapabilities(RemoteConfigCapabilities.ASM_EXCLUSION_DATA, true)
|
|
92
93
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_ENDPOINT_FINGERPRINT, true)
|
|
93
94
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_SESSION_FINGERPRINT, true)
|
|
94
95
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_NETWORK_FINGERPRINT, true)
|
|
95
96
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_HEADER_FINGERPRINT, true)
|
|
97
|
+
rc.updateCapabilities(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, true)
|
|
96
98
|
|
|
97
99
|
if (appsecConfig.rasp?.enabled) {
|
|
98
100
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_RASP_SQLI, true)
|
|
@@ -124,10 +126,12 @@ function disableWafUpdate () {
|
|
|
124
126
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_CUSTOM_RULES, false)
|
|
125
127
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_CUSTOM_BLOCKING_RESPONSE, false)
|
|
126
128
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_TRUSTED_IPS, false)
|
|
129
|
+
rc.updateCapabilities(RemoteConfigCapabilities.ASM_EXCLUSION_DATA, false)
|
|
127
130
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_ENDPOINT_FINGERPRINT, false)
|
|
128
131
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_SESSION_FINGERPRINT, false)
|
|
129
132
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_NETWORK_FINGERPRINT, false)
|
|
130
133
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_HEADER_FINGERPRINT, false)
|
|
134
|
+
rc.updateCapabilities(RemoteConfigCapabilities.ASM_DD_MULTICONFIG, false)
|
|
131
135
|
|
|
132
136
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_RASP_SQLI, false)
|
|
133
137
|
rc.updateCapabilities(RemoteConfigCapabilities.ASM_RASP_SSRF, false)
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
class SchemaDefinition {
|
|
2
4
|
constructor (schema) {
|
|
3
5
|
this.schema = schema
|
|
4
6
|
}
|
|
5
7
|
|
|
6
|
-
getSchemaItem (type, kind, plugin) {
|
|
7
|
-
const schema = this.schema
|
|
8
|
-
if (schema && schema[type] && schema[type][kind] && schema[type][kind][plugin]) {
|
|
9
|
-
return schema[type][kind][plugin]
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
8
|
getOpName (type, kind, plugin, opts) {
|
|
14
|
-
const item = this.
|
|
9
|
+
const item = this.schema[type][kind][plugin]
|
|
15
10
|
return item.opName(opts)
|
|
16
11
|
}
|
|
17
12
|
|
|
18
13
|
getServiceName (type, kind, plugin, opts) {
|
|
19
|
-
const item = this.
|
|
14
|
+
const item = this.schema[type][kind][plugin]
|
|
20
15
|
return item.serviceName(opts)
|
|
21
16
|
}
|
|
22
17
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
1
3
|
function configWithFallback ({ tracerService, pluginConfig }) {
|
|
2
4
|
return pluginConfig.service || tracerService
|
|
3
5
|
}
|
|
@@ -14,7 +16,8 @@ const mySQLNaming = {
|
|
|
14
16
|
|
|
15
17
|
function withFunction ({ tracerService, pluginConfig, params }) {
|
|
16
18
|
if (typeof pluginConfig.service === 'function') {
|
|
17
|
-
|
|
19
|
+
const result = pluginConfig.service(params)
|
|
20
|
+
return typeof result === 'string' && result.length > 0 ? result : tracerService
|
|
18
21
|
}
|
|
19
22
|
return configWithFallback({ tracerService, pluginConfig })
|
|
20
23
|
}
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"DD_DOGSTATSD_HOST": ["A"],
|
|
57
57
|
"DD_DOGSTATSD_PORT": ["A"],
|
|
58
58
|
"DD_DYNAMIC_INSTRUMENTATION_ENABLED": ["A"],
|
|
59
|
+
"DD_DYNAMIC_INSTRUMENTATION_PROBE_FILE": ["A"],
|
|
59
60
|
"DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS": ["A"],
|
|
60
61
|
"DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS": ["A"],
|
|
61
62
|
"DD_DYNAMIC_INSTRUMENTATION_UPLOAD_INTERVAL_SECONDS": ["A"],
|
|
@@ -78,6 +79,9 @@
|
|
|
78
79
|
"DD_GIT_PULL_REQUEST_BASE_BRANCH_SHA": ["A"],
|
|
79
80
|
"DD_GRPC_CLIENT_ERROR_STATUSES": ["A"],
|
|
80
81
|
"DD_GRPC_SERVER_ERROR_STATUSES": ["A"],
|
|
82
|
+
"DD_HEAP_SNAPSHOT_COUNT": ["A"],
|
|
83
|
+
"DD_HEAP_SNAPSHOT_INTERVAL": ["A"],
|
|
84
|
+
"DD_HEAP_SNAPSHOT_DESTINATION": ["A"],
|
|
81
85
|
"DD_IAST_DB_ROWS_TO_TAINT": ["A"],
|
|
82
86
|
"DD_IAST_DEDUPLICATION_ENABLED": ["A"],
|
|
83
87
|
"DD_IAST_ENABLED": ["A"],
|
|
@@ -274,6 +278,7 @@
|
|
|
274
278
|
"DD_TRACE_HAPI_ENABLED": ["A"],
|
|
275
279
|
"DD_TRACE_HAPI_HAPI_ENABLED": ["A"],
|
|
276
280
|
"DD_TRACE_HEADER_TAGS": ["A"],
|
|
281
|
+
"DD_TRACE_HONO_ENABLED": ["A"],
|
|
277
282
|
"DD_TRACE_HTTP_ENABLED": ["A"],
|
|
278
283
|
"DD_TRACE_HTTP2_ENABLED": ["A"],
|
|
279
284
|
"DD_TRACE_HTTPS_ENABLED": ["A"],
|