dd-trace 5.54.0 → 5.56.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 +1 -0
- package/ci/cypress/plugin.js +8 -0
- package/ci/cypress/polyfills.js +23 -0
- package/ci/init.js +8 -7
- package/initialize.mjs +2 -2
- package/package.json +10 -9
- package/packages/datadog-code-origin/index.js +22 -4
- package/packages/datadog-core/src/utils/src/kebabcase.js +3 -3
- package/packages/datadog-core/src/utils/src/set.js +8 -10
- package/packages/datadog-instrumentations/src/cassandra-driver.js +5 -6
- package/packages/datadog-instrumentations/src/confluentinc-kafka-javascript.js +2 -3
- package/packages/datadog-instrumentations/src/cookie-parser.js +1 -1
- package/packages/datadog-instrumentations/src/couchbase.js +3 -6
- package/packages/datadog-instrumentations/src/cucumber.js +21 -28
- package/packages/datadog-instrumentations/src/dns.js +4 -4
- package/packages/datadog-instrumentations/src/elasticsearch.js +9 -10
- package/packages/datadog-instrumentations/src/fastify.js +7 -9
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +14 -16
- package/packages/datadog-instrumentations/src/hapi.js +10 -11
- package/packages/datadog-instrumentations/src/helpers/fetch.js +4 -5
- package/packages/datadog-instrumentations/src/helpers/hook.js +1 -2
- package/packages/datadog-instrumentations/src/helpers/register.js +6 -5
- package/packages/datadog-instrumentations/src/jest.js +421 -376
- package/packages/datadog-instrumentations/src/koa.js +2 -3
- package/packages/datadog-instrumentations/src/mariadb.js +11 -4
- package/packages/datadog-instrumentations/src/mocha/main.js +79 -75
- package/packages/datadog-instrumentations/src/mocha.js +3 -1
- package/packages/datadog-instrumentations/src/mysql.js +11 -2
- package/packages/datadog-instrumentations/src/nyc.js +2 -1
- package/packages/datadog-instrumentations/src/openai.js +2 -2
- package/packages/datadog-instrumentations/src/otel-sdk-trace.js +4 -3
- package/packages/datadog-instrumentations/src/pg.js +2 -3
- package/packages/datadog-instrumentations/src/playwright.js +19 -22
- package/packages/datadog-instrumentations/src/protobufjs.js +3 -4
- package/packages/datadog-instrumentations/src/redis.js +1 -1
- package/packages/datadog-instrumentations/src/restify.js +9 -13
- package/packages/datadog-instrumentations/src/router.js +12 -11
- package/packages/datadog-instrumentations/src/tedious.js +1 -2
- package/packages/datadog-instrumentations/src/vitest.js +15 -29
- package/packages/datadog-plugin-avsc/src/schema_iterator.js +12 -12
- package/packages/datadog-plugin-aws-sdk/src/base.js +12 -8
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +12 -20
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +4 -5
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +3 -5
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +1 -2
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +7 -10
- package/packages/datadog-plugin-azure-functions/src/index.js +5 -4
- package/packages/datadog-plugin-cucumber/src/index.js +3 -2
- package/packages/datadog-plugin-cypress/src/cypress-plugin.js +2 -1
- package/packages/datadog-plugin-dd-trace-api/src/index.js +2 -1
- package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
- package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +1 -1
- package/packages/datadog-plugin-graphql/src/index.js +3 -2
- package/packages/datadog-plugin-graphql/src/resolve.js +17 -10
- package/packages/datadog-plugin-http/src/client.js +5 -6
- package/packages/datadog-plugin-http2/src/client.js +7 -8
- package/packages/datadog-plugin-jest/src/index.js +3 -2
- package/packages/datadog-plugin-mocha/src/index.js +6 -1
- package/packages/datadog-plugin-mongodb-core/src/index.js +2 -1
- package/packages/datadog-plugin-mysql/src/index.js +11 -0
- package/packages/datadog-plugin-next/src/index.js +1 -1
- package/packages/datadog-plugin-openai/src/tracing.js +2 -4
- package/packages/datadog-plugin-oracledb/src/index.js +2 -1
- package/packages/datadog-plugin-playwright/src/index.js +3 -2
- package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +8 -9
- package/packages/datadog-plugin-redis/src/index.js +1 -3
- package/packages/datadog-plugin-vitest/src/index.js +5 -4
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-password-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secret-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/hardcoded-secrets-rules.js +0 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/missing-header-analyzer.js +1 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/security-controls/index.js +12 -13
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +44 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +2 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +8 -3
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +1 -1
- package/packages/dd-trace/src/appsec/iast/telemetry/verbosity.js +1 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/range-utils.js +10 -11
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +0 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +0 -1
- package/packages/dd-trace/src/appsec/index.js +16 -5
- package/packages/dd-trace/src/appsec/reporter.js +11 -11
- package/packages/dd-trace/src/appsec/sdk/set_user.js +2 -2
- package/packages/dd-trace/src/appsec/sdk/track_event.js +3 -3
- package/packages/dd-trace/src/appsec/telemetry/index.js +31 -1
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +6 -2
- package/packages/dd-trace/src/azure_metadata.js +8 -3
- package/packages/dd-trace/src/baggage.js +2 -2
- package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +8 -7
- package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -1
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +4 -3
- package/packages/dd-trace/src/ci-visibility/exporters/test-worker/index.js +7 -6
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -1
- package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +4 -3
- package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +4 -3
- package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +2 -1
- package/packages/dd-trace/src/config-helper.js +89 -0
- package/packages/dd-trace/src/config.js +120 -115
- package/packages/dd-trace/src/config_stable.js +7 -4
- package/packages/dd-trace/src/datastreams/fnv.js +1 -1
- package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +6 -6
- package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/condition.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/index.js +2 -1
- package/packages/dd-trace/src/debugger/devtools_client/send.js +8 -3
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/collector.js +1 -2
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/processor.js +3 -4
- package/packages/dd-trace/src/debugger/devtools_client/snapshot/redaction.js +1 -1
- package/packages/dd-trace/src/debugger/devtools_client/status.js +5 -1
- package/packages/dd-trace/src/debugger/index.js +1 -0
- package/packages/dd-trace/src/dogstatsd.js +2 -2
- package/packages/dd-trace/src/encode/0.4.js +5 -2
- package/packages/dd-trace/src/encode/0.5.js +3 -5
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +5 -5
- package/packages/dd-trace/src/exporter.js +2 -1
- package/packages/dd-trace/src/exporters/agent/writer.js +3 -1
- package/packages/dd-trace/src/exporters/common/docker.js +3 -2
- package/packages/dd-trace/src/exporters/common/request.js +4 -1
- package/packages/dd-trace/src/exporters/common/util.js +3 -1
- package/packages/dd-trace/src/id.js +3 -3
- package/packages/dd-trace/src/index.js +4 -3
- package/packages/dd-trace/src/lambda/handler.js +2 -1
- package/packages/dd-trace/src/lambda/index.js +2 -1
- package/packages/dd-trace/src/lambda/runtime/patch.js +3 -2
- package/packages/dd-trace/src/lambda/runtime/ritm.js +3 -2
- package/packages/dd-trace/src/llmobs/constants/tags.js +1 -0
- package/packages/dd-trace/src/llmobs/index.js +21 -5
- package/packages/dd-trace/src/llmobs/noop.js +18 -20
- package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +11 -13
- package/packages/dd-trace/src/llmobs/plugins/openai.js +1 -2
- package/packages/dd-trace/src/llmobs/sdk.js +2 -1
- package/packages/dd-trace/src/llmobs/span_processor.js +1 -1
- package/packages/dd-trace/src/llmobs/tagger.js +19 -6
- package/packages/dd-trace/src/llmobs/writers/base.js +1 -1
- package/packages/dd-trace/src/log/index.js +5 -4
- package/packages/dd-trace/src/log/writer.js +1 -2
- package/packages/dd-trace/src/msgpack/encoder.js +3 -3
- package/packages/dd-trace/src/noop/span.js +1 -1
- package/packages/dd-trace/src/opentelemetry/tracer.js +1 -1
- package/packages/dd-trace/src/opentracing/propagation/log.js +4 -5
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +35 -42
- package/packages/dd-trace/src/opentracing/span.js +7 -6
- package/packages/dd-trace/src/payload-tagging/config/index.js +17 -21
- package/packages/dd-trace/src/plugin_manager.js +4 -3
- package/packages/dd-trace/src/plugins/ci_plugin.js +25 -1
- package/packages/dd-trace/src/plugins/plugin.js +1 -1
- package/packages/dd-trace/src/plugins/util/ci.js +7 -7
- package/packages/dd-trace/src/plugins/util/git.js +1 -1
- package/packages/dd-trace/src/plugins/util/llm.js +2 -2
- package/packages/dd-trace/src/plugins/util/stacktrace.js +8 -1
- package/packages/dd-trace/src/plugins/util/test.js +4 -3
- package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -1
- package/packages/dd-trace/src/plugins/util/web.js +3 -4
- package/packages/dd-trace/src/priority_sampler.js +46 -35
- package/packages/dd-trace/src/profiling/config.js +12 -32
- package/packages/dd-trace/src/profiling/exporter_cli.js +20 -20
- package/packages/dd-trace/src/profiling/exporters/agent.js +1 -1
- package/packages/dd-trace/src/profiling/exporters/event_serializer.js +2 -1
- package/packages/dd-trace/src/profiling/index.js +2 -1
- package/packages/dd-trace/src/profiling/profiler.js +7 -4
- package/packages/dd-trace/src/profiling/profilers/events.js +10 -2
- package/packages/dd-trace/src/profiling/ssi-telemetry-mock-profiler.js +3 -1
- package/packages/dd-trace/src/profiling/tagger.js +22 -12
- package/packages/dd-trace/src/proxy.js +2 -1
- package/packages/dd-trace/src/ritm.js +4 -4
- package/packages/dd-trace/src/runtime_metrics/runtime_metrics.js +3 -2
- package/packages/dd-trace/src/sampler.js +10 -2
- package/packages/dd-trace/src/serverless.js +11 -4
- package/packages/dd-trace/src/span_processor.js +2 -1
- package/packages/dd-trace/src/standalone/tracesource.js +1 -2
- package/packages/dd-trace/src/standalone/tracesource_priority_sampler.js +1 -2
- package/packages/dd-trace/src/startup-log.js +5 -17
- package/packages/dd-trace/src/supported-configurations.json +440 -0
- package/packages/dd-trace/src/telemetry/dependencies.js +62 -57
- package/packages/dd-trace/src/telemetry/send-data.js +7 -6
- package/packages/dd-trace/src/telemetry/telemetry.js +16 -26
- package/packages/dd-trace/src/tracer.js +3 -7
- package/packages/dd-trace/src/util.js +0 -5
- package/packages/datadog-core/src/utils/src/get.js +0 -11
- package/packages/datadog-core/src/utils/src/has.js +0 -14
- package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +0 -120
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/header-sensitive-analyzer.js +0 -20
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -59,6 +59,7 @@ dev,mocha,MIT,Copyright 2011-2018 JS Foundation and contributors https://js.foun
|
|
|
59
59
|
dev,multer,MIT,Copyright 2014 Hage Yaapa
|
|
60
60
|
dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors
|
|
61
61
|
dev,nyc,ISC,Copyright 2015 Contributors
|
|
62
|
+
dev,octokit,MIT,Copyright 2023 Octokit contributors
|
|
62
63
|
dev,proxyquire,MIT,Copyright 2013 Thorsten Lorenz
|
|
63
64
|
dev,rimraf,ISC,Copyright Isaac Z. Schlueter and Contributors
|
|
64
65
|
dev,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
|
package/ci/cypress/plugin.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
const { NODE_MAJOR } = require('../../version')
|
|
2
|
+
|
|
3
|
+
// These polyfills are here because cypress@6.7.0, which we still support for v5, runs its plugin code
|
|
4
|
+
// with Node.js@12.
|
|
5
|
+
if (NODE_MAJOR < 18) {
|
|
6
|
+
require('./polyfills')
|
|
7
|
+
}
|
|
8
|
+
|
|
1
9
|
require('../init')
|
|
2
10
|
|
|
3
11
|
module.exports = require('../../packages/datadog-plugin-cypress/src/plugin')
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
if (!Object.hasOwn) {
|
|
2
|
+
Object.defineProperty(Object, 'hasOwn', {
|
|
3
|
+
// eslint-disable-next-line prefer-object-has-own
|
|
4
|
+
value: (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop),
|
|
5
|
+
writable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
})
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (!Array.prototype.at) {
|
|
11
|
+
// eslint-disable-next-line no-extend-native
|
|
12
|
+
Object.defineProperty(Array.prototype, 'at', {
|
|
13
|
+
value: function (n) {
|
|
14
|
+
const len = this.length
|
|
15
|
+
if (len === 0) return
|
|
16
|
+
let index = Math.trunc(n)
|
|
17
|
+
if (index < 0) index += len
|
|
18
|
+
return (index < 0 || index >= len) ? undefined : this[index]
|
|
19
|
+
},
|
|
20
|
+
writable: true,
|
|
21
|
+
configurable: true
|
|
22
|
+
})
|
|
23
|
+
}
|
package/ci/init.js
CHANGED
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
const tracer = require('../packages/dd-trace')
|
|
3
3
|
const { isTrue, isFalse } = require('../packages/dd-trace/src/util')
|
|
4
4
|
const log = require('../packages/dd-trace/src/log')
|
|
5
|
+
const { getEnvironmentVariable } = require('../packages/dd-trace/src/config-helper')
|
|
5
6
|
|
|
6
|
-
const isJestWorker = !!
|
|
7
|
-
const isCucumberWorker = !!
|
|
8
|
-
const isMochaWorker = !!
|
|
7
|
+
const isJestWorker = !!getEnvironmentVariable('JEST_WORKER_ID')
|
|
8
|
+
const isCucumberWorker = !!getEnvironmentVariable('CUCUMBER_WORKER_ID')
|
|
9
|
+
const isMochaWorker = !!getEnvironmentVariable('MOCHA_WORKER_ID')
|
|
9
10
|
|
|
10
|
-
const isPlaywrightWorker = !!
|
|
11
|
+
const isPlaywrightWorker = !!getEnvironmentVariable('DD_PLAYWRIGHT_WORKER')
|
|
11
12
|
|
|
12
13
|
const packageManagers = [
|
|
13
14
|
'npm',
|
|
@@ -25,17 +26,17 @@ const options = {
|
|
|
25
26
|
flushInterval: isJestWorker ? 0 : 5000
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
let shouldInit = !isFalse(
|
|
29
|
+
let shouldInit = !isFalse(getEnvironmentVariable('DD_CIVISIBILITY_ENABLED'))
|
|
29
30
|
|
|
30
31
|
if (isPackageManager()) {
|
|
31
32
|
log.debug('dd-trace is not initialized in a package manager.')
|
|
32
33
|
shouldInit = false
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
const isAgentlessEnabled = isTrue(
|
|
36
|
+
const isAgentlessEnabled = isTrue(getEnvironmentVariable('DD_CIVISIBILITY_AGENTLESS_ENABLED'))
|
|
36
37
|
|
|
37
38
|
if (isAgentlessEnabled) {
|
|
38
|
-
if (
|
|
39
|
+
if (getEnvironmentVariable('DD_API_KEY')) {
|
|
39
40
|
options.experimental = {
|
|
40
41
|
exporter: 'datadog'
|
|
41
42
|
}
|
package/initialize.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
17
17
|
import {
|
|
18
18
|
load as origLoad,
|
|
19
19
|
resolve as origResolve,
|
|
20
|
-
getSource as origGetSource
|
|
20
|
+
getSource as origGetSource,
|
|
21
21
|
} from 'import-in-the-middle/hook.mjs'
|
|
22
22
|
|
|
23
23
|
let hasInsertedInit = false
|
|
@@ -31,7 +31,7 @@ ${result.source}`
|
|
|
31
31
|
return result
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const [NODE_MAJOR, NODE_MINOR] = process.versions.node.split('.').map(
|
|
34
|
+
const [NODE_MAJOR, NODE_MINOR] = process.versions.node.split('.').map(Number)
|
|
35
35
|
|
|
36
36
|
const brokenLoaders = NODE_MAJOR === 18 && NODE_MINOR === 0
|
|
37
37
|
const iitmExclusions = [/langsmith/, /openai\/_shims/, /openai\/resources\/chat\/completions\/messages/]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.56.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"dependencies:dedupe": "yarn-deduplicate yarn.lock",
|
|
13
13
|
"type:doc": "cd docs && yarn && yarn build",
|
|
14
14
|
"type:test": "cd docs && yarn && yarn test",
|
|
15
|
-
"lint": "node scripts/check_licenses.js && eslint . --max-warnings 0
|
|
16
|
-
"lint:fix": "node scripts/check_licenses.js && eslint . --max-warnings 0 --fix
|
|
15
|
+
"lint": "node scripts/check_licenses.js && eslint . --max-warnings 0",
|
|
16
|
+
"lint:fix": "node scripts/check_licenses.js && eslint . --max-warnings 0 --fix",
|
|
17
17
|
"lint:inspect": "npx @eslint/config-inspector@latest",
|
|
18
18
|
"release:proposal": "node scripts/release/proposal",
|
|
19
19
|
"services": "node ./scripts/install_plugin_modules && node packages/dd-trace/test/setup/services",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"test:debugger:ci": "nyc --no-clean --include 'packages/dd-trace/src/debugger/**/*.js' -- npm run test:debugger",
|
|
27
27
|
"test:trace:core": "tap packages/dd-trace/test/*.spec.js \"packages/dd-trace/test/{ci-visibility,datastreams,encode,exporters,opentelemetry,opentracing,plugins,service-naming,standalone,telemetry}/**/*.spec.js\"",
|
|
28
28
|
"test:trace:core:ci": "npm run test:trace:core -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/**/*.js\"",
|
|
29
|
-
"test:instrumentations": "mocha -r 'packages/dd-trace/test/setup/mocha.js'
|
|
30
|
-
"test:instrumentations:ci": "nyc --no-clean --include
|
|
29
|
+
"test:instrumentations": "mocha -r 'packages/dd-trace/test/setup/mocha.js' \"packages/datadog-instrumentations/test/@($(echo $PLUGINS)).spec.js\"",
|
|
30
|
+
"test:instrumentations:ci": "yarn services && nyc --no-clean --include \"packages/datadog-instrumentations/src/@($(echo $PLUGINS)).js\" --include \"packages/datadog-instrumentations/src/@($(echo $PLUGINS))/**/*.js\" -- npm run test:instrumentations",
|
|
31
31
|
"test:instrumentations:misc": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/datadog-instrumentations/test/*/**/*.spec.js'",
|
|
32
32
|
"test:instrumentations:misc:ci": "nyc --no-clean --include 'packages/datadog-instrumentations/src/**/*.js' -- npm run test:instrumentations:misc",
|
|
33
33
|
"test:core": "tap \"packages/datadog-core/test/**/*.spec.js\"",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"test:llmobs:sdk:ci": "nyc --no-clean --include \"packages/dd-trace/src/llmobs/**/*.js\" -- npm run test:llmobs:sdk",
|
|
39
39
|
"test:llmobs:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/llmobs/plugins/@($(echo $PLUGINS))/*.spec.js\"",
|
|
40
40
|
"test:llmobs:plugins:ci": "yarn services && nyc --no-clean --include \"packages/dd-trace/src/llmobs/**/*.js\" -- npm run test:llmobs:plugins",
|
|
41
|
-
"test:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-
|
|
42
|
-
"test:plugins:ci": "yarn services && nyc --no-clean --include \"packages/datadog-
|
|
41
|
+
"test:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/*.spec.js\"",
|
|
42
|
+
"test:plugins:ci": "yarn services && nyc --no-clean --include \"packages/datadog-plugin-@($(echo $PLUGINS))/src/**/*.js\" -- npm run test:plugins",
|
|
43
43
|
"test:plugins:upstream": "node ./packages/dd-trace/test/plugins/suite.js",
|
|
44
44
|
"test:profiler": "tap \"packages/dd-trace/test/profiling/**/*.spec.js\"",
|
|
45
45
|
"test:profiler:ci": "npm run test:profiler -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/profiling/**/*.js\"",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@datadog/native-appsec": "8.5.2",
|
|
89
89
|
"@datadog/native-iast-taint-tracking": "4.0.0",
|
|
90
90
|
"@datadog/native-metrics": "^3.1.1",
|
|
91
|
-
"@datadog/pprof": "5.8.
|
|
91
|
+
"@datadog/pprof": "5.8.2",
|
|
92
92
|
"@datadog/sketches-js": "^2.1.1",
|
|
93
93
|
"@datadog/wasm-js-rewriter": "4.0.1",
|
|
94
94
|
"@isaacs/ttlcache": "^1.4.1",
|
|
@@ -143,9 +143,10 @@
|
|
|
143
143
|
"graphql": "0.13.2",
|
|
144
144
|
"jszip": "^3.10.1",
|
|
145
145
|
"mocha": "^10.8.2",
|
|
146
|
-
"multer": "^2.0.
|
|
146
|
+
"multer": "^2.0.1",
|
|
147
147
|
"nock": "^11.9.1",
|
|
148
148
|
"nyc": "^15.1.0",
|
|
149
|
+
"octokit": "^5.0.3",
|
|
149
150
|
"proxyquire": "^1.8.0",
|
|
150
151
|
"rimraf": "^3.0.2",
|
|
151
152
|
"semver": "^7.7.2",
|
|
@@ -2,22 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
const { getUserLandFrames } = require('../dd-trace/src/plugins/util/stacktrace')
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const ENTRY_SPAN_STACK_FRAMES_LIMIT = 1
|
|
6
|
+
const EXIT_SPAN_STACK_FRAMES_LIMIT = Number(process.env._DD_CODE_ORIGIN_FOR_SPANS_EXIT_SPAN_MAX_USER_FRAMES) || 8
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
entryTags,
|
|
9
10
|
exitTags
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @param {Function} topOfStackFunc - A function present in the current stack, above which no stack frames should be
|
|
15
|
+
* collected.
|
|
16
|
+
* @returns {Record<string, string>}
|
|
17
|
+
*/
|
|
12
18
|
function entryTags (topOfStackFunc) {
|
|
13
|
-
return tag('entry', topOfStackFunc)
|
|
19
|
+
return tag('entry', topOfStackFunc, ENTRY_SPAN_STACK_FRAMES_LIMIT)
|
|
14
20
|
}
|
|
15
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @param {Function} topOfStackFunc - A function present in the current stack, above which no stack frames should be
|
|
24
|
+
* collected.
|
|
25
|
+
* @returns {Record<string, string>}
|
|
26
|
+
*/
|
|
16
27
|
function exitTags (topOfStackFunc) {
|
|
17
|
-
return tag('exit', topOfStackFunc)
|
|
28
|
+
return tag('exit', topOfStackFunc, EXIT_SPAN_STACK_FRAMES_LIMIT)
|
|
18
29
|
}
|
|
19
30
|
|
|
20
|
-
|
|
31
|
+
/**
|
|
32
|
+
* @param {'entry'|'exit'} type - The type of code origin.
|
|
33
|
+
* @param {Function} topOfStackFunc - A function present in the current stack, above which no stack frames should be
|
|
34
|
+
* collected.
|
|
35
|
+
* @param {number} limit - The maximum number of stack frames to include in the tags.
|
|
36
|
+
* @returns {Record<string, string>}
|
|
37
|
+
*/
|
|
38
|
+
function tag (type, topOfStackFunc, limit) {
|
|
21
39
|
const frames = getUserLandFrames(topOfStackFunc, limit)
|
|
22
40
|
const tags = {
|
|
23
41
|
'_dd.code_origin.type': type
|
|
@@ -7,8 +7,8 @@ module.exports = function kebabcase (str) {
|
|
|
7
7
|
|
|
8
8
|
return str
|
|
9
9
|
.trim()
|
|
10
|
-
.
|
|
11
|
-
.
|
|
12
|
-
.
|
|
10
|
+
.replaceAll(/([a-z])([A-Z])/g, '$1-$2') // Convert camelCase to kebab-case
|
|
11
|
+
.replaceAll(/[\s_]+/g, '-') // Replace spaces and underscores with a single dash
|
|
12
|
+
.replaceAll(/^-+|-+$/g, '') // Trim leading and trailing dashes
|
|
13
13
|
.toLowerCase()
|
|
14
14
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
module.exports = function set (object, path, value) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
property = property[n]
|
|
11
|
-
} else {
|
|
12
|
-
property[n] = property = {}
|
|
4
|
+
let index = -1
|
|
5
|
+
while (true) {
|
|
6
|
+
const nextIndex = path.indexOf('.', index + 1)
|
|
7
|
+
if (nextIndex === -1) {
|
|
8
|
+
object[path.slice(index + 1)] = value
|
|
9
|
+
return
|
|
13
10
|
}
|
|
11
|
+
object = object[path.slice(index + 1, nextIndex)] ??= {}
|
|
12
|
+
index = nextIndex
|
|
14
13
|
}
|
|
15
|
-
property[pathArr[i]] = value
|
|
16
14
|
}
|
|
@@ -34,13 +34,12 @@ addHook({ name: 'cassandra-driver', versions: ['>=3.0.0'] }, cassandra => {
|
|
|
34
34
|
const res = batch.apply(this, arguments)
|
|
35
35
|
if (typeof res === 'function' || !res) {
|
|
36
36
|
return wrapCallback(finishCh, errorCh, asyncResource, res)
|
|
37
|
-
} else {
|
|
38
|
-
const promiseAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
39
|
-
return res.then(
|
|
40
|
-
promiseAsyncResource.bind(() => finish(finishCh, errorCh)),
|
|
41
|
-
promiseAsyncResource.bind(err => finish(finishCh, errorCh, err))
|
|
42
|
-
)
|
|
43
37
|
}
|
|
38
|
+
const promiseAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
39
|
+
return res.then(
|
|
40
|
+
promiseAsyncResource.bind(() => finish(finishCh, errorCh)),
|
|
41
|
+
promiseAsyncResource.bind(err => finish(finishCh, errorCh, err))
|
|
42
|
+
)
|
|
44
43
|
} catch (e) {
|
|
45
44
|
finish(finishCh, errorCh, e)
|
|
46
45
|
throw e
|
|
@@ -379,10 +379,9 @@ function wrapKafkaCallback (callback, { startCh, commitCh, finishCh, errorCh },
|
|
|
379
379
|
finishCh.publish(ctx)
|
|
380
380
|
throw err
|
|
381
381
|
})
|
|
382
|
-
} else {
|
|
383
|
-
finishCh.publish(ctx)
|
|
384
|
-
return result
|
|
385
382
|
}
|
|
383
|
+
finishCh.publish(ctx)
|
|
384
|
+
return result
|
|
386
385
|
} catch (error) {
|
|
387
386
|
ctx.error = error
|
|
388
387
|
errorCh.publish(ctx)
|
|
@@ -10,7 +10,7 @@ function publishRequestCookieAndNext (req, res, next) {
|
|
|
10
10
|
if (cookieParserReadCh.hasSubscribers && req) {
|
|
11
11
|
const abortController = new AbortController()
|
|
12
12
|
|
|
13
|
-
const mergedCookies =
|
|
13
|
+
const mergedCookies = { ...req.cookies, ...req.signedCookies }
|
|
14
14
|
|
|
15
15
|
cookieParserReadCh.publish({ req, res, abortController, cookies: mergedCookies })
|
|
16
16
|
|
|
@@ -43,14 +43,11 @@ function wrapMaybeInvoke (_maybeInvoke) {
|
|
|
43
43
|
|
|
44
44
|
function wrapQuery (query) {
|
|
45
45
|
const wrapped = function (q, params, callback) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (typeof callback === 'function') {
|
|
49
|
-
arguments[arguments.length - 1] = callback
|
|
46
|
+
if (typeof arguments[arguments.length - 1] === 'function') {
|
|
47
|
+
arguments[arguments.length - 1] = AsyncResource.bind(arguments[arguments.length - 1])
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
return res
|
|
50
|
+
return query.apply(this, arguments)
|
|
54
51
|
}
|
|
55
52
|
return wrapped
|
|
56
53
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
const { createCoverageMap } = require('istanbul-lib-coverage')
|
|
3
3
|
|
|
4
|
-
const { addHook, channel
|
|
4
|
+
const { addHook, channel } = require('./helpers/instrument')
|
|
5
5
|
const shimmer = require('../../datadog-shimmer')
|
|
6
6
|
const log = require('../../dd-trace/src/log')
|
|
7
|
+
const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
|
|
7
8
|
|
|
8
9
|
const testStartCh = channel('ci:cucumber:test:start')
|
|
9
10
|
const testRetryCh = channel('ci:cucumber:test:retry')
|
|
@@ -63,8 +64,6 @@ let eventDataCollector = null
|
|
|
63
64
|
let pickleByFile = {}
|
|
64
65
|
const pickleResultByFile = {}
|
|
65
66
|
|
|
66
|
-
const sessionAsyncResource = new AsyncResource('bound-anonymous-fn')
|
|
67
|
-
|
|
68
67
|
let skippableSuites = []
|
|
69
68
|
let itrCorrelationId = ''
|
|
70
69
|
let isForcedToRun = false
|
|
@@ -160,9 +159,7 @@ function getErrorFromCucumberResult (cucumberResult) {
|
|
|
160
159
|
|
|
161
160
|
function getChannelPromise (channelToPublishTo, isParallel = false) {
|
|
162
161
|
return new Promise(resolve => {
|
|
163
|
-
|
|
164
|
-
channelToPublishTo.publish({ onDone: resolve, isParallel })
|
|
165
|
-
})
|
|
162
|
+
channelToPublishTo.publish({ onDone: resolve, isParallel })
|
|
166
163
|
})
|
|
167
164
|
}
|
|
168
165
|
|
|
@@ -247,7 +244,7 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
247
244
|
testName: this.pickle.name,
|
|
248
245
|
testFileAbsolutePath,
|
|
249
246
|
testSourceLine,
|
|
250
|
-
isParallel: !!
|
|
247
|
+
isParallel: !!getEnvironmentVariable('CUCUMBER_WORKER_ID')
|
|
251
248
|
}
|
|
252
249
|
const ctx = testStartPayload
|
|
253
250
|
numAttemptToCtx.set(numAttempt, ctx)
|
|
@@ -540,15 +537,13 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
540
537
|
}
|
|
541
538
|
|
|
542
539
|
const processArgv = process.argv.slice(2).join(' ')
|
|
543
|
-
const command =
|
|
540
|
+
const command = getEnvironmentVariable('npm_lifecycle_script') || `cucumber-js ${processArgv}`
|
|
544
541
|
|
|
545
542
|
if (isFlakyTestRetriesEnabled && !options.retry && numTestRetries > 0) {
|
|
546
543
|
options.retry = numTestRetries
|
|
547
544
|
}
|
|
548
545
|
|
|
549
|
-
|
|
550
|
-
sessionStartCh.publish({ command, frameworkVersion })
|
|
551
|
-
})
|
|
546
|
+
sessionStartCh.publish({ command, frameworkVersion })
|
|
552
547
|
|
|
553
548
|
if (!errorSkippableRequest && skippedSuites.length) {
|
|
554
549
|
itrSkippedSuitesCh.publish({ skippedSuites, frameworkVersion })
|
|
@@ -576,19 +571,17 @@ function getWrappedStart (start, frameworkVersion, isParallel = false, isCoordin
|
|
|
576
571
|
global.__coverage__ = fromCoverageMapToCoverage(originalCoverageMap)
|
|
577
572
|
}
|
|
578
573
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
isParallel
|
|
591
|
-
})
|
|
574
|
+
sessionFinishCh.publish({
|
|
575
|
+
status: success ? 'pass' : 'fail',
|
|
576
|
+
isSuitesSkipped,
|
|
577
|
+
testCodeCoverageLinesTotal,
|
|
578
|
+
numSkippedSuites: skippedSuites.length,
|
|
579
|
+
hasUnskippableSuites: isUnskippable,
|
|
580
|
+
hasForcedToRunSuites: isForcedToRun,
|
|
581
|
+
isEarlyFlakeDetectionEnabled,
|
|
582
|
+
isEarlyFlakeDetectionFaulty,
|
|
583
|
+
isTestManagementTestsEnabled,
|
|
584
|
+
isParallel
|
|
592
585
|
})
|
|
593
586
|
eventDataCollector = null
|
|
594
587
|
return success
|
|
@@ -676,6 +669,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
676
669
|
if (isAttemptToFix && lastTestStatus !== 'skip') {
|
|
677
670
|
for (let retryIndex = 0; retryIndex < testManagementAttemptToFixRetries; retryIndex++) {
|
|
678
671
|
numRetriesByPickleId.set(pickle.id, retryIndex + 1)
|
|
672
|
+
// eslint-disable-next-line no-await-in-loop
|
|
679
673
|
runTestCaseResult = await runTestCaseFunction.apply(this, arguments)
|
|
680
674
|
}
|
|
681
675
|
}
|
|
@@ -684,6 +678,7 @@ function getWrappedRunTestCase (runTestCaseFunction, isNewerCucumberVersion = fa
|
|
|
684
678
|
if (isEarlyFlakeDetectionEnabled && lastTestStatus !== 'skip' && (isNew || isModified)) {
|
|
685
679
|
for (let retryIndex = 0; retryIndex < earlyFlakeDetectionNumRetries; retryIndex++) {
|
|
686
680
|
numRetriesByPickleId.set(pickle.id, retryIndex + 1)
|
|
681
|
+
// eslint-disable-next-line no-await-in-loop
|
|
687
682
|
runTestCaseResult = await runTestCaseFunction.apply(this, arguments)
|
|
688
683
|
}
|
|
689
684
|
}
|
|
@@ -758,9 +753,7 @@ function getWrappedParseWorkerMessage (parseWorkerMessageFunction, isNewVersion)
|
|
|
758
753
|
if (Array.isArray(message)) {
|
|
759
754
|
const [messageCode, payload] = message
|
|
760
755
|
if (messageCode === CUCUMBER_WORKER_TRACE_PAYLOAD_CODE) {
|
|
761
|
-
|
|
762
|
-
workerReportTraceCh.publish(payload)
|
|
763
|
-
})
|
|
756
|
+
workerReportTraceCh.publish(payload)
|
|
764
757
|
return
|
|
765
758
|
}
|
|
766
759
|
}
|
|
@@ -932,7 +925,7 @@ addHook({
|
|
|
932
925
|
shimmer.wrap(
|
|
933
926
|
workerPackage.Worker.prototype,
|
|
934
927
|
'runTestCase',
|
|
935
|
-
runTestCase => getWrappedRunTestCase(runTestCase, true, !!
|
|
928
|
+
runTestCase => getWrappedRunTestCase(runTestCase, true, !!getEnvironmentVariable('CUCUMBER_WORKER_ID'))
|
|
936
929
|
)
|
|
937
930
|
return workerPackage
|
|
938
931
|
})
|
|
@@ -39,12 +39,12 @@ addHook({ name: names }, dns => {
|
|
|
39
39
|
})
|
|
40
40
|
|
|
41
41
|
function patchResolveShorthands (prototype) {
|
|
42
|
-
Object.keys(rrtypes)
|
|
43
|
-
|
|
44
|
-
.forEach(method => {
|
|
42
|
+
for (const method of Object.keys(rrtypes)) {
|
|
43
|
+
if (prototype[method]) {
|
|
45
44
|
rrtypeMap.set(prototype[method], rrtypes[method])
|
|
46
45
|
shimmer.wrap(prototype, method, fn => wrap('apm:dns:resolve', fn, 2, rrtypes[method]))
|
|
47
|
-
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function wrap (prefix, fn, expectedArgs, rrtype) {
|
|
@@ -91,18 +91,17 @@ function createWrapRequest (name) {
|
|
|
91
91
|
return cb.apply(null, arguments)
|
|
92
92
|
}))
|
|
93
93
|
return request.apply(this, arguments)
|
|
94
|
+
}
|
|
95
|
+
const promise = request.apply(this, arguments)
|
|
96
|
+
if (promise && typeof promise.then === 'function') {
|
|
97
|
+
const onResolve = asyncResource.bind(() => finish(params))
|
|
98
|
+
const onReject = asyncResource.bind(e => finish(params, e))
|
|
99
|
+
|
|
100
|
+
promise.then(onResolve, onReject)
|
|
94
101
|
} else {
|
|
95
|
-
|
|
96
|
-
if (promise && typeof promise.then === 'function') {
|
|
97
|
-
const onResolve = asyncResource.bind(() => finish(params))
|
|
98
|
-
const onReject = asyncResource.bind(e => finish(params, e))
|
|
99
|
-
|
|
100
|
-
promise.then(onResolve, onReject)
|
|
101
|
-
} else {
|
|
102
|
-
finish(params)
|
|
103
|
-
}
|
|
104
|
-
return promise
|
|
102
|
+
finish(params)
|
|
105
103
|
}
|
|
104
|
+
return promise
|
|
106
105
|
} catch (err) {
|
|
107
106
|
err.stack // trigger getting the stack at the original throwing point
|
|
108
107
|
errorCh.publish(err)
|
|
@@ -59,21 +59,19 @@ function wrapAddHook (addHook) {
|
|
|
59
59
|
return parsingResource.runInAsyncScope(() => {
|
|
60
60
|
return done.apply(this, arguments)
|
|
61
61
|
})
|
|
62
|
-
} else {
|
|
63
|
-
return done.apply(this, arguments)
|
|
64
62
|
}
|
|
63
|
+
return done.apply(this, arguments)
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
return fn.apply(this, arguments)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (promise && typeof promise.catch === 'function') {
|
|
72
|
-
return promise.catch(err => publishError(err, req))
|
|
73
|
-
}
|
|
67
|
+
}
|
|
68
|
+
const promise = fn.apply(this, arguments)
|
|
74
69
|
|
|
75
|
-
|
|
70
|
+
if (promise && typeof promise.catch === 'function') {
|
|
71
|
+
return promise.catch(err => publishError(err, req))
|
|
76
72
|
}
|
|
73
|
+
|
|
74
|
+
return promise
|
|
77
75
|
} catch (e) {
|
|
78
76
|
throw publishError(e, req)
|
|
79
77
|
}
|
|
@@ -79,21 +79,20 @@ function wrapMethod (method) {
|
|
|
79
79
|
})
|
|
80
80
|
|
|
81
81
|
return method.apply(this, arguments)
|
|
82
|
-
} else {
|
|
83
|
-
return method.apply(this, arguments)
|
|
84
|
-
.then(
|
|
85
|
-
response => {
|
|
86
|
-
requestFinishCh.publish(ctx)
|
|
87
|
-
return response
|
|
88
|
-
},
|
|
89
|
-
error => {
|
|
90
|
-
ctx.error = error
|
|
91
|
-
requestErrorCh.publish(ctx)
|
|
92
|
-
requestFinishCh.publish(ctx)
|
|
93
|
-
throw error
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
82
|
}
|
|
83
|
+
return method.apply(this, arguments)
|
|
84
|
+
.then(
|
|
85
|
+
response => {
|
|
86
|
+
requestFinishCh.publish(ctx)
|
|
87
|
+
return response
|
|
88
|
+
},
|
|
89
|
+
error => {
|
|
90
|
+
ctx.error = error
|
|
91
|
+
requestErrorCh.publish(ctx)
|
|
92
|
+
requestFinishCh.publish(ctx)
|
|
93
|
+
throw error
|
|
94
|
+
}
|
|
95
|
+
)
|
|
97
96
|
})
|
|
98
97
|
}
|
|
99
98
|
}
|
|
@@ -133,9 +132,8 @@ addHook({ name: '@google-cloud/pubsub', versions: ['>=1.2'], file: 'build/src/le
|
|
|
133
132
|
if (receiveStartCh.hasSubscribers) {
|
|
134
133
|
ctx.message = message
|
|
135
134
|
return receiveStartCh.runStores(ctx, dispense, this, ...arguments)
|
|
136
|
-
} else {
|
|
137
|
-
return dispense.apply(this, arguments)
|
|
138
135
|
}
|
|
136
|
+
return dispense.apply(this, arguments)
|
|
139
137
|
})
|
|
140
138
|
|
|
141
139
|
shimmer.wrap(LeaseManager.prototype, 'remove', remove => function (message) {
|
|
@@ -42,7 +42,10 @@ function wrapExt (ext) {
|
|
|
42
42
|
if (events !== null && typeof events === 'object') {
|
|
43
43
|
arguments[0] = wrapEvents(events)
|
|
44
44
|
} else {
|
|
45
|
-
|
|
45
|
+
// The method should never be an array. The check is done as a safe guard
|
|
46
|
+
// during a refactoring where it was unclear if this would be possible or
|
|
47
|
+
// not.
|
|
48
|
+
arguments[1] = Array.isArray(method) ? method.map(wrapHandler) : [wrapHandler(method)]
|
|
46
49
|
}
|
|
47
50
|
|
|
48
51
|
return ext.apply(this, arguments)
|
|
@@ -75,17 +78,13 @@ function wrapRebuild (rebuild) {
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
+
function wrapEvents (events, flat = false) {
|
|
82
|
+
const eventsArray = Array.isArray(events) ? events : [events]
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (!event || !event.method) return event
|
|
84
|
+
return eventsArray.map(event => {
|
|
85
|
+
if (!event?.method) return event
|
|
85
86
|
|
|
86
|
-
return
|
|
87
|
-
method: wrapExtension(event.method)
|
|
88
|
-
})
|
|
87
|
+
return { ...event, method: wrapHandler(event.method) }
|
|
89
88
|
})
|
|
90
89
|
}
|
|
91
90
|
|
|
@@ -93,7 +92,7 @@ function wrapHandler (handler) {
|
|
|
93
92
|
if (typeof handler !== 'function') return handler
|
|
94
93
|
|
|
95
94
|
return shimmer.wrapFunction(handler, handler => function (request, h) {
|
|
96
|
-
const req = request
|
|
95
|
+
const req = request?.raw?.req
|
|
97
96
|
|
|
98
97
|
if (!req) return handler.apply(this, arguments)
|
|
99
98
|
|
|
@@ -16,12 +16,11 @@ exports.createWrapFetch = function createWrapFetch (Request, ch, onLoad) {
|
|
|
16
16
|
const ctx = { req: input }
|
|
17
17
|
|
|
18
18
|
return ch.tracePromise(() => fetch.call(this, input, init), ctx)
|
|
19
|
-
} else {
|
|
20
|
-
const req = new Request(input, init)
|
|
21
|
-
const ctx = { req }
|
|
22
|
-
|
|
23
|
-
return ch.tracePromise(() => fetch.call(this, req), ctx)
|
|
24
19
|
}
|
|
20
|
+
const req = new Request(input, init)
|
|
21
|
+
const ctx = { req }
|
|
22
|
+
|
|
23
|
+
return ch.tracePromise(() => fetch.call(this, req), ctx)
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
}
|
|
@@ -41,9 +41,8 @@ function Hook (modules, hookOptions, onrequire) {
|
|
|
41
41
|
if (moduleExports && moduleExports.default) {
|
|
42
42
|
moduleExports.default = safeHook(moduleExports.default, moduleName, moduleBaseDir)
|
|
43
43
|
return moduleExports
|
|
44
|
-
} else {
|
|
45
|
-
return safeHook(moduleExports, moduleName, moduleBaseDir)
|
|
46
44
|
}
|
|
45
|
+
return safeHook(moduleExports, moduleName, moduleBaseDir)
|
|
47
46
|
})
|
|
48
47
|
}
|
|
49
48
|
|