dd-trace 2.21.0 → 2.22.1
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 +2 -0
- package/index.d.ts +42 -31
- package/package.json +4 -2
- package/packages/datadog-instrumentations/src/body-parser.js +26 -0
- package/packages/datadog-instrumentations/src/child-process.js +30 -0
- package/packages/datadog-instrumentations/src/connect.js +15 -15
- package/packages/datadog-instrumentations/src/cucumber.js +1 -1
- package/packages/datadog-instrumentations/src/hapi.js +3 -3
- package/packages/datadog-instrumentations/src/helpers/hooks.js +5 -0
- package/packages/datadog-instrumentations/src/http/server.js +11 -12
- package/packages/datadog-instrumentations/src/jest.js +102 -42
- package/packages/datadog-instrumentations/src/koa.js +32 -32
- package/packages/datadog-instrumentations/src/mocha.js +87 -6
- package/packages/datadog-instrumentations/src/pg.js +1 -2
- package/packages/datadog-instrumentations/src/qs.js +24 -0
- package/packages/datadog-instrumentations/src/restify.js +6 -3
- package/packages/datadog-instrumentations/src/router.js +22 -22
- package/packages/datadog-plugin-cucumber/src/index.js +13 -32
- package/packages/datadog-plugin-cypress/src/plugin.js +2 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +0 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +0 -1
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +0 -1
- package/packages/datadog-plugin-http/src/client.js +5 -3
- package/packages/datadog-plugin-http/src/server.js +11 -0
- package/packages/datadog-plugin-http2/src/client.js +2 -0
- package/packages/datadog-plugin-http2/src/server.js +3 -0
- package/packages/datadog-plugin-jest/src/index.js +11 -131
- package/packages/datadog-plugin-mocha/src/index.js +33 -46
- package/packages/datadog-plugin-net/src/index.js +4 -0
- package/packages/datadog-plugin-next/src/index.js +3 -0
- package/packages/datadog-plugin-pg/src/index.js +5 -2
- package/packages/datadog-plugin-router/src/index.js +9 -1
- package/packages/dd-trace/src/appsec/callbacks/ddwaf.js +3 -5
- package/packages/dd-trace/src/appsec/gateway/engine/index.js +1 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +3 -1
- package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +11 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/injection-analyzer.js +19 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +13 -0
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/index.js +6 -0
- package/packages/dd-trace/src/appsec/iast/path-line.js +8 -1
- package/packages/dd-trace/src/appsec/iast/taint-tracking/filter.js +16 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +18 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +125 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/origin-types.js +4 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +38 -0
- package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +66 -0
- package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +52 -6
- package/packages/dd-trace/src/appsec/index.js +8 -0
- package/packages/dd-trace/src/appsec/remote_config/capabilities.js +7 -0
- package/packages/dd-trace/src/appsec/remote_config/index.js +34 -0
- package/packages/dd-trace/src/appsec/remote_config/manager.js +264 -0
- package/packages/dd-trace/src/{exporters → appsec/remote_config}/scheduler.js +9 -9
- package/packages/dd-trace/src/appsec/rule_manager.js +3 -0
- package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +5 -7
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +1 -3
- package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -3
- package/packages/dd-trace/src/config.js +25 -9
- package/packages/dd-trace/src/constants.js +6 -1
- package/packages/dd-trace/src/exporters/common/request.js +7 -1
- package/packages/dd-trace/src/format.js +12 -10
- package/packages/dd-trace/src/opentracing/propagation/text_map.js +1 -5
- package/packages/dd-trace/src/opentracing/span_context.js +9 -0
- package/packages/dd-trace/src/plugin_manager.js +4 -1
- package/packages/dd-trace/src/plugins/ci_plugin.js +132 -0
- package/packages/dd-trace/src/plugins/database.js +46 -0
- package/packages/dd-trace/src/plugins/tracing.js +2 -0
- package/packages/dd-trace/src/plugins/util/test.js +61 -8
- package/packages/dd-trace/src/plugins/util/web.js +14 -9
- package/packages/dd-trace/src/profiling/config.js +3 -1
- package/packages/dd-trace/src/profiling/index.js +2 -2
- package/packages/dd-trace/src/profiling/profiler.js +35 -6
- package/packages/dd-trace/src/proxy.js +5 -1
- package/packages/dd-trace/src/tracer.js +4 -3
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Component,Origin,License,Copyright
|
|
2
2
|
require,@datadog/native-appsec,Apache license 2.0,Copyright 2018 Datadog Inc.
|
|
3
3
|
require,@datadog/native-metrics,Apache license 2.0,Copyright 2018 Datadog Inc.
|
|
4
|
+
require,@datadog/native-iast-rewriter,Apache license 2.0,Copyright 2018 Datadog Inc.
|
|
5
|
+
require,@datadog/native-iast-taint-tracking,Apache license 2.0,Copyright 2018 Datadog Inc.
|
|
4
6
|
require,@datadog/pprof,Apache license 2.0,Copyright 2019 Google Inc.
|
|
5
7
|
require,@datadog/sketches-js,Apache license 2.0,Copyright 2020 Datadog Inc.
|
|
6
8
|
require,@types/node,MIT,Copyright Authors
|
package/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare interface Tracer extends opentracing.Tracer {
|
|
|
15
15
|
* @param {SpanOptions} [options] Options for the newly created span.
|
|
16
16
|
* @returns {Span} A new Span object.
|
|
17
17
|
*/
|
|
18
|
-
startSpan(name: string, options?: SpanOptions): Span;
|
|
18
|
+
startSpan (name: string, options?: SpanOptions): Span;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Injects the given SpanContext instance for cross-process propagation
|
|
@@ -27,7 +27,7 @@ export declare interface Tracer extends opentracing.Tracer {
|
|
|
27
27
|
* @param {string} format The format of the carrier.
|
|
28
28
|
* @param {any} carrier The carrier object.
|
|
29
29
|
*/
|
|
30
|
-
inject(spanContext: SpanContext | Span, format: string, carrier: any): void;
|
|
30
|
+
inject (spanContext: SpanContext | Span, format: string, carrier: any): void;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Returns a SpanContext instance extracted from `carrier` in the given
|
|
@@ -38,31 +38,31 @@ export declare interface Tracer extends opentracing.Tracer {
|
|
|
38
38
|
* The extracted SpanContext, or null if no such SpanContext could
|
|
39
39
|
* be found in `carrier`
|
|
40
40
|
*/
|
|
41
|
-
extract(format: string, carrier: any): SpanContext | null;
|
|
41
|
+
extract (format: string, carrier: any): SpanContext | null;
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Initializes the tracer. This should be called before importing other libraries.
|
|
45
45
|
*/
|
|
46
|
-
init(options?: TracerOptions): this;
|
|
46
|
+
init (options?: TracerOptions): this;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* Sets the URL for the trace agent. This should only be called _after_
|
|
50
50
|
* init() is called, only in cases where the URL needs to be set after
|
|
51
51
|
* initialization.
|
|
52
52
|
*/
|
|
53
|
-
setUrl(url: string): this;
|
|
53
|
+
setUrl (url: string): this;
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Enable and optionally configure a plugin.
|
|
57
57
|
* @param plugin The name of a built-in plugin.
|
|
58
58
|
* @param config Configuration options. Can also be `false` to disable the plugin.
|
|
59
59
|
*/
|
|
60
|
-
use<P extends keyof Plugins>(plugin: P, config?: Plugins[P] | boolean): this;
|
|
60
|
+
use<P extends keyof Plugins> (plugin: P, config?: Plugins[P] | boolean): this;
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Returns a reference to the current scope.
|
|
64
64
|
*/
|
|
65
|
-
scope(): Scope;
|
|
65
|
+
scope (): Scope;
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* Instruments a function by automatically creating a span activated on its
|
|
@@ -81,8 +81,8 @@ export declare interface Tracer extends opentracing.Tracer {
|
|
|
81
81
|
* If the `orphanable` option is set to false, the function will not be traced
|
|
82
82
|
* unless there is already an active span or `childOf` option.
|
|
83
83
|
*/
|
|
84
|
-
trace<T>(name: string, fn: (span?: Span, fn?: (error?: Error) => any) => T): T;
|
|
85
|
-
trace<T>(name: string, options: TraceOptions & SpanOptions, fn: (span?: Span, done?: (error?: Error) => string) => T): T;
|
|
84
|
+
trace<T> (name: string, fn: (span?: Span, fn?: (error?: Error) => any) => T): T;
|
|
85
|
+
trace<T> (name: string, options: TraceOptions & SpanOptions, fn: (span?: Span, done?: (error?: Error) => string) => T): T;
|
|
86
86
|
|
|
87
87
|
/**
|
|
88
88
|
* Wrap a function to automatically create a span activated on its
|
|
@@ -98,23 +98,23 @@ export declare interface Tracer extends opentracing.Tracer {
|
|
|
98
98
|
* * The function doesn't accept a callback and doesn't return a promise, in
|
|
99
99
|
* which case the span will finish at the end of the function execution.
|
|
100
100
|
*/
|
|
101
|
-
wrap<T = (...args: any[]) => any>(name: string, fn: T, requiresParent?: boolean): T;
|
|
102
|
-
wrap<T = (...args: any[]) => any>(name: string, options: TraceOptions & SpanOptions, fn: T): T;
|
|
103
|
-
wrap<T = (...args: any[]) => any>(name: string, options: (...args: any[]) => TraceOptions & SpanOptions, fn: T): T;
|
|
101
|
+
wrap<T = (...args: any[]) => any> (name: string, fn: T, requiresParent?: boolean): T;
|
|
102
|
+
wrap<T = (...args: any[]) => any> (name: string, options: TraceOptions & SpanOptions, fn: T): T;
|
|
103
|
+
wrap<T = (...args: any[]) => any> (name: string, options: (...args: any[]) => TraceOptions & SpanOptions, fn: T): T;
|
|
104
104
|
|
|
105
105
|
/**
|
|
106
106
|
* Create and return a string that can be included in the <head> of a
|
|
107
107
|
* document to enable RUM tracing to include it. The resulting string
|
|
108
108
|
* should not be cached.
|
|
109
109
|
*/
|
|
110
|
-
getRumData(): string;
|
|
110
|
+
getRumData (): string;
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* Links an authenticated user to the current trace.
|
|
114
114
|
* @param {User} user Properties of the authenticated user. Accepts custom fields.
|
|
115
115
|
* @returns {Tracer} The Tracer instance for chaining.
|
|
116
116
|
*/
|
|
117
|
-
setUser(user: User): Tracer;
|
|
117
|
+
setUser (user: User): Tracer;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
export declare interface TraceOptions extends Analyzable {
|
|
@@ -144,7 +144,7 @@ export declare interface TraceOptions extends Analyzable {
|
|
|
144
144
|
* have children.
|
|
145
145
|
*/
|
|
146
146
|
export declare interface Span extends opentracing.Span {
|
|
147
|
-
context(): SpanContext;
|
|
147
|
+
context (): SpanContext;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
/**
|
|
@@ -161,12 +161,17 @@ export declare interface SpanContext extends opentracing.SpanContext {
|
|
|
161
161
|
/**
|
|
162
162
|
* Returns the string representation of the internal trace ID.
|
|
163
163
|
*/
|
|
164
|
-
toTraceId(): string;
|
|
164
|
+
toTraceId (): string;
|
|
165
165
|
|
|
166
166
|
/**
|
|
167
167
|
* Returns the string representation of the internal span ID.
|
|
168
168
|
*/
|
|
169
|
-
toSpanId(): string;
|
|
169
|
+
toSpanId (): string;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Returns the string representation used for DBM integration.
|
|
173
|
+
*/
|
|
174
|
+
toTraceparent (): string;
|
|
170
175
|
}
|
|
171
176
|
|
|
172
177
|
/**
|
|
@@ -324,7 +329,7 @@ export declare interface TracerOptions {
|
|
|
324
329
|
* Number of spans before partially exporting a trace. This prevents keeping all the spans in memory for very large traces.
|
|
325
330
|
* @default 1000
|
|
326
331
|
*/
|
|
327
|
-
|
|
332
|
+
flushMinSpans?: number;
|
|
328
333
|
|
|
329
334
|
/**
|
|
330
335
|
* Whether to enable runtime metrics.
|
|
@@ -377,10 +382,10 @@ export declare interface TracerOptions {
|
|
|
377
382
|
runtimeId?: boolean
|
|
378
383
|
|
|
379
384
|
/**
|
|
380
|
-
* Whether to write traces to log output, rather than send to an agent
|
|
385
|
+
* Whether to write traces to log output or agentless, rather than send to an agent
|
|
381
386
|
* @default false
|
|
382
387
|
*/
|
|
383
|
-
exporter?: 'log' | 'agent'
|
|
388
|
+
exporter?: 'log' | 'agent' | 'datadog'
|
|
384
389
|
|
|
385
390
|
/**
|
|
386
391
|
* Whether to enable the experimental `getRumData` method.
|
|
@@ -391,7 +396,7 @@ export declare interface TracerOptions {
|
|
|
391
396
|
/**
|
|
392
397
|
* Configuration of the IAST. Can be a boolean as an alias to `iast.enabled`.
|
|
393
398
|
*/
|
|
394
|
-
iast?: boolean
|
|
399
|
+
iast?: boolean | {
|
|
395
400
|
/**
|
|
396
401
|
* Whether to enable IAST.
|
|
397
402
|
* @default false
|
|
@@ -463,6 +468,12 @@ export declare interface TracerOptions {
|
|
|
463
468
|
*/
|
|
464
469
|
orphanable?: boolean
|
|
465
470
|
|
|
471
|
+
/**
|
|
472
|
+
* Enables DBM to APM link using tag injection.
|
|
473
|
+
* @default 'disabled'
|
|
474
|
+
*/
|
|
475
|
+
dbmPropagationMode?: 'disabled' | 'service' | 'full'
|
|
476
|
+
|
|
466
477
|
/**
|
|
467
478
|
* Configuration of the AppSec protection. Can be a boolean as an alias to `appsec.enabled`.
|
|
468
479
|
*/
|
|
@@ -505,7 +516,7 @@ export declare interface TracerOptions {
|
|
|
505
516
|
/**
|
|
506
517
|
* User object that can be passed to `tracer.setUser()`.
|
|
507
518
|
*/
|
|
508
|
-
|
|
519
|
+
export declare interface User {
|
|
509
520
|
/**
|
|
510
521
|
* Unique identifier of the user.
|
|
511
522
|
* Mandatory.
|
|
@@ -577,7 +588,7 @@ export declare interface Scope {
|
|
|
577
588
|
*
|
|
578
589
|
* @returns {Span} The active span.
|
|
579
590
|
*/
|
|
580
|
-
active(): Span | null;
|
|
591
|
+
active (): Span | null;
|
|
581
592
|
|
|
582
593
|
/**
|
|
583
594
|
* Activate a span in the scope of a function.
|
|
@@ -586,7 +597,7 @@ export declare interface Scope {
|
|
|
586
597
|
* @param {Function} fn Function that will have the span activated on its scope.
|
|
587
598
|
* @returns The return value of the provided function.
|
|
588
599
|
*/
|
|
589
|
-
activate<T>(span: Span, fn: ((...args: any[]) => T)): T;
|
|
600
|
+
activate<T> (span: Span, fn: ((...args: any[]) => T)): T;
|
|
590
601
|
|
|
591
602
|
/**
|
|
592
603
|
* Binds a target to the provided span, or the active span if omitted.
|
|
@@ -595,9 +606,9 @@ export declare interface Scope {
|
|
|
595
606
|
* @param {Span} [span=scope.active()] The span to activate.
|
|
596
607
|
* @returns The bound target.
|
|
597
608
|
*/
|
|
598
|
-
bind<T extends (...args: any[]) => void>(fn: T, span?: Span | null): T;
|
|
599
|
-
bind<V, T extends (...args: any[]) => V>(fn: T, span?: Span | null): T;
|
|
600
|
-
bind<T>(fn: Promise<T>, span?: Span | null): Promise<T>;
|
|
609
|
+
bind<T extends (...args: any[]) => void> (fn: T, span?: Span | null): T;
|
|
610
|
+
bind<V, T extends (...args: any[]) => V> (fn: T, span?: Span | null): T;
|
|
611
|
+
bind<T> (fn: Promise<T>, span?: Span | null): Promise<T>;
|
|
601
612
|
bind(emitter: EventEmitter, span?: Span | null): EventEmitter;
|
|
602
613
|
}
|
|
603
614
|
|
|
@@ -1218,7 +1229,7 @@ declare namespace plugins {
|
|
|
1218
1229
|
* This plugin automatically instruments the
|
|
1219
1230
|
* [mariadb](https://github.com/mariadb-corporation/mariadb-connector-nodejs) module.
|
|
1220
1231
|
*/
|
|
1221
|
-
|
|
1232
|
+
interface mariadb extends mysql {}
|
|
1222
1233
|
|
|
1223
1234
|
/**
|
|
1224
1235
|
* This plugin automatically instruments the
|
|
@@ -1242,7 +1253,7 @@ declare namespace plugins {
|
|
|
1242
1253
|
* This plugin automatically instruments the
|
|
1243
1254
|
* [moleculer](https://moleculer.services/) module.
|
|
1244
1255
|
*/
|
|
1245
|
-
|
|
1256
|
+
interface moleculer extends Moleculer {
|
|
1246
1257
|
/**
|
|
1247
1258
|
* Configuration for Moleculer clients. Set to false to disable client
|
|
1248
1259
|
* instrumentation.
|
|
@@ -1296,7 +1307,7 @@ declare namespace plugins {
|
|
|
1296
1307
|
/**
|
|
1297
1308
|
* Hooks to run before spans are finished.
|
|
1298
1309
|
*/
|
|
1299
|
-
|
|
1310
|
+
hooks?: {
|
|
1300
1311
|
/**
|
|
1301
1312
|
* Hook to execute just before the request span finishes.
|
|
1302
1313
|
*/
|
|
@@ -1325,7 +1336,7 @@ declare namespace plugins {
|
|
|
1325
1336
|
* This plugin automatically instruments the
|
|
1326
1337
|
* [paperplane](https://github.com/articulate/paperplane) module.
|
|
1327
1338
|
*/
|
|
1328
|
-
|
|
1339
|
+
interface paperplane extends HttpServer {}
|
|
1329
1340
|
|
|
1330
1341
|
/**
|
|
1331
1342
|
* This plugin automatically instruments the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dd-trace",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.1",
|
|
4
4
|
"description": "Datadog APM tracing client for JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -58,7 +58,9 @@
|
|
|
58
58
|
"node": ">=12"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@datadog/native-appsec": "
|
|
61
|
+
"@datadog/native-appsec": "2.0.0",
|
|
62
|
+
"@datadog/native-iast-rewriter": "1.0.0",
|
|
63
|
+
"@datadog/native-iast-taint-tracking": "1.0.0",
|
|
62
64
|
"@datadog/native-metrics": "^1.5.0",
|
|
63
65
|
"@datadog/pprof": "^1.1.1",
|
|
64
66
|
"@datadog/sketches-js": "^2.1.0",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { channel, addHook, AsyncResource } = require('./helpers/instrument')
|
|
4
|
+
|
|
5
|
+
const bodyParserReadCh = channel('datadog:body-parser:read:finish')
|
|
6
|
+
|
|
7
|
+
function publishRequestBodyAndNext (request, next) {
|
|
8
|
+
return function () {
|
|
9
|
+
if (bodyParserReadCh.hasSubscribers && request) {
|
|
10
|
+
bodyParserReadCh.publish({ request })
|
|
11
|
+
}
|
|
12
|
+
next.apply(this, arguments)
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
addHook({
|
|
17
|
+
name: 'body-parser',
|
|
18
|
+
file: 'lib/read.js',
|
|
19
|
+
versions: ['>=1']
|
|
20
|
+
}, read => {
|
|
21
|
+
return function (req, res, next) {
|
|
22
|
+
const nextResource = new AsyncResource('bound-anonymous-fn')
|
|
23
|
+
arguments[2] = nextResource.bind(publishRequestBodyAndNext(req, next))
|
|
24
|
+
read.apply(this, arguments)
|
|
25
|
+
}
|
|
26
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
channel,
|
|
5
|
+
addHook
|
|
6
|
+
} = require('./helpers/instrument')
|
|
7
|
+
const shimmer = require('../../datadog-shimmer')
|
|
8
|
+
|
|
9
|
+
const childProcessChannel = channel('datadog:child_process:execution:start')
|
|
10
|
+
const execMethods = ['exec', 'execFile', 'fork', 'spawn', 'execFileSync', 'execSync', 'spawnSync']
|
|
11
|
+
const names = ['child_process', 'node:child_process']
|
|
12
|
+
names.forEach(name => {
|
|
13
|
+
addHook({ name }, childProcess => {
|
|
14
|
+
shimmer.massWrap(childProcess, execMethods, wrapChildProcessMethod())
|
|
15
|
+
return childProcess
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
function wrapChildProcessMethod () {
|
|
20
|
+
function wrapMethod (childProcessMethod) {
|
|
21
|
+
return function () {
|
|
22
|
+
if (childProcessChannel.hasSubscribers && arguments.length > 0) {
|
|
23
|
+
const command = arguments[0]
|
|
24
|
+
childProcessChannel.publish({ command })
|
|
25
|
+
}
|
|
26
|
+
return childProcessMethod.apply(this, arguments)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return wrapMethod
|
|
30
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const shimmer = require('../../datadog-shimmer')
|
|
4
|
-
const { addHook, channel
|
|
4
|
+
const { addHook, channel } = require('./helpers/instrument')
|
|
5
5
|
|
|
6
6
|
const enterChannel = channel('apm:connect:middleware:enter')
|
|
7
7
|
const exitChannel = channel('apm:connect:middleware:exit')
|
|
8
8
|
const errorChannel = channel('apm:connect:middleware:error')
|
|
9
9
|
const nextChannel = channel('apm:connect:middleware:next')
|
|
10
|
+
const finishChannel = channel('apm:connect:middleware:finish')
|
|
10
11
|
const handleChannel = channel('apm:connect:request:handle')
|
|
11
12
|
|
|
12
13
|
function wrapConnect (connect) {
|
|
@@ -61,7 +62,6 @@ function wrapLayerHandle (layer) {
|
|
|
61
62
|
return shimmer.wrap(original, function () {
|
|
62
63
|
if (!enterChannel.hasSubscribers) return original.apply(this, arguments)
|
|
63
64
|
|
|
64
|
-
const middlewareResource = new AsyncResource('bound-anonymous-fn')
|
|
65
65
|
const lastIndex = arguments.length - 1
|
|
66
66
|
const name = original._name || original.name
|
|
67
67
|
const req = arguments[arguments.length > 3 ? 1 : 0]
|
|
@@ -71,21 +71,21 @@ function wrapLayerHandle (layer) {
|
|
|
71
71
|
arguments[lastIndex] = wrapNext(req, next)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
const route = layer.route
|
|
74
|
+
const route = layer.route
|
|
76
75
|
|
|
77
|
-
|
|
76
|
+
enterChannel.publish({ name, req, route })
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
try {
|
|
79
|
+
return original.apply(this, arguments)
|
|
80
|
+
} catch (error) {
|
|
81
|
+
errorChannel.publish({ req, error })
|
|
82
|
+
nextChannel.publish({ req })
|
|
83
|
+
finishChannel.publish({ req })
|
|
85
84
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
throw error
|
|
86
|
+
} finally {
|
|
87
|
+
exitChannel.publish({ req })
|
|
88
|
+
}
|
|
89
89
|
})
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -96,7 +96,7 @@ function wrapNext (req, next) {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
nextChannel.publish({ req })
|
|
99
|
-
|
|
99
|
+
finishChannel.publish({ req })
|
|
100
100
|
|
|
101
101
|
next.apply(this, arguments)
|
|
102
102
|
}
|
|
@@ -50,7 +50,7 @@ function wrapRun (pl, isLatestVersion) {
|
|
|
50
50
|
|
|
51
51
|
const asyncResource = new AsyncResource('bound-anonymous-fn')
|
|
52
52
|
return asyncResource.runInAsyncScope(() => {
|
|
53
|
-
runStartCh.publish({
|
|
53
|
+
runStartCh.publish({ testName: this.pickle.name, fullTestSuite: this.pickle.uri })
|
|
54
54
|
try {
|
|
55
55
|
const promise = run.apply(this, arguments)
|
|
56
56
|
promise.finally(() => {
|
|
@@ -142,19 +142,19 @@ function reply (request, h) {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
addHook({ name: '@hapi/hapi', versions: ['>=17.9'] }, hapi => {
|
|
145
|
+
addHook({ name: '@hapi/hapi', versions: ['>=17.9 <=20.2.1'] }, hapi => {
|
|
146
146
|
shimmer.massWrap(hapi, ['server', 'Server'], wrapServer)
|
|
147
147
|
|
|
148
148
|
return hapi
|
|
149
149
|
})
|
|
150
150
|
|
|
151
|
-
addHook({ name: '@hapi/hapi', versions: ['>=17.9'], file: 'lib/core.js' }, Core => {
|
|
151
|
+
addHook({ name: '@hapi/hapi', versions: ['>=17.9 <=20.2.1'], file: 'lib/core.js' }, Core => {
|
|
152
152
|
shimmer.wrap(Core.prototype, '_dispatch', wrapDispatch)
|
|
153
153
|
|
|
154
154
|
return Core
|
|
155
155
|
})
|
|
156
156
|
|
|
157
|
-
addHook({ name: '@hapi/hapi', versions: ['>=17.9'], file: 'lib/route.js' }, Route => {
|
|
157
|
+
addHook({ name: '@hapi/hapi', versions: ['>=17.9 <=20.2.1'], file: 'lib/route.js' }, Route => {
|
|
158
158
|
shimmer.wrap(Route.prototype, 'rebuild', wrapRebuild)
|
|
159
159
|
|
|
160
160
|
return Route
|
|
@@ -8,6 +8,7 @@ module.exports = {
|
|
|
8
8
|
'@grpc/grpc-js': () => require('../grpc'),
|
|
9
9
|
'@hapi/hapi': () => require('../hapi'),
|
|
10
10
|
'@jest/core': () => require('../jest'),
|
|
11
|
+
'@jest/reporters': () => require('../jest'),
|
|
11
12
|
'@koa/router': () => require('../koa'),
|
|
12
13
|
'@node-redis/client': () => require('../redis'),
|
|
13
14
|
'@opensearch-project/opensearch': () => require('../opensearch'),
|
|
@@ -16,8 +17,11 @@ module.exports = {
|
|
|
16
17
|
'amqplib': () => require('../amqplib'),
|
|
17
18
|
'aws-sdk': () => require('../aws-sdk'),
|
|
18
19
|
'bluebird': () => require('../bluebird'),
|
|
20
|
+
'body-parser': () => require('../body-parser'),
|
|
19
21
|
'bunyan': () => require('../bunyan'),
|
|
20
22
|
'cassandra-driver': () => require('../cassandra-driver'),
|
|
23
|
+
'child_process': () => require('../child-process'),
|
|
24
|
+
'node:child_process': () => require('../child-process'),
|
|
21
25
|
'connect': () => require('../connect'),
|
|
22
26
|
'couchbase': () => require('../couchbase'),
|
|
23
27
|
'crypto': () => require('../crypto'),
|
|
@@ -65,6 +69,7 @@ module.exports = {
|
|
|
65
69
|
'promise-js': () => require('../promise-js'),
|
|
66
70
|
'promise': () => require('../promise'),
|
|
67
71
|
'q': () => require('../q'),
|
|
72
|
+
'qs': () => require('../qs'),
|
|
68
73
|
'redis': () => require('../redis'),
|
|
69
74
|
'restify': () => require('../restify'),
|
|
70
75
|
'rhea': () => require('../rhea'),
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
4
|
channel,
|
|
5
|
-
addHook
|
|
6
|
-
AsyncResource
|
|
5
|
+
addHook
|
|
7
6
|
} = require('../helpers/instrument')
|
|
8
7
|
const shimmer = require('../../../datadog-shimmer')
|
|
9
8
|
|
|
10
9
|
const startServerCh = channel('apm:http:server:request:start')
|
|
10
|
+
const exitServerCh = channel('apm:http:server:request:exit')
|
|
11
11
|
const errorServerCh = channel('apm:http:server:request:error')
|
|
12
12
|
const finishServerCh = channel('apm:http:server:request:finish')
|
|
13
13
|
|
|
@@ -45,18 +45,17 @@ function wrapEmit (emit) {
|
|
|
45
45
|
if (eventName === 'request') {
|
|
46
46
|
res.req = req
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
return asyncResource.runInAsyncScope(() => {
|
|
50
|
-
startServerCh.publish({ req, res })
|
|
48
|
+
startServerCh.publish({ req, res })
|
|
51
49
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
try {
|
|
51
|
+
return emit.apply(this, arguments)
|
|
52
|
+
} catch (err) {
|
|
53
|
+
errorServerCh.publish(err)
|
|
56
54
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
throw err
|
|
56
|
+
} finally {
|
|
57
|
+
exitServerCh.publish({ req })
|
|
58
|
+
}
|
|
60
59
|
}
|
|
61
60
|
return emit.apply(this, arguments)
|
|
62
61
|
}
|