dd-trace 4.0.0 → 4.1.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/MIGRATING.md +39 -0
- package/README.md +18 -11
- package/package.json +2 -2
- package/packages/datadog-instrumentations/src/cucumber.js +13 -0
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/http/client.js +2 -1
- package/packages/datadog-instrumentations/src/http/server.js +14 -0
- package/packages/datadog-instrumentations/src/http2/client.js +4 -0
- package/packages/datadog-instrumentations/src/jest.js +2 -3
- package/packages/datadog-instrumentations/src/next.js +2 -2
- package/packages/datadog-instrumentations/src/playwright.js +1 -1
- package/packages/datadog-instrumentations/src/sequelize.js +51 -0
- package/packages/datadog-plugin-amqp10/src/consumer.js +1 -3
- package/packages/datadog-plugin-amqp10/src/producer.js +1 -3
- package/packages/datadog-plugin-amqplib/src/client.js +4 -3
- package/packages/datadog-plugin-amqplib/src/consumer.js +1 -3
- package/packages/datadog-plugin-amqplib/src/producer.js +1 -3
- package/packages/datadog-plugin-cucumber/src/index.js +2 -2
- package/packages/datadog-plugin-cypress/src/plugin.js +150 -30
- package/packages/datadog-plugin-cypress/src/support.js +6 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +4 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -3
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +1 -3
- package/packages/datadog-plugin-http/src/client.js +70 -68
- package/packages/datadog-plugin-http2/src/client.js +50 -47
- package/packages/datadog-plugin-jest/src/index.js +5 -4
- package/packages/datadog-plugin-kafkajs/src/consumer.js +1 -4
- package/packages/datadog-plugin-kafkajs/src/producer.js +1 -3
- package/packages/datadog-plugin-memcached/src/index.js +2 -3
- package/packages/datadog-plugin-mocha/src/index.js +4 -2
- package/packages/datadog-plugin-pg/src/index.js +1 -1
- package/packages/datadog-plugin-redis/src/index.js +2 -13
- package/packages/datadog-plugin-rhea/src/consumer.js +1 -3
- package/packages/datadog-plugin-rhea/src/producer.js +1 -5
- package/packages/dd-trace/src/appsec/blocked_templates.js +2 -101
- package/packages/dd-trace/src/appsec/blocking.js +60 -11
- package/packages/dd-trace/src/appsec/channels.js +3 -2
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +7 -5
- package/packages/dd-trace/src/appsec/iast/analyzers/index.js +3 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/insecure-cookie-analyzer.js +31 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +4 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/set-cookies-header-interceptor.js +47 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +30 -5
- package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +26 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +35 -3
- package/packages/dd-trace/src/appsec/iast/path-line.js +14 -7
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +19 -4
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +25 -2
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +49 -0
- package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +3 -1
- package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +7 -5
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +0 -33
- package/packages/dd-trace/src/appsec/recommended.json +45 -46
- package/packages/dd-trace/src/appsec/remote_config/capabilities.js +3 -1
- package/packages/dd-trace/src/appsec/remote_config/index.js +4 -0
- package/packages/dd-trace/src/appsec/rule_manager.js +49 -6
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -7
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +1 -1
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +1 -6
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -4
- package/packages/dd-trace/src/config.js +29 -2
- package/packages/dd-trace/src/encode/coverage-ci-visibility.js +11 -3
- package/packages/dd-trace/src/exporters/common/util.js +9 -0
- package/packages/dd-trace/src/exporters/common/writer.js +3 -2
- package/packages/dd-trace/src/plugin_manager.js +2 -0
- package/packages/dd-trace/src/plugins/cache.js +7 -0
- package/packages/dd-trace/src/plugins/ci_plugin.js +2 -0
- package/packages/dd-trace/src/plugins/client.js +3 -2
- package/packages/dd-trace/src/plugins/consumer.js +14 -2
- package/packages/dd-trace/src/plugins/database.js +2 -2
- package/packages/dd-trace/src/plugins/inbound.js +7 -0
- package/packages/dd-trace/src/plugins/{outgoing.js → outbound.js} +2 -2
- package/packages/dd-trace/src/plugins/producer.js +19 -2
- package/packages/dd-trace/src/plugins/server.js +2 -2
- package/packages/dd-trace/src/plugins/storage.js +2 -0
- package/packages/dd-trace/src/plugins/tracing.js +11 -0
- package/packages/dd-trace/src/plugins/util/ci.js +1 -1
- package/packages/dd-trace/src/profiling/config.js +4 -2
- package/packages/dd-trace/src/service-naming/index.js +30 -0
- package/packages/dd-trace/src/service-naming/schemas/definition.js +24 -0
- package/packages/dd-trace/src/service-naming/schemas/index.js +6 -0
- package/packages/dd-trace/src/service-naming/schemas/util.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/index.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +64 -0
- package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +33 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/index.js +5 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +52 -0
- package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +21 -0
- package/packages/dd-trace/src/tracer.js +3 -3
- package/version.js +8 -4
- package/packages/dd-trace/src/plugins/incoming.js +0 -7
package/MIGRATING.md
CHANGED
|
@@ -4,6 +4,45 @@ This guide describes the steps to upgrade dd-trace from a major version to the
|
|
|
4
4
|
next. If you are having any issues related to migrating, please feel free to
|
|
5
5
|
open an issue or contact our [support](https://www.datadoghq.com/support/) team.
|
|
6
6
|
|
|
7
|
+
## 3.0 to 4.0
|
|
8
|
+
|
|
9
|
+
### Node 14 is no longer supported
|
|
10
|
+
|
|
11
|
+
Node.js 14 has reached EOL in April 2023 and is no longer supported. Generally
|
|
12
|
+
speaking, we highly recommend always keeping Node.js up to date regardless of
|
|
13
|
+
our support policy.
|
|
14
|
+
|
|
15
|
+
### The `orphanable` option was removed
|
|
16
|
+
|
|
17
|
+
This option was only useful internally for a single integration that has since
|
|
18
|
+
been removed. It was never useful for manual instrumentation since all that is
|
|
19
|
+
needed to orphan a span on creation is to use
|
|
20
|
+
`tracer.trace('web.request', { childOf: null })`.
|
|
21
|
+
|
|
22
|
+
### Support for `jest-jasmine2` has been removed
|
|
23
|
+
|
|
24
|
+
The default test runner for Jest was changed to `jest-circus` around 2 years ago and
|
|
25
|
+
is no longer supported by our Jest integration for CI Visibility. We recommend
|
|
26
|
+
switching to `jest-circus` to anyone still using `jest-jasmine2`.
|
|
27
|
+
|
|
28
|
+
### Support for older Next.js versions was removed
|
|
29
|
+
|
|
30
|
+
We now support only Next.js 10.2 and up.
|
|
31
|
+
|
|
32
|
+
### W3C headers are now prioritized over Datadog headers
|
|
33
|
+
|
|
34
|
+
As we move towards open standards, we have decided to prioritize W3C Trace
|
|
35
|
+
Context headers over our own vendor-specific headers for context propagation
|
|
36
|
+
across services. For most applications this shouldn't change anything and
|
|
37
|
+
distributed tracing should continue to work seamlessly.
|
|
38
|
+
|
|
39
|
+
In some rare cases it's possible that some of the services involved in a trace
|
|
40
|
+
are not instrumented by Datadog at all which can cause spans within the trace to
|
|
41
|
+
become disconnected. While the data would still be available in the UI, the
|
|
42
|
+
relationship between spans would no longer be visible. This can be addressed by
|
|
43
|
+
restoring the previous behaviour using
|
|
44
|
+
`DD_TRACE_PROPAGATION_STYLE='datadog,tracecontext'`.
|
|
45
|
+
|
|
7
46
|
## 2.0 to 3.0
|
|
8
47
|
|
|
9
48
|
### Node 12 is no longer supported
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# `dd-trace`: Node.js APM Tracer Library
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/dd-trace)
|
|
4
|
+
[](https://www.npmjs.com/package/dd-trace/v/latest-node12)
|
|
4
5
|
[](https://www.npmjs.com/package/dd-trace/v/latest-node12)
|
|
5
6
|
[](https://www.npmjs.com/package/dd-trace/v/dev)
|
|
6
7
|
[](https://codecov.io/gh/DataDog/dd-trace-js)
|
|
@@ -28,27 +29,28 @@ Most of the documentation for `dd-trace` is available on these webpages:
|
|
|
28
29
|
| :---: | :---: | :---: | :---: | :---: | :---: |
|
|
29
30
|
| [`v1`](https://github.com/DataDog/dd-trace-js/tree/v1.x) |  | `>= v12` | **End of Life** | 2021-07-13 | 2022-02-25 |
|
|
30
31
|
| [`v2`](https://github.com/DataDog/dd-trace-js/tree/v2.x) |  | `>= v12` | **Maintenance** | 2022-01-28 | 2023-08-15 |
|
|
31
|
-
| [`v3`](https://github.com/DataDog/dd-trace-js/tree/v3.x) | 
|
|
32
|
+
| [`v3`](https://github.com/DataDog/dd-trace-js/tree/v3.x) |  | `>= v14` | **Maintenance** | 2022-08-15 | 2024-05-15 |
|
|
33
|
+
| [`v4`](https://github.com/DataDog/dd-trace-js/tree/v4.x) |  | `>= v16` | **Current** | 2023-05-12 | Unknown |
|
|
32
34
|
|
|
33
|
-
We currently maintain
|
|
34
|
-
Features and bug fixes that are merged are released to the `
|
|
35
|
+
We currently maintain three release lines, namely `v2`, `v3` and `v4`.
|
|
36
|
+
Features and bug fixes that are merged are released to the `v4` line and, if appropriate, also the `v2` and `v3` line.
|
|
35
37
|
|
|
36
|
-
For any new projects it is recommended to use the `
|
|
38
|
+
For any new projects it is recommended to use the `v4` release line:
|
|
37
39
|
|
|
38
40
|
```sh
|
|
39
41
|
$ npm install dd-trace
|
|
40
42
|
$ yarn add dd-trace
|
|
41
43
|
```
|
|
42
44
|
|
|
43
|
-
However, existing projects that already use the `v2` release
|
|
45
|
+
However, existing projects that already use the `v2` or `v3` release lines, or projects that need to support EOL versions of Node.js, may continue to use these release lines.
|
|
44
46
|
This is done by specifying the version when installing the package.
|
|
45
|
-
Note that we also publish to npm using a `latest-node12` tag that can also be used for install:
|
|
47
|
+
Note that we also publish to npm using a `latest-node12` and `latest-node14` tag that can also be used for install:
|
|
46
48
|
|
|
47
49
|
```sh
|
|
48
|
-
$ npm install dd-trace@
|
|
49
|
-
$ yarn add dd-trace@
|
|
50
|
-
$ npm install dd-trace@latest-
|
|
51
|
-
$ yarn add dd-trace@latest-
|
|
50
|
+
$ npm install dd-trace@3
|
|
51
|
+
$ yarn add dd-trace@3
|
|
52
|
+
$ npm install dd-trace@latest-node14
|
|
53
|
+
$ yarn add dd-trace@latest-node14
|
|
52
54
|
```
|
|
53
55
|
|
|
54
56
|
Any backwards-breaking functionality that is introduced into the library will result in an increase of the major version of the library and therefore a new release line.
|
|
@@ -153,6 +155,11 @@ $ yarn lint
|
|
|
153
155
|
|
|
154
156
|
### Experimental ESM Support
|
|
155
157
|
|
|
158
|
+
> **Warning**
|
|
159
|
+
>
|
|
160
|
+
> ESM support has been temporarily disabled starting from Node 20 as significant
|
|
161
|
+
> changes are in progress.
|
|
162
|
+
|
|
156
163
|
ESM support is currently in the experimental stages, while CJS has been supported
|
|
157
164
|
since inception. This means that code loaded using `require()` should work fine
|
|
158
165
|
but code loaded using `import` might not always work.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"node": ">=16"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@datadog/native-appsec": "^3.
|
|
69
|
+
"@datadog/native-appsec": "^3.2.0",
|
|
70
70
|
"@datadog/native-iast-rewriter": "2.0.1",
|
|
71
71
|
"@datadog/native-iast-taint-tracking": "^1.4.1",
|
|
72
72
|
"@datadog/native-metrics": "^2.0.0",
|
|
@@ -3,6 +3,7 @@ const { createCoverageMap } = require('istanbul-lib-coverage')
|
|
|
3
3
|
|
|
4
4
|
const { addHook, channel, AsyncResource } = require('./helpers/instrument')
|
|
5
5
|
const shimmer = require('../../datadog-shimmer')
|
|
6
|
+
const log = require('../../dd-trace/src/log')
|
|
6
7
|
|
|
7
8
|
const testStartCh = channel('ci:cucumber:test:start')
|
|
8
9
|
const testFinishCh = channel('ci:cucumber:test:finish') // used for test steps too
|
|
@@ -175,6 +176,12 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
175
176
|
}
|
|
176
177
|
|
|
177
178
|
function pickleHook (PickleRunner) {
|
|
179
|
+
if (process.env.CUCUMBER_WORKER_ID) {
|
|
180
|
+
// Parallel mode is not supported
|
|
181
|
+
log.warn('Unable to initialize CI Visibility because Cucumber is running in parallel mode.')
|
|
182
|
+
return PickleRunner
|
|
183
|
+
}
|
|
184
|
+
|
|
178
185
|
const pl = PickleRunner.default
|
|
179
186
|
|
|
180
187
|
wrapRun(pl, false)
|
|
@@ -183,6 +190,12 @@ function pickleHook (PickleRunner) {
|
|
|
183
190
|
}
|
|
184
191
|
|
|
185
192
|
function testCaseHook (TestCaseRunner) {
|
|
193
|
+
if (process.env.CUCUMBER_WORKER_ID) {
|
|
194
|
+
// Parallel mode is not supported
|
|
195
|
+
log.warn('Unable to initialize CI Visibility because Cucumber is running in parallel mode.')
|
|
196
|
+
return TestCaseRunner
|
|
197
|
+
}
|
|
198
|
+
|
|
186
199
|
const pl = TestCaseRunner.default
|
|
187
200
|
|
|
188
201
|
wrapRun(pl, true)
|
|
@@ -80,6 +80,7 @@ module.exports = {
|
|
|
80
80
|
'rhea': () => require('../rhea'),
|
|
81
81
|
'router': () => require('../router'),
|
|
82
82
|
'sharedb': () => require('../sharedb'),
|
|
83
|
+
'sequelize': () => require('../sequelize'),
|
|
83
84
|
'tedious': () => require('../tedious'),
|
|
84
85
|
'when': () => require('../when'),
|
|
85
86
|
'winston': () => require('../winston')
|
|
@@ -101,6 +101,7 @@ function patch (http, methodName) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
function normalizeArgs (inputURL, inputOptions, cb) {
|
|
104
|
+
const originalUrl = inputURL
|
|
104
105
|
inputURL = normalizeOptions(inputURL)
|
|
105
106
|
|
|
106
107
|
const [callback, inputOptionsNormalized] = normalizeCallback(inputOptions, cb, inputURL)
|
|
@@ -108,7 +109,7 @@ function patch (http, methodName) {
|
|
|
108
109
|
normalizeHeaders(options)
|
|
109
110
|
const uri = url.format(options)
|
|
110
111
|
|
|
111
|
-
return { uri, options, callback }
|
|
112
|
+
return { uri, options, callback, originalUrl }
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
function combineOptions (inputURL, inputOptions) {
|
|
@@ -11,6 +11,7 @@ const startServerCh = channel('apm:http:server:request:start')
|
|
|
11
11
|
const exitServerCh = channel('apm:http:server:request:exit')
|
|
12
12
|
const errorServerCh = channel('apm:http:server:request:error')
|
|
13
13
|
const finishServerCh = channel('apm:http:server:request:finish')
|
|
14
|
+
const finishSetHeaderCh = channel('datadog:http:server:response:set-header:finish')
|
|
14
15
|
|
|
15
16
|
const requestFinishedSet = new WeakSet()
|
|
16
17
|
|
|
@@ -58,6 +59,9 @@ function wrapEmit (emit) {
|
|
|
58
59
|
// TODO: should this always return true ?
|
|
59
60
|
return this.listenerCount(eventName) > 0
|
|
60
61
|
}
|
|
62
|
+
if (finishSetHeaderCh.hasSubscribers) {
|
|
63
|
+
wrapSetHeader(res)
|
|
64
|
+
}
|
|
61
65
|
return emit.apply(this, arguments)
|
|
62
66
|
} catch (err) {
|
|
63
67
|
errorServerCh.publish(err)
|
|
@@ -70,3 +74,13 @@ function wrapEmit (emit) {
|
|
|
70
74
|
return emit.apply(this, arguments)
|
|
71
75
|
}
|
|
72
76
|
}
|
|
77
|
+
|
|
78
|
+
function wrapSetHeader (res) {
|
|
79
|
+
shimmer.wrap(res, 'setHeader', setHeader => {
|
|
80
|
+
return function (name, value) {
|
|
81
|
+
const setHeaderResult = setHeader.apply(this, arguments)
|
|
82
|
+
finishSetHeaderCh.publish({ name, value, res })
|
|
83
|
+
return setHeaderResult
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const shimmer = require('../../../datadog-shimmer')
|
|
4
4
|
const { addHook, channel, AsyncResource } = require('../helpers/instrument')
|
|
5
5
|
|
|
6
|
+
const connectChannel = channel('apm:http2:client:connect:start')
|
|
6
7
|
const startChannel = channel('apm:http2:client:request:start')
|
|
7
8
|
const finishChannel = channel('apm:http2:client:request:finish')
|
|
8
9
|
const errorChannel = channel('apm:http2:client:request:error')
|
|
@@ -52,6 +53,9 @@ function createWrapRequest (authority, options) {
|
|
|
52
53
|
|
|
53
54
|
function wrapConnect (connect) {
|
|
54
55
|
return function (authority, options) {
|
|
56
|
+
if (connectChannel.hasSubscribers) {
|
|
57
|
+
connectChannel.publish({ authority })
|
|
58
|
+
}
|
|
55
59
|
const session = connect.apply(this, arguments)
|
|
56
60
|
|
|
57
61
|
shimmer.wrap(session, 'request', createWrapRequest(authority, options))
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use strict'
|
|
2
|
-
const semver = require('semver')
|
|
3
2
|
|
|
4
3
|
const { addHook, channel, AsyncResource } = require('./helpers/instrument')
|
|
5
4
|
const shimmer = require('../../datadog-shimmer')
|
|
6
5
|
const log = require('../../dd-trace/src/log')
|
|
7
|
-
const { version: ddTraceVersion } = require('../../../package.json')
|
|
8
6
|
const {
|
|
9
7
|
getCoveredFilenamesFromCoverage,
|
|
10
8
|
JEST_WORKER_TRACE_PAYLOAD_CODE,
|
|
@@ -18,6 +16,7 @@ const {
|
|
|
18
16
|
getJestTestName,
|
|
19
17
|
getJestSuitesToRun
|
|
20
18
|
} = require('../../datadog-plugin-jest/src/util')
|
|
19
|
+
const { DD_MAJOR } = require('../../../version')
|
|
21
20
|
|
|
22
21
|
const testSessionStartCh = channel('ci:jest:session:start')
|
|
23
22
|
const testSessionFinishCh = channel('ci:jest:session:finish')
|
|
@@ -481,7 +480,7 @@ function jasmineAsyncInstallWraper (jasmineAsyncInstallExport, jestVersion) {
|
|
|
481
480
|
}
|
|
482
481
|
}
|
|
483
482
|
|
|
484
|
-
if (
|
|
483
|
+
if (DD_MAJOR < 4) {
|
|
485
484
|
addHook({
|
|
486
485
|
name: 'jest-jasmine2',
|
|
487
486
|
versions: ['>=24.8.0'],
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
const { channel, addHook, AsyncResource } = require('./helpers/instrument')
|
|
6
6
|
const shimmer = require('../../datadog-shimmer')
|
|
7
|
-
const {
|
|
7
|
+
const { DD_MAJOR } = require('../../../version')
|
|
8
8
|
|
|
9
9
|
const startChannel = channel('apm:next:request:start')
|
|
10
10
|
const finishChannel = channel('apm:next:request:finish')
|
|
@@ -171,7 +171,7 @@ addHook({ name: 'next', versions: ['>=11.1 <13.2'], file: 'dist/server/next-serv
|
|
|
171
171
|
|
|
172
172
|
addHook({
|
|
173
173
|
name: 'next',
|
|
174
|
-
versions:
|
|
174
|
+
versions: DD_MAJOR >= 4 ? ['>=10.2 <11.1'] : ['>=9.5 <11.1'],
|
|
175
175
|
file: 'dist/next-server/server/next-server.js'
|
|
176
176
|
}, nextServer => {
|
|
177
177
|
const Server = nextServer.default
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
channel,
|
|
5
|
+
addHook,
|
|
6
|
+
AsyncResource
|
|
7
|
+
} = require('./helpers/instrument')
|
|
8
|
+
|
|
9
|
+
const shimmer = require('../../datadog-shimmer')
|
|
10
|
+
|
|
11
|
+
addHook({ name: 'sequelize', versions: ['>=4'] }, Sequelize => {
|
|
12
|
+
const startCh = channel('datadog:sequelize:query:start')
|
|
13
|
+
const finishCh = channel('datadog:sequelize:query:finish')
|
|
14
|
+
|
|
15
|
+
shimmer.wrap(Sequelize.prototype, 'query', query => {
|
|
16
|
+
return function (sql) {
|
|
17
|
+
if (!startCh.hasSubscribers) {
|
|
18
|
+
return query.apply(this, arguments)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
22
|
+
|
|
23
|
+
let dialect
|
|
24
|
+
if (this.options && this.options.dialect) {
|
|
25
|
+
dialect = this.options.dialect
|
|
26
|
+
} else if (this.dialect && this.dialect.name) {
|
|
27
|
+
dialect = this.dialect.name
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function onFinish () {
|
|
31
|
+
asyncResource.bind(function () {
|
|
32
|
+
finishCh.publish()
|
|
33
|
+
}, this).apply(this)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return asyncResource.bind(function () {
|
|
37
|
+
startCh.publish({
|
|
38
|
+
sql,
|
|
39
|
+
dialect
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const promise = query.apply(this, arguments)
|
|
43
|
+
promise.then(onFinish, onFinish)
|
|
44
|
+
|
|
45
|
+
return promise
|
|
46
|
+
}, this).apply(this, arguments)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
return Sequelize
|
|
51
|
+
})
|
|
@@ -11,11 +11,9 @@ class Amqp10ConsumerPlugin extends ConsumerPlugin {
|
|
|
11
11
|
const source = getShortName(link)
|
|
12
12
|
const address = getAddress(link)
|
|
13
13
|
|
|
14
|
-
this.startSpan(
|
|
15
|
-
service: this.config.service || `${this.tracer._service}-amqp`,
|
|
14
|
+
this.startSpan({
|
|
16
15
|
resource: ['receive', source].filter(v => v).join(' '),
|
|
17
16
|
type: 'worker',
|
|
18
|
-
kind: 'consumer',
|
|
19
17
|
meta: {
|
|
20
18
|
'amqp.link.source.address': source,
|
|
21
19
|
'amqp.link.role': 'receiver',
|
|
@@ -13,10 +13,8 @@ class Amqp10ProducerPlugin extends ProducerPlugin {
|
|
|
13
13
|
const address = getAddress(link)
|
|
14
14
|
const target = getShortName(link)
|
|
15
15
|
|
|
16
|
-
this.startSpan(
|
|
17
|
-
service: this.config.service || `${this.tracer._service}-amqp`,
|
|
16
|
+
this.startSpan({
|
|
18
17
|
resource: ['send', target].filter(v => v).join(' '),
|
|
19
|
-
kind: 'producer',
|
|
20
18
|
meta: {
|
|
21
19
|
'amqp.link.target.address': target,
|
|
22
20
|
'amqp.link.role': 'sender',
|
|
@@ -7,6 +7,7 @@ const { getResourceName } = require('./util')
|
|
|
7
7
|
|
|
8
8
|
class AmqplibClientPlugin extends ClientPlugin {
|
|
9
9
|
static get id () { return 'amqplib' }
|
|
10
|
+
static get type () { return 'messaging' }
|
|
10
11
|
static get operation () { return 'command' }
|
|
11
12
|
|
|
12
13
|
start ({ channel = {}, method, fields }) {
|
|
@@ -14,10 +15,10 @@ class AmqplibClientPlugin extends ClientPlugin {
|
|
|
14
15
|
if (method === 'basic.publish') return
|
|
15
16
|
|
|
16
17
|
const stream = (channel.connection && channel.connection.stream) || {}
|
|
17
|
-
const span = this.startSpan(
|
|
18
|
-
service: this.config.service ||
|
|
18
|
+
const span = this.startSpan(this.operationName(), {
|
|
19
|
+
service: this.config.service || this.serviceName(),
|
|
19
20
|
resource: getResourceName(method, fields),
|
|
20
|
-
kind:
|
|
21
|
+
kind: this.constructor.kind,
|
|
21
22
|
meta: {
|
|
22
23
|
'out.host': stream._host,
|
|
23
24
|
[CLIENT_PORT_KEY]: stream.remotePort,
|
|
@@ -13,11 +13,9 @@ class AmqplibConsumerPlugin extends ConsumerPlugin {
|
|
|
13
13
|
|
|
14
14
|
const childOf = extract(this.tracer, message)
|
|
15
15
|
|
|
16
|
-
this.startSpan(
|
|
16
|
+
this.startSpan({
|
|
17
17
|
childOf,
|
|
18
|
-
service: this.config.service || `${this.tracer._service}-amqp`,
|
|
19
18
|
resource: getResourceName(method, fields),
|
|
20
|
-
kind: 'consumer',
|
|
21
19
|
type: 'worker',
|
|
22
20
|
meta: {
|
|
23
21
|
'amqp.queue': fields.queue,
|
|
@@ -13,10 +13,8 @@ class AmqplibProducerPlugin extends ProducerPlugin {
|
|
|
13
13
|
if (method !== 'basic.publish') return
|
|
14
14
|
|
|
15
15
|
const stream = (channel.connection && channel.connection.stream) || {}
|
|
16
|
-
const span = this.startSpan(
|
|
17
|
-
service: this.config.service || `${this.tracer._service}-amqp`,
|
|
16
|
+
const span = this.startSpan({
|
|
18
17
|
resource: getResourceName(method, fields),
|
|
19
|
-
kind: 'producer',
|
|
20
18
|
meta: {
|
|
21
19
|
'out.host': stream._host,
|
|
22
20
|
[CLIENT_PORT_KEY]: stream.remotePort,
|
|
@@ -73,8 +73,8 @@ class CucumberPlugin extends CiPlugin {
|
|
|
73
73
|
.map(filename => getTestSuitePath(filename, this.sourceRoot))
|
|
74
74
|
|
|
75
75
|
const formattedCoverage = {
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
sessionId: this.testSuiteSpan.context()._traceId,
|
|
77
|
+
suiteId: this.testSuiteSpan.context()._spanId,
|
|
78
78
|
files: relativeCoverageFiles
|
|
79
79
|
}
|
|
80
80
|
|