dd-trace 4.15.0 → 4.16.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/ext/tags.d.ts +1 -0
- package/ext/tags.js +1 -0
- package/index.d.ts +1 -0
- package/package.json +6 -4
- package/packages/datadog-esbuild/index.js +30 -25
- package/packages/datadog-instrumentations/src/body-parser.js +2 -2
- package/packages/datadog-instrumentations/src/cookie-parser.js +37 -0
- package/packages/datadog-instrumentations/src/express.js +1 -1
- package/packages/datadog-instrumentations/src/graphql.js +5 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -0
- package/packages/datadog-instrumentations/src/http/server.js +1 -1
- package/packages/datadog-instrumentations/src/next.js +22 -80
- package/packages/datadog-instrumentations/src/pg.js +14 -15
- package/packages/datadog-instrumentations/src/playwright.js +15 -3
- package/packages/datadog-plugin-mysql/src/index.js +2 -2
- package/packages/datadog-plugin-next/src/index.js +14 -5
- package/packages/datadog-plugin-pg/src/index.js +2 -2
- package/packages/dd-trace/src/appsec/channels.js +1 -0
- package/packages/dd-trace/src/appsec/index.js +18 -5
- package/packages/dd-trace/src/appsec/recommended.json +549 -24
- package/packages/dd-trace/src/appsec/remote_config/capabilities.js +2 -1
- package/packages/dd-trace/src/appsec/remote_config/index.js +2 -0
- package/packages/dd-trace/src/appsec/reporter.js +7 -5
- package/packages/dd-trace/src/appsec/telemetry.js +2 -2
- package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +4 -4
- package/packages/dd-trace/src/appsec/waf/waf_manager.js +5 -4
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +1 -14
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -13
- package/packages/dd-trace/src/datastreams/processor.js +6 -2
- package/packages/dd-trace/src/format.js +6 -1
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +2 -2
- package/packages/dd-trace/src/opentracing/tracer.js +0 -2
- package/packages/dd-trace/src/plugin_manager.js +1 -2
- package/packages/dd-trace/src/plugins/database.js +14 -4
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/outbound.js +4 -3
- package/packages/dd-trace/src/telemetry/index.js +10 -1
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -32,6 +32,7 @@ require,retry,MIT,Copyright 2011 Tim Koschützki Felix Geisendörfer
|
|
|
32
32
|
require,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
|
|
33
33
|
dev,@types/node,MIT,Copyright Authors
|
|
34
34
|
dev,autocannon,MIT,Copyright 2016 Matteo Collina
|
|
35
|
+
dev,aws-sdk,Apache 2.0,Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
35
36
|
dev,axios,MIT,Copyright 2014-present Matt Zabriskie
|
|
36
37
|
dev,benchmark,MIT,Copyright 2010-2016 Mathias Bynens Robert Kieffer John-David Dalton
|
|
37
38
|
dev,body-parser,MIT,Copyright 2014 Jonathan Ong 2014-2015 Douglas Christopher Wilson
|
package/ext/tags.d.ts
CHANGED
package/ext/tags.js
CHANGED
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"test:integration:cypress": "mocha --colors --timeout 30000 \"integration-tests/cypress/*.spec.js\"",
|
|
38
38
|
"test:integration:playwright": "mocha --colors --timeout 30000 \"integration-tests/playwright/*.spec.js\"",
|
|
39
39
|
"test:integration:serverless": "mocha --colors --timeout 30000 \"integration-tests/serverless/*.spec.js\"",
|
|
40
|
-
"test:integration:plugins": "mocha --colors --
|
|
40
|
+
"test:integration:plugins": "mocha --colors --exit -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/integration-test/**/*.spec.js\"",
|
|
41
|
+
"test:unit:plugins": "mocha --colors --exit -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-instrumentations/test/@($(echo $PLUGINS)).spec.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/*.spec.js\" --exclude \"packages/datadog-plugin-@($(echo $PLUGINS))/test/integration-test/**/*.spec.js\"",
|
|
41
42
|
"test:shimmer": "mocha --colors 'packages/datadog-shimmer/test/**/*.spec.js'",
|
|
42
43
|
"test:shimmer:ci": "nyc --no-clean --include 'packages/datadog-shimmer/src/**/*.js' -- npm run test:shimmer",
|
|
43
44
|
"leak:core": "node ./scripts/install_plugin_modules && (cd packages/memwatch && yarn) && NODE_PATH=./packages/memwatch/node_modules node --no-warnings ./node_modules/.bin/tape 'packages/dd-trace/test/leak/**/*.js'",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"apm"
|
|
59
60
|
],
|
|
60
61
|
"author": "Datadog Inc. <info@datadoghq.com>",
|
|
61
|
-
"license": "BSD-3-Clause",
|
|
62
|
+
"license": "(Apache-2.0 OR BSD-3-Clause)",
|
|
62
63
|
"bugs": {
|
|
63
64
|
"url": "https://github.com/DataDog/dd-trace-js/issues"
|
|
64
65
|
},
|
|
@@ -67,7 +68,7 @@
|
|
|
67
68
|
"node": ">=16"
|
|
68
69
|
},
|
|
69
70
|
"dependencies": {
|
|
70
|
-
"@datadog/native-appsec": "^
|
|
71
|
+
"@datadog/native-appsec": "^4.0.0",
|
|
71
72
|
"@datadog/native-iast-rewriter": "2.1.3",
|
|
72
73
|
"@datadog/native-iast-taint-tracking": "1.5.0",
|
|
73
74
|
"@datadog/native-metrics": "^2.0.0",
|
|
@@ -102,6 +103,7 @@
|
|
|
102
103
|
"devDependencies": {
|
|
103
104
|
"@types/node": ">=16",
|
|
104
105
|
"autocannon": "^4.5.2",
|
|
106
|
+
"aws-sdk": "^2.1446.0",
|
|
105
107
|
"axios": "^0.21.2",
|
|
106
108
|
"benchmark": "^2.1.4",
|
|
107
109
|
"body-parser": "^1.20.2",
|
|
@@ -23,11 +23,12 @@ for (const instrumentation of Object.values(instrumentations)) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const NAMESPACE = 'datadog'
|
|
27
26
|
const NM = 'node_modules/'
|
|
28
27
|
const INSTRUMENTED = Object.keys(instrumentations)
|
|
29
28
|
const RAW_BUILTINS = require('module').builtinModules
|
|
30
29
|
const CHANNEL = 'dd-trace:bundler:load'
|
|
30
|
+
const path = require('path')
|
|
31
|
+
const fs = require('fs')
|
|
31
32
|
|
|
32
33
|
const builtins = new Set()
|
|
33
34
|
|
|
@@ -109,55 +110,59 @@ module.exports.setup = function (build) {
|
|
|
109
110
|
// https://esbuild.github.io/plugins/#on-resolve-arguments
|
|
110
111
|
return {
|
|
111
112
|
path: fullPathToModule,
|
|
112
|
-
namespace: NAMESPACE,
|
|
113
113
|
pluginData: {
|
|
114
114
|
version: packageJson.version,
|
|
115
115
|
pkg: extracted.pkg,
|
|
116
116
|
path: extracted.path,
|
|
117
117
|
full: fullPathToModule,
|
|
118
118
|
raw: args.path,
|
|
119
|
+
pkgOfInterest: true,
|
|
119
120
|
internal
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
|
-
} else if (args.namespace === NAMESPACE) {
|
|
123
|
-
// The datadog namespace is used when requiring files that are injected during the onLoad stage
|
|
124
|
-
|
|
125
|
-
if (builtins.has(args.path)) return
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
path: require.resolve(args.path, { paths: [ args.resolveDir ] }),
|
|
129
|
-
namespace: 'file'
|
|
130
|
-
}
|
|
131
123
|
}
|
|
132
124
|
})
|
|
133
125
|
|
|
134
|
-
build.onLoad({ filter:
|
|
126
|
+
build.onLoad({ filter: /.*/ }, args => {
|
|
127
|
+
if (!args.pluginData?.pkgOfInterest) {
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
|
|
135
131
|
const data = args.pluginData
|
|
136
132
|
|
|
137
133
|
if (DEBUG) console.log(`LOAD: ${data.pkg}@${data.version}, pkg "${data.path}"`)
|
|
138
134
|
|
|
139
|
-
const
|
|
135
|
+
const pkgPath = data.raw !== data.pkg
|
|
140
136
|
? `${data.pkg}/${data.path}`
|
|
141
137
|
: data.pkg
|
|
142
138
|
|
|
139
|
+
// Read the content of the module file of interest
|
|
140
|
+
const fileCode = fs.readFileSync(args.path, 'utf8')
|
|
141
|
+
|
|
143
142
|
const contents = `
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
143
|
+
(function() {
|
|
144
|
+
${fileCode}
|
|
145
|
+
})(...arguments);
|
|
146
|
+
{
|
|
147
|
+
const dc = require('diagnostics_channel');
|
|
148
|
+
const ch = dc.channel('${CHANNEL}');
|
|
149
|
+
const mod = module.exports
|
|
150
|
+
const payload = {
|
|
151
|
+
module: mod,
|
|
152
|
+
version: '${data.version}',
|
|
153
|
+
package: '${data.pkg}',
|
|
154
|
+
path: '${pkgPath}'
|
|
155
|
+
};
|
|
156
|
+
ch.publish(payload);
|
|
157
|
+
module.exports = payload.module;
|
|
158
|
+
}
|
|
155
159
|
`
|
|
156
160
|
|
|
157
161
|
// https://esbuild.github.io/plugins/#on-load-results
|
|
158
162
|
return {
|
|
159
163
|
contents,
|
|
160
|
-
loader: 'js'
|
|
164
|
+
loader: 'js',
|
|
165
|
+
resolveDir: path.dirname(args.path)
|
|
161
166
|
}
|
|
162
167
|
})
|
|
163
168
|
}
|
|
@@ -16,7 +16,7 @@ function publishRequestBodyAndNext (req, res, next) {
|
|
|
16
16
|
if (abortController.signal.aborted) return
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
next.apply(this, arguments)
|
|
19
|
+
return next.apply(this, arguments)
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -27,6 +27,6 @@ addHook({
|
|
|
27
27
|
}, read => {
|
|
28
28
|
return shimmer.wrap(read, function (req, res, next) {
|
|
29
29
|
arguments[2] = publishRequestBodyAndNext(req, res, next)
|
|
30
|
-
read.apply(this, arguments)
|
|
30
|
+
return read.apply(this, arguments)
|
|
31
31
|
})
|
|
32
32
|
})
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { AbortController } = require('node-abort-controller') // AbortController is not available in node <15
|
|
4
|
+
const shimmer = require('../../datadog-shimmer')
|
|
5
|
+
const { channel, addHook } = require('./helpers/instrument')
|
|
6
|
+
|
|
7
|
+
const cookieParserReadCh = channel('datadog:cookie-parser:read:finish')
|
|
8
|
+
|
|
9
|
+
function publishRequestCookieAndNext (req, res, next) {
|
|
10
|
+
return function cookieParserWrapper () {
|
|
11
|
+
if (cookieParserReadCh.hasSubscribers && req) {
|
|
12
|
+
const abortController = new AbortController()
|
|
13
|
+
|
|
14
|
+
const mergedCookies = Object.assign({}, req.cookies, req.signedCookies)
|
|
15
|
+
|
|
16
|
+
cookieParserReadCh.publish({ req, res, abortController, cookies: mergedCookies })
|
|
17
|
+
|
|
18
|
+
if (abortController.signal.aborted) return
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return next.apply(this, arguments)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
addHook({
|
|
26
|
+
name: 'cookie-parser',
|
|
27
|
+
versions: ['>=1.0.0']
|
|
28
|
+
}, cookieParser => {
|
|
29
|
+
return shimmer.wrap(cookieParser, function () {
|
|
30
|
+
const cookieMiddleware = cookieParser.apply(this, arguments)
|
|
31
|
+
|
|
32
|
+
return shimmer.wrap(cookieMiddleware, function (req, res, next) {
|
|
33
|
+
arguments[2] = publishRequestCookieAndNext(req, res, next)
|
|
34
|
+
return cookieMiddleware.apply(this, arguments)
|
|
35
|
+
})
|
|
36
|
+
})
|
|
37
|
+
})
|
|
@@ -350,6 +350,11 @@ function finishResolvers ({ fields }) {
|
|
|
350
350
|
})
|
|
351
351
|
}
|
|
352
352
|
|
|
353
|
+
addHook({ name: '@graphql-tools/executor', file: 'cjs/execution/execute.js', versions: ['>=0.0.14'] }, execute => {
|
|
354
|
+
shimmer.wrap(execute, 'execute', wrapExecute(execute))
|
|
355
|
+
return execute
|
|
356
|
+
})
|
|
357
|
+
|
|
353
358
|
addHook({ name: 'graphql', file: 'execution/execute.js', versions: ['>=0.10'] }, execute => {
|
|
354
359
|
shimmer.wrap(execute, 'execute', wrapExecute(execute))
|
|
355
360
|
return execute
|
|
@@ -7,6 +7,7 @@ module.exports = {
|
|
|
7
7
|
'@elastic/elasticsearch': () => require('../elasticsearch'),
|
|
8
8
|
'@elastic/transport': () => require('../elasticsearch'),
|
|
9
9
|
'@google-cloud/pubsub': () => require('../google-cloud-pubsub'),
|
|
10
|
+
'@graphql-tools/executor': () => require('../graphql'),
|
|
10
11
|
'@grpc/grpc-js': () => require('../grpc'),
|
|
11
12
|
'@hapi/hapi': () => require('../hapi'),
|
|
12
13
|
'@jest/core': () => require('../jest'),
|
|
@@ -30,6 +31,7 @@ module.exports = {
|
|
|
30
31
|
'node:child_process': () => require('../child-process'),
|
|
31
32
|
'connect': () => require('../connect'),
|
|
32
33
|
'cookie': () => require('../cookie'),
|
|
34
|
+
'cookie-parser': () => require('../cookie-parser'),
|
|
33
35
|
'couchbase': () => require('../couchbase'),
|
|
34
36
|
'crypto': () => require('../crypto'),
|
|
35
37
|
'cypress': () => require('../cypress'),
|
|
@@ -81,6 +83,7 @@ module.exports = {
|
|
|
81
83
|
'pg': () => require('../pg'),
|
|
82
84
|
'pino': () => require('../pino'),
|
|
83
85
|
'pino-pretty': () => require('../pino'),
|
|
86
|
+
'playwright': () => require('../playwright'),
|
|
84
87
|
'promise-js': () => require('../promise-js'),
|
|
85
88
|
'promise': () => require('../promise'),
|
|
86
89
|
'q': () => require('../q'),
|
|
@@ -12,7 +12,6 @@ const errorChannel = channel('apm:next:request:error')
|
|
|
12
12
|
const pageLoadChannel = channel('apm:next:page:load')
|
|
13
13
|
|
|
14
14
|
const requests = new WeakSet()
|
|
15
|
-
const requestToNextjsPagePath = new WeakMap()
|
|
16
15
|
|
|
17
16
|
function wrapHandleRequest (handleRequest) {
|
|
18
17
|
return function (req, res, pathname, query) {
|
|
@@ -29,9 +28,9 @@ function wrapHandleApiRequest (handleApiRequest) {
|
|
|
29
28
|
if (!handled) return handled
|
|
30
29
|
|
|
31
30
|
return this.hasPage(pathname).then(pageFound => {
|
|
32
|
-
const
|
|
31
|
+
const pageData = pageFound ? { page: pathname } : getPageFromPath(pathname, this.dynamicRoutes)
|
|
33
32
|
|
|
34
|
-
pageLoadChannel.publish(
|
|
33
|
+
pageLoadChannel.publish(pageData)
|
|
35
34
|
|
|
36
35
|
return handled
|
|
37
36
|
})
|
|
@@ -84,15 +83,19 @@ function wrapFindPageComponents (findPageComponents) {
|
|
|
84
83
|
const result = findPageComponents.apply(this, arguments)
|
|
85
84
|
|
|
86
85
|
if (result) {
|
|
87
|
-
pageLoadChannel.publish(
|
|
86
|
+
pageLoadChannel.publish(getPagePath(pathname))
|
|
88
87
|
}
|
|
89
88
|
|
|
90
89
|
return result
|
|
91
90
|
}
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
function getPagePath (
|
|
95
|
-
|
|
93
|
+
function getPagePath (maybePage) {
|
|
94
|
+
if (typeof maybePage !== 'object') return { page: maybePage }
|
|
95
|
+
|
|
96
|
+
const isAppPath = maybePage.isAppPath
|
|
97
|
+
const page = maybePage.pathname || maybePage.page
|
|
98
|
+
return { page, isAppPath }
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
function getPageFromPath (page, dynamicRoutes = []) {
|
|
@@ -133,57 +136,16 @@ function instrument (req, res, handler) {
|
|
|
133
136
|
})
|
|
134
137
|
}
|
|
135
138
|
|
|
136
|
-
function
|
|
137
|
-
return function (
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function wrapInitialize (initialize) {
|
|
144
|
-
return async function () {
|
|
145
|
-
const result = await initialize.apply(this, arguments)
|
|
146
|
-
if (Array.isArray(result)) {
|
|
147
|
-
const requestHandler = result[0]
|
|
148
|
-
result[0] = shimmer.wrap(requestHandler, wrapRequestHandler(requestHandler))
|
|
149
|
-
}
|
|
150
|
-
return result
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function wrapRequestHandler (requestHandler) {
|
|
155
|
-
return function (req, res) {
|
|
156
|
-
return instrument(req, res, async () => {
|
|
157
|
-
const result = await requestHandler.apply(this, arguments) // apply here first to get page path association
|
|
158
|
-
|
|
159
|
-
const page = requestToNextjsPagePath.get(req)
|
|
160
|
-
if (page && pageLoadChannel.hasSubscribers) pageLoadChannel.publish({ page })
|
|
139
|
+
function wrapServeStatic (serveStatic) {
|
|
140
|
+
return function (req, res, path) {
|
|
141
|
+
return instrument(req, res, () => {
|
|
142
|
+
if (pageLoadChannel.hasSubscribers && path) pageLoadChannel.publish({ page: path })
|
|
161
143
|
|
|
162
|
-
return
|
|
144
|
+
return serveStatic.apply(this, arguments)
|
|
163
145
|
})
|
|
164
146
|
}
|
|
165
147
|
}
|
|
166
148
|
|
|
167
|
-
// these two functions make sure we get path groups for routes in standalone,
|
|
168
|
-
// as it doesn't route through `next-server`/`base-server`
|
|
169
|
-
function wrapGetResolveRoutes (getResolveRoutes) {
|
|
170
|
-
return function () {
|
|
171
|
-
const result = getResolveRoutes.apply(this, arguments)
|
|
172
|
-
return shimmer.wrap(result, wrapResolveRoutes(result))
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function wrapResolveRoutes (resolveRoutes) {
|
|
177
|
-
return async function (req) {
|
|
178
|
-
const result = await resolveRoutes.apply(this, arguments)
|
|
179
|
-
if (result && result.matchedOutput) {
|
|
180
|
-
const path = result.matchedOutput.itemPath
|
|
181
|
-
requestToNextjsPagePath.set(req, path)
|
|
182
|
-
}
|
|
183
|
-
return result
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
149
|
function finish (ctx, result, err) {
|
|
188
150
|
if (err) {
|
|
189
151
|
ctx.error = err
|
|
@@ -201,25 +163,21 @@ function finish (ctx, result, err) {
|
|
|
201
163
|
|
|
202
164
|
addHook({
|
|
203
165
|
name: 'next',
|
|
204
|
-
versions: ['>=
|
|
205
|
-
file: 'dist/server/
|
|
206
|
-
},
|
|
166
|
+
versions: ['>=11.1'],
|
|
167
|
+
file: 'dist/server/serve-static.js'
|
|
168
|
+
}, serveStatic => shimmer.wrap(serveStatic, 'serveStatic', wrapServeStatic))
|
|
207
169
|
|
|
208
170
|
addHook({
|
|
209
171
|
name: 'next',
|
|
210
|
-
versions: ['
|
|
211
|
-
file: 'dist/server/
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
addHook({
|
|
215
|
-
name: 'next',
|
|
216
|
-
versions: ['>=13.4.15'],
|
|
217
|
-
file: 'dist/server/lib/router-server.js'
|
|
218
|
-
}, routerServer => shimmer.wrap(routerServer, 'initialize', wrapInitialize))
|
|
172
|
+
versions: DD_MAJOR >= 4 ? ['>=10.2 <11.1'] : ['>=9.5 <11.1'],
|
|
173
|
+
file: 'dist/next-server/server/serve-static.js'
|
|
174
|
+
}, serveStatic => shimmer.wrap(serveStatic, 'serveStatic', wrapServeStatic))
|
|
219
175
|
|
|
220
176
|
addHook({ name: 'next', versions: ['>=13.2'], file: 'dist/server/next-server.js' }, nextServer => {
|
|
221
177
|
const Server = nextServer.default
|
|
222
178
|
|
|
179
|
+
shimmer.wrap(Server.prototype, 'handleRequest', wrapHandleRequest)
|
|
180
|
+
shimmer.wrap(Server.prototype, 'handleApiRequest', wrapHandleApiRequestWithMatch)
|
|
223
181
|
shimmer.wrap(Server.prototype, 'renderToResponse', wrapRenderToResponse)
|
|
224
182
|
shimmer.wrap(Server.prototype, 'renderErrorToResponse', wrapRenderErrorToResponse)
|
|
225
183
|
shimmer.wrap(Server.prototype, 'findPageComponents', wrapFindPageComponents)
|
|
@@ -227,22 +185,6 @@ addHook({ name: 'next', versions: ['>=13.2'], file: 'dist/server/next-server.js'
|
|
|
227
185
|
return nextServer
|
|
228
186
|
})
|
|
229
187
|
|
|
230
|
-
// these functions wrapped in all versions above 13.2 except:
|
|
231
|
-
// 13.4.13 due to tests failing when these functions are wrapped
|
|
232
|
-
// 13.4.14 due to it not being in the NPM registry/officially released
|
|
233
|
-
addHook({
|
|
234
|
-
name: 'next',
|
|
235
|
-
versions: ['>=13.2 <13.4.13', '>=13.4.15'],
|
|
236
|
-
file: 'dist/server/next-server.js'
|
|
237
|
-
}, nextServer => {
|
|
238
|
-
const Server = nextServer.default
|
|
239
|
-
|
|
240
|
-
shimmer.wrap(Server.prototype, 'handleRequest', wrapHandleRequest)
|
|
241
|
-
shimmer.wrap(Server.prototype, 'handleApiRequest', wrapHandleApiRequestWithMatch)
|
|
242
|
-
|
|
243
|
-
return nextServer
|
|
244
|
-
})
|
|
245
|
-
|
|
246
188
|
addHook({ name: 'next', versions: ['>=11.1 <13.2'], file: 'dist/server/next-server.js' }, nextServer => {
|
|
247
189
|
const Server = nextServer.default
|
|
248
190
|
|
|
@@ -39,28 +39,27 @@ function wrapQuery (query) {
|
|
|
39
39
|
? arguments[0]
|
|
40
40
|
: { text: arguments[0] }
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
42
|
+
const textProp = Object.getOwnPropertyDescriptor(pgQuery, 'text')
|
|
43
|
+
|
|
44
|
+
// Only alter `text` property if safe to do so.
|
|
45
|
+
if (!textProp || textProp.configurable) {
|
|
46
|
+
const originalText = pgQuery.text
|
|
47
|
+
|
|
48
|
+
Object.defineProperty(pgQuery, 'text', {
|
|
49
|
+
get () {
|
|
50
|
+
return this?.__ddInjectableQuery || originalText
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
53
|
}
|
|
54
|
-
Object.setPrototypeOf(newQuery, pgQuery)
|
|
55
54
|
|
|
56
55
|
return asyncResource.runInAsyncScope(() => {
|
|
57
56
|
startCh.publish({
|
|
58
57
|
params: this.connectionParameters,
|
|
59
|
-
query:
|
|
58
|
+
query: pgQuery,
|
|
60
59
|
processId
|
|
61
60
|
})
|
|
62
61
|
|
|
63
|
-
arguments[0] =
|
|
62
|
+
arguments[0] = pgQuery
|
|
64
63
|
|
|
65
64
|
const finish = asyncResource.bind(function (error) {
|
|
66
65
|
if (error) {
|
|
@@ -73,7 +72,7 @@ function wrapQuery (query) {
|
|
|
73
72
|
const queryQueue = this.queryQueue || this._queryQueue
|
|
74
73
|
const activeQuery = this.activeQuery || this._activeQuery
|
|
75
74
|
|
|
76
|
-
newQuery = queryQueue[queryQueue.length - 1] || activeQuery
|
|
75
|
+
const newQuery = queryQueue[queryQueue.length - 1] || activeQuery
|
|
77
76
|
|
|
78
77
|
if (!newQuery) {
|
|
79
78
|
return retval
|
|
@@ -254,7 +254,7 @@ addHook({
|
|
|
254
254
|
addHook({
|
|
255
255
|
name: '@playwright/test',
|
|
256
256
|
file: 'lib/dispatcher.js',
|
|
257
|
-
versions: ['>=1.18.0
|
|
257
|
+
versions: ['>=1.18.0 <1.30.0']
|
|
258
258
|
}, dispatcherHook)
|
|
259
259
|
|
|
260
260
|
addHook({
|
|
@@ -266,11 +266,23 @@ addHook({
|
|
|
266
266
|
addHook({
|
|
267
267
|
name: '@playwright/test',
|
|
268
268
|
file: 'lib/runner/dispatcher.js',
|
|
269
|
-
versions: ['>=1.31.0']
|
|
269
|
+
versions: ['>=1.31.0 <1.38.0']
|
|
270
270
|
}, (dispatcher) => dispatcherHookNew(dispatcher, dispatcherRunWrapperNew))
|
|
271
271
|
|
|
272
272
|
addHook({
|
|
273
273
|
name: '@playwright/test',
|
|
274
274
|
file: 'lib/runner/runner.js',
|
|
275
|
-
versions: ['>=1.31.0']
|
|
275
|
+
versions: ['>=1.31.0 <1.38.0']
|
|
276
276
|
}, runnerHook)
|
|
277
|
+
|
|
278
|
+
// From >=1.38.0
|
|
279
|
+
addHook({
|
|
280
|
+
name: 'playwright',
|
|
281
|
+
file: 'lib/runner/runner.js',
|
|
282
|
+
versions: ['>=1.38.0']
|
|
283
|
+
}, runnerHook)
|
|
284
|
+
addHook({
|
|
285
|
+
name: 'playwright',
|
|
286
|
+
file: 'lib/runner/dispatcher.js',
|
|
287
|
+
versions: ['>=1.38.0']
|
|
288
|
+
}, (dispatcher) => dispatcherHookNew(dispatcher, dispatcherRunWrapperNew))
|
|
@@ -9,7 +9,7 @@ class MySQLPlugin extends DatabasePlugin {
|
|
|
9
9
|
|
|
10
10
|
start (payload) {
|
|
11
11
|
const service = this.serviceName({ pluginConfig: this.config, dbConfig: payload.conf, system: this.system })
|
|
12
|
-
this.startSpan(this.operationName(), {
|
|
12
|
+
const span = this.startSpan(this.operationName(), {
|
|
13
13
|
service,
|
|
14
14
|
resource: payload.sql,
|
|
15
15
|
type: 'sql',
|
|
@@ -22,7 +22,7 @@ class MySQLPlugin extends DatabasePlugin {
|
|
|
22
22
|
[CLIENT_PORT_KEY]: payload.conf.port
|
|
23
23
|
}
|
|
24
24
|
})
|
|
25
|
-
payload.sql = this.injectDbmQuery(payload.sql, service)
|
|
25
|
+
payload.sql = this.injectDbmQuery(span, payload.sql, service)
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -50,7 +50,6 @@ class NextPlugin extends ServerPlugin {
|
|
|
50
50
|
|
|
51
51
|
const span = store.span
|
|
52
52
|
const error = span.context()._tags['error']
|
|
53
|
-
const page = span.context()._tags['next.page']
|
|
54
53
|
|
|
55
54
|
if (!this.config.validateStatus(res.statusCode) && !error) {
|
|
56
55
|
span.setTag('error', true)
|
|
@@ -60,14 +59,12 @@ class NextPlugin extends ServerPlugin {
|
|
|
60
59
|
'http.status_code': res.statusCode
|
|
61
60
|
})
|
|
62
61
|
|
|
63
|
-
if (page) web.setRoute(req, page)
|
|
64
|
-
|
|
65
62
|
this.config.hooks.request(span, req, res)
|
|
66
63
|
|
|
67
64
|
span.finish()
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
pageLoad ({ page }) {
|
|
67
|
+
pageLoad ({ page, isAppPath }) {
|
|
71
68
|
const store = storage.getStore()
|
|
72
69
|
|
|
73
70
|
if (!store) return
|
|
@@ -77,15 +74,27 @@ class NextPlugin extends ServerPlugin {
|
|
|
77
74
|
|
|
78
75
|
// Only use error page names if there's not already a name
|
|
79
76
|
const current = span.context()._tags['next.page']
|
|
80
|
-
if (current &&
|
|
77
|
+
if (current && ['/404', '/500', '/_error', '/_not-found'].includes(page)) {
|
|
81
78
|
return
|
|
82
79
|
}
|
|
83
80
|
|
|
81
|
+
// remove ending /route or /page for appDir projects
|
|
82
|
+
if (isAppPath) page = page.substring(0, page.lastIndexOf('/'))
|
|
83
|
+
|
|
84
|
+
// This is for static files whose 'page' includes the whole file path
|
|
85
|
+
// For normal page matches, like /api/hello/[name] and a req.url like /api/hello/world,
|
|
86
|
+
// nothing should happen
|
|
87
|
+
// For page matches like /User/something/public/text.txt and req.url like /text.txt,
|
|
88
|
+
// it should disregard the extra absolute path Next.js sometimes sets
|
|
89
|
+
if (page.includes(req.url)) page = req.url
|
|
90
|
+
|
|
84
91
|
span.addTags({
|
|
85
92
|
[COMPONENT]: this.constructor.id,
|
|
86
93
|
'resource.name': `${req.method} ${page}`.trim(),
|
|
87
94
|
'next.page': page
|
|
88
95
|
})
|
|
96
|
+
|
|
97
|
+
web.setRoute(req, page)
|
|
89
98
|
}
|
|
90
99
|
|
|
91
100
|
configure (config) {
|
|
@@ -12,7 +12,7 @@ class PGPlugin extends DatabasePlugin {
|
|
|
12
12
|
const service = this.serviceName({ pluginConfig: this.config, params })
|
|
13
13
|
const originalStatement = this.maybeTruncate(query.text)
|
|
14
14
|
|
|
15
|
-
this.startSpan(this.operationName(), {
|
|
15
|
+
const span = this.startSpan(this.operationName(), {
|
|
16
16
|
service,
|
|
17
17
|
resource: originalStatement,
|
|
18
18
|
type: 'sql',
|
|
@@ -27,7 +27,7 @@ class PGPlugin extends DatabasePlugin {
|
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
query.__ddInjectableQuery = this.injectDbmQuery(query.text, service, !!query.name)
|
|
30
|
+
query.__ddInjectableQuery = this.injectDbmQuery(span, query.text, service, !!query.name)
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -5,6 +5,7 @@ const dc = require('../../../diagnostics_channel')
|
|
|
5
5
|
// TODO: use TBD naming convention
|
|
6
6
|
module.exports = {
|
|
7
7
|
bodyParser: dc.channel('datadog:body-parser:read:finish'),
|
|
8
|
+
cookieParser: dc.channel('datadog:cookie-parser:read:finish'),
|
|
8
9
|
graphqlFinishExecute: dc.channel('apm:graphql:execute:finish'),
|
|
9
10
|
incomingHttpRequestStart: dc.channel('dd-trace:incomingHttpRequestStart'),
|
|
10
11
|
incomingHttpRequestEnd: dc.channel('dd-trace:incomingHttpRequestEnd'),
|