dd-trace 2.5.0 → 2.7.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 +0 -2
- package/index.d.ts +17 -8
- package/package.json +19 -23
- package/packages/datadog-instrumentations/index.js +15 -0
- package/packages/datadog-instrumentations/src/aws-sdk.js +104 -0
- package/packages/datadog-instrumentations/src/connect.js +111 -0
- package/packages/datadog-instrumentations/src/express.js +27 -0
- package/packages/datadog-instrumentations/src/fastify.js +187 -0
- package/packages/datadog-instrumentations/src/find-my-way.js +30 -0
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +100 -0
- package/packages/datadog-instrumentations/src/http/server.js +1 -1
- package/packages/datadog-instrumentations/src/jest.js +175 -0
- package/packages/datadog-instrumentations/src/kafkajs.js +112 -0
- package/packages/datadog-instrumentations/src/knex.js +20 -0
- package/packages/datadog-instrumentations/src/koa.js +159 -0
- package/packages/datadog-instrumentations/src/limitd-client.js +21 -0
- package/packages/datadog-instrumentations/src/oracledb.js +128 -0
- package/packages/datadog-instrumentations/src/paperplane.js +77 -0
- package/packages/datadog-instrumentations/src/pg.js +2 -2
- package/packages/datadog-instrumentations/src/restify.js +58 -0
- package/packages/datadog-instrumentations/src/rhea.js +1 -1
- package/packages/datadog-instrumentations/src/router.js +177 -0
- package/packages/datadog-plugin-aws-sdk/src/base.js +146 -0
- package/packages/datadog-plugin-aws-sdk/src/index.js +16 -106
- package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +4 -2
- package/packages/datadog-plugin-aws-sdk/src/services/default.js +7 -0
- package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +3 -1
- package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +5 -4
- package/packages/datadog-plugin-aws-sdk/src/services/index.js +12 -0
- package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +4 -3
- package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +4 -3
- package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +3 -1
- package/packages/datadog-plugin-aws-sdk/src/services/s3.js +3 -1
- package/packages/datadog-plugin-aws-sdk/src/services/sns.js +4 -3
- package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +45 -6
- package/packages/datadog-plugin-connect/src/index.js +10 -114
- package/packages/datadog-plugin-cucumber/src/index.js +9 -21
- package/packages/datadog-plugin-cypress/src/plugin.js +6 -17
- package/packages/datadog-plugin-dns/src/index.js +12 -1
- package/packages/datadog-plugin-express/src/index.js +11 -25
- package/packages/datadog-plugin-fastify/src/index.js +17 -4
- package/packages/datadog-plugin-find-my-way/src/index.js +20 -0
- package/packages/datadog-plugin-fs/src/index.js +2 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +56 -111
- package/packages/datadog-plugin-http/src/server.js +2 -10
- package/packages/datadog-plugin-jest/src/index.js +101 -3
- package/packages/datadog-plugin-jest/src/util.js +1 -29
- package/packages/datadog-plugin-kafkajs/src/index.js +64 -90
- package/packages/datadog-plugin-koa/src/index.js +12 -164
- package/packages/datadog-plugin-mocha/src/index.js +5 -15
- package/packages/datadog-plugin-oracledb/src/index.js +34 -100
- package/packages/datadog-plugin-paperplane/src/index.js +14 -100
- package/packages/datadog-plugin-paperplane/src/logger.js +11 -0
- package/packages/datadog-plugin-paperplane/src/server.js +24 -0
- package/packages/datadog-plugin-restify/src/index.js +13 -75
- package/packages/datadog-plugin-router/src/index.js +67 -164
- package/packages/datadog-plugin-web/src/index.js +20 -0
- package/packages/dd-trace/lib/version.js +1 -1
- package/packages/dd-trace/src/appsec/callbacks/ddwaf.js +31 -11
- package/packages/dd-trace/src/appsec/index.js +7 -3
- package/packages/dd-trace/src/appsec/reporter.js +33 -3
- package/packages/dd-trace/src/appsec/rule_manager.js +2 -2
- package/packages/dd-trace/src/config.js +25 -3
- package/packages/dd-trace/src/format.js +9 -5
- package/packages/dd-trace/src/plugin_manager.js +13 -7
- package/packages/dd-trace/src/plugins/index.js +1 -2
- package/packages/dd-trace/src/plugins/log_plugin.js +8 -4
- package/packages/dd-trace/src/plugins/plugin.js +8 -0
- package/packages/dd-trace/src/plugins/util/test.js +20 -1
- package/packages/dd-trace/src/plugins/util/web.js +41 -12
- package/packages/dd-trace/src/profiling/config.js +8 -8
- package/packages/dd-trace/src/profiling/index.js +4 -4
- package/packages/dd-trace/src/profiling/profilers/{heap.js → space.js} +2 -2
- package/packages/dd-trace/src/profiling/profilers/{cpu.js → wall.js} +3 -3
- package/packages/dd-trace/src/span_processor.js +4 -1
- package/scripts/install_plugin_modules.js +1 -0
- package/packages/datadog-plugin-aws-sdk/src/helpers.js +0 -103
- package/packages/datadog-plugin-fastify/src/fastify.js +0 -198
- package/packages/datadog-plugin-fastify/src/find-my-way.js +0 -37
- package/packages/datadog-plugin-jest/src/jest-environment.js +0 -272
- package/packages/datadog-plugin-jest/src/jest-jasmine2.js +0 -185
- package/packages/datadog-plugin-knex/src/index.js +0 -23
- package/packages/datadog-plugin-limitd-client/src/index.js +0 -30
- package/scripts/postpublish.js +0 -24
|
@@ -1,176 +1,24 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const RouterPlugin = require('../../datadog-plugin-router/src')
|
|
3
4
|
const web = require('../../dd-trace/src/plugins/util/web')
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
config = web.normalizeConfig(config)
|
|
9
|
-
|
|
10
|
-
return function wrapCallback (callback) {
|
|
11
|
-
return function callbackWithTrace () {
|
|
12
|
-
const handleRequest = callback.apply(this, arguments)
|
|
13
|
-
|
|
14
|
-
if (typeof handleRequest !== 'function') return handleRequest
|
|
15
|
-
|
|
16
|
-
return function handleRequestWithTrace (req, res) {
|
|
17
|
-
web.instrument(tracer, config, req, res, 'koa.request')
|
|
18
|
-
|
|
19
|
-
return handleRequest.apply(this, arguments)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function createWrapCreateContext () {
|
|
26
|
-
return function wrapCreateContext (createContext) {
|
|
27
|
-
return function createContextWithTrace (req, res) {
|
|
28
|
-
const ctx = createContext.apply(this, arguments)
|
|
29
|
-
|
|
30
|
-
if (!ctx) return ctx
|
|
31
|
-
|
|
32
|
-
web.patch(req)
|
|
33
|
-
web.beforeEnd(req, () => {
|
|
34
|
-
web.enterRoute(req, ctx.routePath)
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
return ctx
|
|
38
|
-
}
|
|
6
|
+
class KoaPlugin extends RouterPlugin {
|
|
7
|
+
static get name () {
|
|
8
|
+
return 'koa'
|
|
39
9
|
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function createWrapUse () {
|
|
43
|
-
return function wrapUse (use) {
|
|
44
|
-
return function useWithTrace () {
|
|
45
|
-
const result = use.apply(this, arguments)
|
|
46
|
-
|
|
47
|
-
if (!Array.isArray(this.middleware)) return result
|
|
48
10
|
|
|
49
|
-
|
|
11
|
+
constructor (...args) {
|
|
12
|
+
super(...args)
|
|
50
13
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function createWrapRegister (tracer, config) {
|
|
59
|
-
return function wrapRegister (register) {
|
|
60
|
-
return function registerWithTrace (path, methods, middleware, opts) {
|
|
61
|
-
const route = register.apply(this, arguments)
|
|
62
|
-
|
|
63
|
-
if (!Array.isArray(path) && route && Array.isArray(route.stack)) {
|
|
64
|
-
wrapStack(route)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return route
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function createWrapRouterUse (tracer, config) {
|
|
73
|
-
return function wrapUse (use) {
|
|
74
|
-
return function useWithTrace () {
|
|
75
|
-
const router = use.apply(this, arguments)
|
|
76
|
-
|
|
77
|
-
router.stack.forEach(wrapStack)
|
|
78
|
-
|
|
79
|
-
return router
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function wrapStack (layer) {
|
|
85
|
-
layer.stack = layer.stack.map(middleware => {
|
|
86
|
-
if (typeof middleware !== 'function') return middleware
|
|
87
|
-
|
|
88
|
-
const original = originals.get(middleware)
|
|
89
|
-
|
|
90
|
-
middleware = original || middleware
|
|
91
|
-
|
|
92
|
-
const wrappedMiddleware = wrapMiddleware(middleware)
|
|
93
|
-
|
|
94
|
-
const handler = function (ctx, next) {
|
|
95
|
-
if (!ctx || !web.active(ctx.req)) return middleware.apply(this, arguments)
|
|
96
|
-
|
|
97
|
-
web.exitRoute(ctx.req)
|
|
98
|
-
web.enterRoute(ctx.req, layer.path)
|
|
99
|
-
|
|
100
|
-
return wrappedMiddleware.apply(this, arguments)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
originals.set(handler, middleware)
|
|
104
|
-
|
|
105
|
-
return handler
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function wrapMiddleware (fn) {
|
|
110
|
-
if (typeof fn !== 'function') return fn
|
|
111
|
-
|
|
112
|
-
return function (ctx, next) {
|
|
113
|
-
if (!ctx) return fn.apply(this, arguments)
|
|
114
|
-
|
|
115
|
-
return web.wrapMiddleware(ctx.req, fn, 'koa.middleware', () => {
|
|
116
|
-
try {
|
|
117
|
-
const result = fn.apply(this, arguments)
|
|
118
|
-
|
|
119
|
-
if (result && typeof result.then === 'function') {
|
|
120
|
-
result.then(
|
|
121
|
-
() => web.finish(ctx.req),
|
|
122
|
-
err => web.finish(ctx.req, err)
|
|
123
|
-
)
|
|
124
|
-
} else {
|
|
125
|
-
web.finish(ctx.req)
|
|
126
|
-
}
|
|
14
|
+
this.addSub('apm:koa:request:handle', ({ req }) => {
|
|
15
|
+
this.setFramework(req, 'koa', this.config)
|
|
16
|
+
})
|
|
127
17
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
web.finish(ctx.req, e)
|
|
131
|
-
throw e
|
|
132
|
-
}
|
|
18
|
+
this.addSub('apm:koa:request:route', ({ req, route }) => {
|
|
19
|
+
web.setRoute(req, route)
|
|
133
20
|
})
|
|
134
21
|
}
|
|
135
22
|
}
|
|
136
23
|
|
|
137
|
-
module.exports =
|
|
138
|
-
{
|
|
139
|
-
name: 'koa',
|
|
140
|
-
versions: ['>=2'],
|
|
141
|
-
patch (Koa, tracer, config) {
|
|
142
|
-
this.wrap(Koa.prototype, 'callback', createWrapCallback(tracer, config))
|
|
143
|
-
this.wrap(Koa.prototype, 'createContext', createWrapCreateContext(tracer, config))
|
|
144
|
-
this.wrap(Koa.prototype, 'use', createWrapUse(tracer, config))
|
|
145
|
-
},
|
|
146
|
-
unpatch (Koa) {
|
|
147
|
-
this.unwrap(Koa.prototype, 'callback')
|
|
148
|
-
this.unwrap(Koa.prototype, 'createContext')
|
|
149
|
-
this.unwrap(Koa.prototype, 'use')
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: '@koa/router',
|
|
154
|
-
versions: ['>=8'],
|
|
155
|
-
patch (Router, tracer, config) {
|
|
156
|
-
this.wrap(Router.prototype, 'register', createWrapRegister(tracer, config))
|
|
157
|
-
this.wrap(Router.prototype, 'use', createWrapRouterUse(tracer, config))
|
|
158
|
-
},
|
|
159
|
-
unpatch (Router) {
|
|
160
|
-
this.unwrap(Router.prototype, 'register')
|
|
161
|
-
this.unwrap(Router.prototype, 'use')
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
name: 'koa-router',
|
|
166
|
-
versions: ['>=7'],
|
|
167
|
-
patch (Router, tracer, config) {
|
|
168
|
-
this.wrap(Router.prototype, 'register', createWrapRegister(tracer, config))
|
|
169
|
-
this.wrap(Router.prototype, 'use', createWrapRouterUse(tracer, config))
|
|
170
|
-
},
|
|
171
|
-
unpatch (Router) {
|
|
172
|
-
this.unwrap(Router.prototype, 'register')
|
|
173
|
-
this.unwrap(Router.prototype, 'use')
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
]
|
|
24
|
+
module.exports = KoaPlugin
|
|
@@ -6,10 +6,7 @@ const { storage } = require('../../datadog-core')
|
|
|
6
6
|
const {
|
|
7
7
|
CI_APP_ORIGIN,
|
|
8
8
|
TEST_CODE_OWNERS,
|
|
9
|
-
TEST_TYPE,
|
|
10
|
-
TEST_NAME,
|
|
11
9
|
TEST_SUITE,
|
|
12
|
-
TEST_FRAMEWORK_VERSION,
|
|
13
10
|
TEST_STATUS,
|
|
14
11
|
TEST_PARAMETERS,
|
|
15
12
|
finishAllTraceSpans,
|
|
@@ -18,11 +15,9 @@ const {
|
|
|
18
15
|
getTestParentSpan,
|
|
19
16
|
getTestParametersString,
|
|
20
17
|
getCodeOwnersFileEntries,
|
|
21
|
-
getCodeOwnersForFilename
|
|
18
|
+
getCodeOwnersForFilename,
|
|
19
|
+
getTestCommonTags
|
|
22
20
|
} = require('../../dd-trace/src/plugins/util/test')
|
|
23
|
-
const { SPAN_TYPE, RESOURCE_NAME, SAMPLING_PRIORITY } = require('../../../ext/tags')
|
|
24
|
-
const { SAMPLING_RULE_DECISION } = require('../../dd-trace/src/constants')
|
|
25
|
-
const { AUTO_KEEP } = require('../../../ext/priority')
|
|
26
21
|
|
|
27
22
|
const skippedTests = new WeakSet()
|
|
28
23
|
|
|
@@ -33,16 +28,11 @@ function getTestSpanMetadata (tracer, test, sourceRoot) {
|
|
|
33
28
|
const fullTestName = test.fullTitle()
|
|
34
29
|
const testSuite = getTestSuitePath(testSuiteAbsolutePath, sourceRoot)
|
|
35
30
|
|
|
31
|
+
const commonTags = getTestCommonTags(fullTestName, testSuite, tracer._version)
|
|
32
|
+
|
|
36
33
|
return {
|
|
37
34
|
childOf,
|
|
38
|
-
|
|
39
|
-
[TEST_TYPE]: 'test',
|
|
40
|
-
[TEST_NAME]: fullTestName,
|
|
41
|
-
[TEST_SUITE]: testSuite,
|
|
42
|
-
[SAMPLING_RULE_DECISION]: 1,
|
|
43
|
-
[SAMPLING_PRIORITY]: AUTO_KEEP,
|
|
44
|
-
[TEST_FRAMEWORK_VERSION]: tracer._version,
|
|
45
|
-
[RESOURCE_NAME]: `${testSuite}.${fullTestName}`
|
|
35
|
+
...commonTags
|
|
46
36
|
}
|
|
47
37
|
}
|
|
48
38
|
|
|
@@ -1,105 +1,54 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const Plugin = require('../../dd-trace/src/plugins/plugin')
|
|
4
|
+
const { storage } = require('../../datadog-core')
|
|
3
5
|
const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
class OracledbPlugin extends Plugin {
|
|
8
|
+
static get name () {
|
|
9
|
+
return 'oracledb'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
constructor (...args) {
|
|
13
|
+
super(...args)
|
|
7
14
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return function executeWithTrace (dbQuery, ...args) {
|
|
11
|
-
const connAttrs = connectionAttributes.get(this)
|
|
12
|
-
const service = getServiceName(tracer, config, connAttrs)
|
|
15
|
+
this.addSub('apm:oracledb:execute:start', ({ query, connAttrs }) => {
|
|
16
|
+
const service = getServiceName(this.tracer, this.config, connAttrs)
|
|
13
17
|
const connectStringObj = new URL('http://' + connAttrs.connectString)
|
|
14
18
|
const tags = {
|
|
15
19
|
'span.kind': 'client',
|
|
16
20
|
'span.type': 'sql',
|
|
17
|
-
'sql.query':
|
|
21
|
+
'sql.query': query,
|
|
18
22
|
'db.instance': connectStringObj.pathname.substring(1),
|
|
19
23
|
'db.hostname': connectStringObj.hostname,
|
|
20
|
-
'db.user': config.user,
|
|
24
|
+
'db.user': this.config.user,
|
|
21
25
|
'db.port': connectStringObj.port,
|
|
22
|
-
'resource.name':
|
|
26
|
+
'resource.name': query,
|
|
23
27
|
'service.name': service
|
|
24
28
|
}
|
|
29
|
+
const store = storage.getStore()
|
|
30
|
+
const childOf = store ? store.span : store
|
|
31
|
+
const span = this.tracer.startSpan('oracle.query', {
|
|
32
|
+
childOf,
|
|
33
|
+
tags
|
|
34
|
+
})
|
|
35
|
+
analyticsSampler.sample(span, this.config.measured)
|
|
36
|
+
this.enter(span, store)
|
|
37
|
+
})
|
|
25
38
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return execute.apply(this, args)
|
|
32
|
-
}).apply(this, arguments)
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function createWrapGetConnection (tracer, config) {
|
|
38
|
-
return function wrapGetConnection (getConnection) {
|
|
39
|
-
return function getConnectionWithTrace (connAttrs, callback) {
|
|
40
|
-
if (callback) {
|
|
41
|
-
arguments[1] = (err, connection) => {
|
|
42
|
-
if (connection) {
|
|
43
|
-
connectionAttributes.set(connection, connAttrs)
|
|
44
|
-
}
|
|
45
|
-
callback(err, connection)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getConnection.apply(this, arguments)
|
|
49
|
-
} else {
|
|
50
|
-
return getConnection.apply(this, arguments).then((connection) => {
|
|
51
|
-
connectionAttributes.set(connection, connAttrs)
|
|
52
|
-
return connection
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function createWrapCreatePool (tracer, config) {
|
|
60
|
-
return function wrapCreatePool (createPool) {
|
|
61
|
-
return function createPoolWithTrace (poolAttrs, callback) {
|
|
62
|
-
if (callback) {
|
|
63
|
-
arguments[1] = (err, pool) => {
|
|
64
|
-
if (pool) {
|
|
65
|
-
poolAttributes.set(pool, poolAttrs)
|
|
66
|
-
}
|
|
67
|
-
callback(err, pool)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
createPool.apply(this, arguments)
|
|
71
|
-
} else {
|
|
72
|
-
return createPool.apply(this, arguments).then((pool) => {
|
|
73
|
-
poolAttributes.set(pool, poolAttrs)
|
|
74
|
-
return pool
|
|
75
|
-
})
|
|
39
|
+
this.addSub('apm:oracledb:execute:error', err => {
|
|
40
|
+
const store = storage.getStore()
|
|
41
|
+
if (store && store.span) {
|
|
42
|
+
store.span.setTag('error', err)
|
|
76
43
|
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
44
|
+
})
|
|
80
45
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (typeof arguments[arguments.length - 1] === 'function') {
|
|
86
|
-
callback = arguments[arguments.length - 1]
|
|
87
|
-
}
|
|
88
|
-
if (callback) {
|
|
89
|
-
arguments[arguments.length - 1] = (err, connection) => {
|
|
90
|
-
if (connection) {
|
|
91
|
-
connectionAttributes.set(connection, poolAttributes.get(this))
|
|
92
|
-
}
|
|
93
|
-
callback(err, connection)
|
|
94
|
-
}
|
|
95
|
-
getConnection.apply(this, arguments)
|
|
96
|
-
} else {
|
|
97
|
-
return getConnection.apply(this, arguments).then((connection) => {
|
|
98
|
-
connectionAttributes.set(connection, poolAttributes.get(this))
|
|
99
|
-
return connection
|
|
100
|
-
})
|
|
46
|
+
this.addSub('apm:oracledb:execute:finish', () => {
|
|
47
|
+
const store = storage.getStore()
|
|
48
|
+
if (store && store.span) {
|
|
49
|
+
store.span.finish()
|
|
101
50
|
}
|
|
102
|
-
}
|
|
51
|
+
})
|
|
103
52
|
}
|
|
104
53
|
}
|
|
105
54
|
|
|
@@ -113,19 +62,4 @@ function getServiceName (tracer, config, connAttrs) {
|
|
|
113
62
|
}
|
|
114
63
|
}
|
|
115
64
|
|
|
116
|
-
module.exports =
|
|
117
|
-
name: 'oracledb',
|
|
118
|
-
versions: ['5'],
|
|
119
|
-
patch (oracledb, tracer, config) {
|
|
120
|
-
this.wrap(oracledb.Connection.prototype, 'execute', createWrapExecute(tracer, config))
|
|
121
|
-
this.wrap(oracledb, 'getConnection', createWrapGetConnection(tracer, config))
|
|
122
|
-
this.wrap(oracledb, 'createPool', createWrapCreatePool(tracer, config))
|
|
123
|
-
this.wrap(oracledb.Pool.prototype, 'getConnection', createWrapPoolGetConnection(tracer, config))
|
|
124
|
-
},
|
|
125
|
-
unpatch (oracledb) {
|
|
126
|
-
this.unwrap(oracledb.Connection.prototype, 'execute')
|
|
127
|
-
this.unwrap(oracledb, 'getConnection')
|
|
128
|
-
this.unwrap(oracledb, 'createPool')
|
|
129
|
-
this.unwrap(oracledb.Pool.prototype, 'getConnection')
|
|
130
|
-
}
|
|
131
|
-
}
|
|
65
|
+
module.exports = OracledbPlugin
|
|
@@ -1,111 +1,25 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const Plugin = require('../../dd-trace/src/plugins/plugin')
|
|
4
|
+
const PaperplaneLoggerPlugin = require('./logger')
|
|
5
|
+
const PaperplaneServerPlugin = require('./server')
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (web.active(original)) {
|
|
9
|
-
web.enterRoute(original, route)
|
|
7
|
+
class PaperplanePlugin extends Plugin {
|
|
8
|
+
static get name () {
|
|
9
|
+
return 'paperplane'
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const wrapLogger = tracer => logger => record => {
|
|
16
|
-
const span = tracer.scope().active()
|
|
12
|
+
constructor (...args) {
|
|
13
|
+
super(...args)
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const correlation = {
|
|
21
|
-
dd: {
|
|
22
|
-
trace_id: span.context().toTraceId(),
|
|
23
|
-
span_id: span.context().toSpanId()
|
|
24
|
-
}
|
|
15
|
+
this.server = new PaperplaneServerPlugin(...args)
|
|
16
|
+
this.logger = new PaperplaneLoggerPlugin(...args)
|
|
25
17
|
}
|
|
26
18
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return logger(record)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const wrapMount = (tracer, config) => mount => opts => {
|
|
35
|
-
const handler = mount(opts)
|
|
36
|
-
|
|
37
|
-
const traced = (req, res) =>
|
|
38
|
-
web.instrument(
|
|
39
|
-
tracer, config, req, res, 'paperplane.request',
|
|
40
|
-
() => handler(req, res)
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
return traced
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const wrapRoutes = tracer => routes => handlers => {
|
|
47
|
-
const traced = {}
|
|
48
|
-
|
|
49
|
-
for (const route in handlers) {
|
|
50
|
-
traced[route] = traceRoute(handlers[route])
|
|
19
|
+
configure (config) {
|
|
20
|
+
this.server.configure(config)
|
|
21
|
+
this.logger.configure(config)
|
|
51
22
|
}
|
|
52
|
-
|
|
53
|
-
return routes(traced)
|
|
54
23
|
}
|
|
55
24
|
|
|
56
|
-
|
|
57
|
-
const mainVersionRange = nodeMajor <= 12 ? ['>=2.3.2'] : nodeMajor <= 14 ? ['>=3.1.1'] : []
|
|
58
|
-
|
|
59
|
-
module.exports = [
|
|
60
|
-
{
|
|
61
|
-
name: 'paperplane',
|
|
62
|
-
versions: mainVersionRange,
|
|
63
|
-
file: 'lib/logger.js',
|
|
64
|
-
patch (exports, tracer) {
|
|
65
|
-
if (tracer._logInjection) {
|
|
66
|
-
this.wrap(exports, 'logger', wrapLogger(tracer))
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
unpatch (exports) {
|
|
70
|
-
this.unwrap(exports, 'logger')
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
name: 'paperplane',
|
|
75
|
-
versions: mainVersionRange,
|
|
76
|
-
file: 'lib/mount.js',
|
|
77
|
-
patch (exports, tracer, config) {
|
|
78
|
-
config = web.normalizeConfig(config)
|
|
79
|
-
this.wrap(exports, 'mount', wrapMount(tracer, config))
|
|
80
|
-
},
|
|
81
|
-
unpatch (exports) {
|
|
82
|
-
this.unwrap(exports, 'mount')
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: 'paperplane',
|
|
87
|
-
versions: mainVersionRange,
|
|
88
|
-
file: 'lib/routes.js',
|
|
89
|
-
patch (exports, tracer) {
|
|
90
|
-
this.wrap(exports, 'routes', wrapRoutes(tracer))
|
|
91
|
-
},
|
|
92
|
-
unpatch (exports) {
|
|
93
|
-
this.unwrap(exports, 'routes')
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
|
|
98
|
-
if (nodeMajor <= 12) {
|
|
99
|
-
module.exports.push({
|
|
100
|
-
name: 'paperplane',
|
|
101
|
-
versions: ['2.3.0 - 2.3.1'],
|
|
102
|
-
patch (paperplane, tracer, config) {
|
|
103
|
-
config = web.normalizeConfig(config)
|
|
104
|
-
this.wrap(paperplane, 'mount', wrapMount(tracer, config))
|
|
105
|
-
this.wrap(paperplane, 'routes', wrapRoutes(tracer))
|
|
106
|
-
},
|
|
107
|
-
unpatch (paperplane) {
|
|
108
|
-
this.unwrap(paperplane, ['mount', 'routes'])
|
|
109
|
-
}
|
|
110
|
-
})
|
|
111
|
-
}
|
|
25
|
+
module.exports = PaperplanePlugin
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const RouterPlugin = require('../../datadog-plugin-router/src')
|
|
4
|
+
const web = require('../../dd-trace/src/plugins/util/web')
|
|
5
|
+
|
|
6
|
+
class PaperplaneServerPlugin extends RouterPlugin {
|
|
7
|
+
static get name () {
|
|
8
|
+
return 'paperplane'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
constructor (...args) {
|
|
12
|
+
super(...args)
|
|
13
|
+
|
|
14
|
+
this.addSub('apm:paperplane:request:handle', req => {
|
|
15
|
+
this.setFramework(req, 'paperplane', this.config)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
this.addSub('apm:paperplane:request:route', ({ req, route }) => {
|
|
19
|
+
web.setRoute(req, route)
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = PaperplaneServerPlugin
|
|
@@ -1,86 +1,24 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const RouterPlugin = require('../../datadog-plugin-router/src')
|
|
3
4
|
const web = require('../../dd-trace/src/plugins/util/web')
|
|
4
|
-
const handlers = ['use', 'pre']
|
|
5
|
-
const methods = ['del', 'get', 'head', 'opts', 'post', 'put', 'patch']
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return function wrapSetupRequest (setupRequest) {
|
|
11
|
-
return function setupRequestWithTrace (req, res) {
|
|
12
|
-
return web.instrument(tracer, config, req, res, 'restify.request', () => {
|
|
13
|
-
web.beforeEnd(req, () => {
|
|
14
|
-
if (req.route && withRoute) {
|
|
15
|
-
web.enterRoute(req, req.route.path)
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
return setupRequest.apply(this, arguments)
|
|
20
|
-
})
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function createWrapMethod (tracer, config) {
|
|
26
|
-
return function wrapMethod (method) {
|
|
27
|
-
return function methodWithTrace (path) {
|
|
28
|
-
const middleware = wrapMiddleware(Array.prototype.slice.call(arguments, 1))
|
|
29
|
-
|
|
30
|
-
return method.apply(this, [path].concat(middleware))
|
|
31
|
-
}
|
|
6
|
+
class RestifyPlugin extends RouterPlugin {
|
|
7
|
+
static get name () {
|
|
8
|
+
return 'restify'
|
|
32
9
|
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function createWrapHandler (tracer, config) {
|
|
36
|
-
return function wrapMethod (method) {
|
|
37
|
-
return function methodWithTrace () {
|
|
38
|
-
return method.apply(this, wrapMiddleware(arguments))
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
10
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
11
|
+
constructor (...args) {
|
|
12
|
+
super(...args)
|
|
46
13
|
|
|
47
|
-
|
|
48
|
-
|
|
14
|
+
this.addSub('apm:restify:request:handle', ({ req }) => {
|
|
15
|
+
this.setFramework(req, 'restify', this.config)
|
|
16
|
+
})
|
|
49
17
|
|
|
50
|
-
|
|
51
|
-
|
|
18
|
+
this.addSub('apm:restify:request:route', ({ req, route }) => {
|
|
19
|
+
web.setRoute(req, route)
|
|
20
|
+
})
|
|
52
21
|
}
|
|
53
22
|
}
|
|
54
23
|
|
|
55
|
-
module.exports =
|
|
56
|
-
{
|
|
57
|
-
name: 'restify',
|
|
58
|
-
versions: ['>=7'],
|
|
59
|
-
file: 'lib/server.js',
|
|
60
|
-
patch (Server, tracer, config) {
|
|
61
|
-
this.wrap(Server.prototype, '_setupRequest', createWrapSetupRequest(tracer, config))
|
|
62
|
-
this.wrap(Server.prototype, handlers, createWrapHandler(tracer, config))
|
|
63
|
-
this.wrap(Server.prototype, methods, createWrapMethod(tracer, config))
|
|
64
|
-
},
|
|
65
|
-
unpatch (Server) {
|
|
66
|
-
this.unwrap(Server.prototype, '_setupRequest')
|
|
67
|
-
this.unwrap(Server.prototype, handlers)
|
|
68
|
-
this.unwrap(Server.prototype, methods)
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
name: 'restify',
|
|
73
|
-
versions: ['3 - 6'],
|
|
74
|
-
file: 'lib/server.js',
|
|
75
|
-
patch (Server, tracer, config) {
|
|
76
|
-
this.wrap(Server.prototype, '_setupRequest', createWrapSetupRequest(tracer, config, true))
|
|
77
|
-
this.wrap(Server.prototype, handlers, createWrapHandler(tracer, config))
|
|
78
|
-
this.wrap(Server.prototype, methods, createWrapMethod(tracer, config))
|
|
79
|
-
},
|
|
80
|
-
unpatch (Server) {
|
|
81
|
-
this.unwrap(Server.prototype, '_setupRequest')
|
|
82
|
-
this.unwrap(Server.prototype, handlers)
|
|
83
|
-
this.unwrap(Server.prototype, methods)
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
]
|
|
24
|
+
module.exports = RestifyPlugin
|