dd-trace 3.4.0 → 3.6.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/index.d.ts +40 -2
- package/package.json +1 -1
- package/packages/datadog-instrumentations/src/cucumber.js +0 -2
- package/packages/datadog-instrumentations/src/elasticsearch.js +51 -47
- package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +1 -1
- package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
- package/packages/datadog-instrumentations/src/mariadb.js +43 -69
- package/packages/datadog-instrumentations/src/mocha.js +14 -18
- package/packages/datadog-instrumentations/src/opensearch.js +10 -0
- package/packages/datadog-instrumentations/src/pg.js +2 -1
- package/packages/datadog-instrumentations/src/restify.js +1 -0
- package/packages/datadog-instrumentations/src/rhea.js +20 -17
- package/packages/datadog-plugin-amqp10/src/consumer.js +32 -0
- package/packages/datadog-plugin-amqp10/src/index.js +11 -101
- package/packages/datadog-plugin-amqp10/src/producer.js +34 -0
- package/packages/datadog-plugin-amqp10/src/util.js +15 -0
- package/packages/datadog-plugin-amqplib/src/client.js +38 -0
- package/packages/datadog-plugin-amqplib/src/consumer.js +40 -0
- package/packages/datadog-plugin-amqplib/src/index.js +14 -102
- package/packages/datadog-plugin-amqplib/src/producer.js +37 -0
- package/packages/datadog-plugin-amqplib/src/util.js +14 -0
- package/packages/datadog-plugin-dns/src/index.js +16 -91
- package/packages/datadog-plugin-dns/src/lookup.js +40 -0
- package/packages/datadog-plugin-dns/src/lookup_service.js +24 -0
- package/packages/datadog-plugin-dns/src/resolve.js +24 -0
- package/packages/datadog-plugin-dns/src/reverse.js +21 -0
- package/packages/datadog-plugin-elasticsearch/src/index.js +7 -7
- package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +25 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +42 -0
- package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +14 -99
- package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +34 -0
- package/packages/datadog-plugin-graphql/src/execute.js +73 -0
- package/packages/datadog-plugin-graphql/src/index.js +14 -176
- package/packages/datadog-plugin-graphql/src/parse.js +32 -0
- package/packages/datadog-plugin-graphql/src/resolve.js +70 -76
- package/packages/datadog-plugin-graphql/src/validate.js +28 -0
- package/packages/datadog-plugin-grpc/src/client.js +46 -55
- package/packages/datadog-plugin-grpc/src/index.js +7 -24
- package/packages/datadog-plugin-grpc/src/server.js +50 -52
- package/packages/datadog-plugin-grpc/src/util.js +15 -14
- package/packages/datadog-plugin-http/src/index.js +7 -22
- package/packages/datadog-plugin-http2/src/index.js +8 -26
- package/packages/datadog-plugin-jest/src/index.js +3 -0
- package/packages/datadog-plugin-kafkajs/src/consumer.js +42 -0
- package/packages/datadog-plugin-kafkajs/src/index.js +11 -87
- package/packages/datadog-plugin-kafkajs/src/producer.js +31 -0
- package/packages/datadog-plugin-mocha/src/index.js +2 -2
- package/packages/datadog-plugin-moleculer/src/client.js +22 -36
- package/packages/datadog-plugin-moleculer/src/index.js +8 -26
- package/packages/datadog-plugin-moleculer/src/server.js +18 -30
- package/packages/datadog-plugin-net/src/ipc.js +21 -0
- package/packages/datadog-plugin-net/src/tcp.js +46 -0
- package/packages/datadog-plugin-opensearch/src/index.js +11 -0
- package/packages/datadog-plugin-pg/src/index.js +2 -1
- package/packages/datadog-plugin-rhea/src/consumer.js +55 -0
- package/packages/datadog-plugin-rhea/src/index.js +11 -99
- package/packages/datadog-plugin-rhea/src/producer.js +45 -0
- package/packages/datadog-plugin-sharedb/src/index.js +22 -39
- package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +1 -1
- package/packages/dd-trace/src/appsec/iast/index.js +4 -6
- package/packages/dd-trace/src/appsec/iast/path-line.js +3 -0
- package/packages/dd-trace/src/appsec/recommended.json +60 -46
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -5
- package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +2 -5
- package/packages/dd-trace/src/config.js +26 -6
- package/packages/dd-trace/src/constants.js +3 -0
- package/packages/dd-trace/src/dogstatsd.js +42 -10
- package/packages/dd-trace/src/encode/agentless-ci-visibility.js +10 -2
- package/packages/dd-trace/src/exporters/agent/writer.js +2 -9
- package/packages/dd-trace/src/exporters/common/request.js +12 -0
- package/packages/dd-trace/src/format.js +13 -0
- package/packages/dd-trace/src/metrics.js +10 -2
- package/packages/dd-trace/src/plugins/client.js +3 -1
- package/packages/dd-trace/src/plugins/composite.js +26 -0
- package/packages/dd-trace/src/plugins/consumer.js +9 -0
- package/packages/dd-trace/src/plugins/incoming.js +7 -0
- package/packages/dd-trace/src/plugins/index.js +1 -0
- package/packages/dd-trace/src/plugins/outgoing.js +1 -1
- package/packages/dd-trace/src/plugins/producer.js +9 -0
- package/packages/dd-trace/src/plugins/server.js +9 -0
- package/packages/dd-trace/src/plugins/storage.js +0 -4
- package/packages/dd-trace/src/plugins/tracing.js +10 -9
- package/packages/dd-trace/src/profiling/profiler.js +8 -1
- package/packages/dd-trace/src/span_processor.js +3 -0
- package/packages/dd-trace/src/span_sampler.js +80 -0
- package/packages/dd-trace/src/tracer.js +6 -2
- package/packages/dd-trace/src/util.js +43 -1
|
@@ -1,107 +1,17 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
class Amqp10Plugin extends
|
|
8
|
-
static get name () {
|
|
9
|
-
|
|
3
|
+
const ProducerPlugin = require('./producer')
|
|
4
|
+
const ConsumerPlugin = require('./consumer')
|
|
5
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
6
|
+
|
|
7
|
+
class Amqp10Plugin extends CompositePlugin {
|
|
8
|
+
static get name () { return 'amqp10' }
|
|
9
|
+
static get plugins () {
|
|
10
|
+
return {
|
|
11
|
+
producer: ProducerPlugin,
|
|
12
|
+
consumer: ConsumerPlugin
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
constructor (...args) {
|
|
13
|
-
super(...args)
|
|
14
|
-
|
|
15
|
-
this.addSub(`apm:amqp10:send:start`, ({ link }) => {
|
|
16
|
-
const address = getAddress(link)
|
|
17
|
-
const target = getShortName(link)
|
|
18
|
-
|
|
19
|
-
const store = storage.getStore()
|
|
20
|
-
const childOf = store ? store.span : store
|
|
21
|
-
|
|
22
|
-
const span = this.tracer.startSpan('amqp.send', {
|
|
23
|
-
childOf,
|
|
24
|
-
tags: {
|
|
25
|
-
'resource.name': ['send', target].filter(v => v).join(' '),
|
|
26
|
-
'span.kind': 'producer',
|
|
27
|
-
'amqp.link.target.address': target,
|
|
28
|
-
'amqp.link.role': 'sender',
|
|
29
|
-
'out.host': address.host,
|
|
30
|
-
'out.port': address.port,
|
|
31
|
-
'service.name': this.config.service || `${this.tracer._service}-amqp`,
|
|
32
|
-
'amqp.link.name': link.name,
|
|
33
|
-
'amqp.link.handle': link.handle,
|
|
34
|
-
'amqp.connection.host': address.host,
|
|
35
|
-
'amqp.connection.port': address.port,
|
|
36
|
-
'amqp.connection.user': address.user
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
analyticsSampler.sample(span, this.config.measured)
|
|
41
|
-
|
|
42
|
-
this.enter(span, store)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
this.addSub(`apm:amqp10:send:error`, err => {
|
|
46
|
-
const span = storage.getStore().span
|
|
47
|
-
span.setTag('error', err)
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
this.addSub(`apm:amqp10:send:finish`, () => {
|
|
51
|
-
const span = storage.getStore().span
|
|
52
|
-
span.finish()
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
this.addSub(`apm:amqp10:receive:start`, ({ link }) => {
|
|
56
|
-
const source = getShortName(link)
|
|
57
|
-
const address = getAddress(link)
|
|
58
|
-
|
|
59
|
-
const store = storage.getStore()
|
|
60
|
-
const childOf = store ? store.span : store
|
|
61
|
-
|
|
62
|
-
const span = this.tracer.startSpan('amqp.receive', {
|
|
63
|
-
childOf,
|
|
64
|
-
tags: {
|
|
65
|
-
'resource.name': ['receive', source].filter(v => v).join(' '),
|
|
66
|
-
'span.kind': 'consumer',
|
|
67
|
-
'span.type': 'worker',
|
|
68
|
-
'amqp.link.source.address': source,
|
|
69
|
-
'amqp.link.role': 'receiver',
|
|
70
|
-
'service.name': this.config.service || `${this.tracer._service}-amqp`,
|
|
71
|
-
'amqp.link.name': link.name,
|
|
72
|
-
'amqp.link.handle': link.handle,
|
|
73
|
-
'amqp.connection.host': address.host,
|
|
74
|
-
'amqp.connection.port': address.port,
|
|
75
|
-
'amqp.connection.user': address.user
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
analyticsSampler.sample(span, this.config.measured)
|
|
80
|
-
|
|
81
|
-
this.enter(span, store)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
this.addSub(`apm:amqp10:receive:finish`, () => {
|
|
85
|
-
storage.getStore().span.finish()
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
this.addSub(`apm:amqp10:receive:error`, err => {
|
|
89
|
-
const span = storage.getStore().span
|
|
90
|
-
span.setTag('error', err)
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function getShortName (link) {
|
|
96
|
-
if (!link || !link.name) return null
|
|
97
|
-
|
|
98
|
-
return link.name.split('_').slice(0, -1).join('_')
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function getAddress (link) {
|
|
102
|
-
if (!link || !link.session || !link.session.connection) return {}
|
|
103
|
-
|
|
104
|
-
return link.session.connection.address || {}
|
|
105
15
|
}
|
|
106
16
|
|
|
107
17
|
module.exports = Amqp10Plugin
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
4
|
+
const { getAddress, getShortName } = require('./util')
|
|
5
|
+
|
|
6
|
+
class Amqp10ProducerPlugin extends ProducerPlugin {
|
|
7
|
+
static get name () { return 'amqp10' }
|
|
8
|
+
static get operation () { return 'send' }
|
|
9
|
+
static get system () { return 'amqp' }
|
|
10
|
+
|
|
11
|
+
start ({ link }) {
|
|
12
|
+
const address = getAddress(link)
|
|
13
|
+
const target = getShortName(link)
|
|
14
|
+
|
|
15
|
+
this.startSpan('amqp.send', {
|
|
16
|
+
service: this.config.service || `${this.tracer._service}-amqp`,
|
|
17
|
+
resource: ['send', target].filter(v => v).join(' '),
|
|
18
|
+
kind: 'producer',
|
|
19
|
+
meta: {
|
|
20
|
+
'amqp.link.target.address': target,
|
|
21
|
+
'amqp.link.role': 'sender',
|
|
22
|
+
'out.host': address.host,
|
|
23
|
+
'out.port': address.port,
|
|
24
|
+
'amqp.link.name': link.name,
|
|
25
|
+
'amqp.link.handle': link.handle,
|
|
26
|
+
'amqp.connection.host': address.host,
|
|
27
|
+
'amqp.connection.port': address.port,
|
|
28
|
+
'amqp.connection.user': address.user
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = Amqp10ProducerPlugin
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
function getAddress (link) {
|
|
4
|
+
if (!link || !link.session || !link.session.connection) return {}
|
|
5
|
+
|
|
6
|
+
return link.session.connection.address || {}
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function getShortName (link) {
|
|
10
|
+
if (!link || !link.name) return null
|
|
11
|
+
|
|
12
|
+
return link.name.split('_').slice(0, -1).join('_')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = { getAddress, getShortName }
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { TEXT_MAP } = require('../../../ext/formats')
|
|
4
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
5
|
+
const { getResourceName } = require('./util')
|
|
6
|
+
|
|
7
|
+
class AmqplibClientPlugin extends ClientPlugin {
|
|
8
|
+
static get name () { return 'amqplib' }
|
|
9
|
+
static get operation () { return 'command' }
|
|
10
|
+
|
|
11
|
+
start ({ channel = {}, method, fields }) {
|
|
12
|
+
if (method === 'basic.deliver' || method === 'basic.get') return
|
|
13
|
+
if (method === 'basic.publish') return
|
|
14
|
+
|
|
15
|
+
const stream = (channel.connection && channel.connection.stream) || {}
|
|
16
|
+
const span = this.startSpan('amqp.command', {
|
|
17
|
+
service: this.config.service || `${this.tracer._service}-amqp`,
|
|
18
|
+
resource: getResourceName(method, fields),
|
|
19
|
+
kind: 'client',
|
|
20
|
+
meta: {
|
|
21
|
+
'out.host': stream._host,
|
|
22
|
+
'out.port': stream.remotePort,
|
|
23
|
+
'amqp.queue': fields.queue,
|
|
24
|
+
'amqp.exchange': fields.exchange,
|
|
25
|
+
'amqp.routingKey': fields.routingKey,
|
|
26
|
+
'amqp.consumerTag': fields.consumerTag,
|
|
27
|
+
'amqp.source': fields.source,
|
|
28
|
+
'amqp.destination': fields.destination
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
fields.headers = fields.headers || {}
|
|
33
|
+
|
|
34
|
+
this.tracer.inject(span, TEXT_MAP, fields.headers)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = AmqplibClientPlugin
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { TEXT_MAP } = require('../../../ext/formats')
|
|
4
|
+
const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
|
|
5
|
+
const { getResourceName } = require('./util')
|
|
6
|
+
|
|
7
|
+
class AmqplibConsumerPlugin extends ConsumerPlugin {
|
|
8
|
+
static get name () { return 'amqplib' }
|
|
9
|
+
static get operation () { return 'command' }
|
|
10
|
+
|
|
11
|
+
start ({ method, fields, message }) {
|
|
12
|
+
if (method !== 'basic.deliver' && method !== 'basic.get') return
|
|
13
|
+
|
|
14
|
+
const childOf = extract(this.tracer, message)
|
|
15
|
+
|
|
16
|
+
this.startSpan('amqp.command', {
|
|
17
|
+
childOf,
|
|
18
|
+
service: this.config.service || `${this.tracer._service}-amqp`,
|
|
19
|
+
resource: getResourceName(method, fields),
|
|
20
|
+
kind: 'consumer',
|
|
21
|
+
type: 'worker',
|
|
22
|
+
meta: {
|
|
23
|
+
'amqp.queue': fields.queue,
|
|
24
|
+
'amqp.exchange': fields.exchange,
|
|
25
|
+
'amqp.routingKey': fields.routingKey,
|
|
26
|
+
'amqp.consumerTag': fields.consumerTag,
|
|
27
|
+
'amqp.source': fields.source,
|
|
28
|
+
'amqp.destination': fields.destination
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function extract (tracer, message) {
|
|
35
|
+
return message
|
|
36
|
+
? tracer.extract(TEXT_MAP, message.properties.headers)
|
|
37
|
+
: null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = AmqplibConsumerPlugin
|
|
@@ -1,108 +1,20 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const store = storage.getStore()
|
|
18
|
-
let childOf
|
|
19
|
-
|
|
20
|
-
if (method === 'basic.deliver') {
|
|
21
|
-
childOf = extract(this.tracer, message)
|
|
22
|
-
} else {
|
|
23
|
-
fields.headers = fields.headers || {}
|
|
24
|
-
childOf = store ? store.span : store
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const span = this.tracer.startSpan('amqp.command', {
|
|
28
|
-
childOf,
|
|
29
|
-
tags: {
|
|
30
|
-
'service.name': this.config.service || `${this.tracer._service}-amqp`,
|
|
31
|
-
'resource.name': getResourceName(method, fields)
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
if (channel && channel.connection && channel.connection.stream) {
|
|
36
|
-
span.addTags({
|
|
37
|
-
'out.host': channel.connection.stream._host,
|
|
38
|
-
'out.port': channel.connection.stream.remotePort
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
const fieldNames = [
|
|
42
|
-
'queue',
|
|
43
|
-
'exchange',
|
|
44
|
-
'routingKey',
|
|
45
|
-
'consumerTag',
|
|
46
|
-
'source',
|
|
47
|
-
'destination'
|
|
48
|
-
]
|
|
49
|
-
|
|
50
|
-
switch (method) {
|
|
51
|
-
case 'basic.publish':
|
|
52
|
-
span.setTag('span.kind', 'producer')
|
|
53
|
-
break
|
|
54
|
-
case 'basic.consume':
|
|
55
|
-
case 'basic.get':
|
|
56
|
-
case 'basic.deliver':
|
|
57
|
-
span.addTags({
|
|
58
|
-
'span.kind': 'consumer',
|
|
59
|
-
'span.type': 'worker'
|
|
60
|
-
})
|
|
61
|
-
break
|
|
62
|
-
default:
|
|
63
|
-
span.setTag('span.kind', 'client')
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
fieldNames.forEach(field => {
|
|
67
|
-
fields[field] !== undefined && span.setTag(`amqp.${field}`, fields[field])
|
|
68
|
-
})
|
|
69
|
-
if (method === 'basic.deliver') {
|
|
70
|
-
analyticsSampler.sample(span, this.config.measured, true)
|
|
71
|
-
} else {
|
|
72
|
-
this.tracer.inject(span, TEXT_MAP, fields.headers)
|
|
73
|
-
analyticsSampler.sample(span, this.config.measured)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
this.enter(span, store)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
this.addSub(`apm:amqplib:command:finish`, () => {
|
|
80
|
-
const span = storage.getStore().span
|
|
81
|
-
span.finish()
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
this.addSub(`apm:amqplib:command:error`, err => {
|
|
85
|
-
const span = storage.getStore().span
|
|
86
|
-
span.setTag('error', err)
|
|
87
|
-
})
|
|
3
|
+
const ProducerPlugin = require('./producer')
|
|
4
|
+
const ConsumerPlugin = require('./consumer')
|
|
5
|
+
const ClientPlugin = require('./client')
|
|
6
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
7
|
+
|
|
8
|
+
// TODO: Consider splitting channels for publish/receive in the instrumentation.
|
|
9
|
+
class AmqplibPlugin extends CompositePlugin {
|
|
10
|
+
static get name () { return 'amqplib' }
|
|
11
|
+
static get plugins () {
|
|
12
|
+
return {
|
|
13
|
+
producer: ProducerPlugin,
|
|
14
|
+
consumer: ConsumerPlugin,
|
|
15
|
+
client: ClientPlugin
|
|
16
|
+
}
|
|
88
17
|
}
|
|
89
18
|
}
|
|
90
19
|
|
|
91
|
-
function getResourceName (method, fields = {}) {
|
|
92
|
-
return [
|
|
93
|
-
method,
|
|
94
|
-
fields.exchange,
|
|
95
|
-
fields.routingKey,
|
|
96
|
-
fields.queue,
|
|
97
|
-
fields.source,
|
|
98
|
-
fields.destination
|
|
99
|
-
].filter(val => val).join(' ')
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function extract (tracer, message) {
|
|
103
|
-
return message
|
|
104
|
-
? tracer.extract(TEXT_MAP, message.properties.headers)
|
|
105
|
-
: null
|
|
106
|
-
}
|
|
107
|
-
|
|
108
20
|
module.exports = AmqplibPlugin
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { TEXT_MAP } = require('../../../ext/formats')
|
|
4
|
+
const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
|
|
5
|
+
const { getResourceName } = require('./util')
|
|
6
|
+
|
|
7
|
+
class AmqplibProducerPlugin extends ProducerPlugin {
|
|
8
|
+
static get name () { return 'amqplib' }
|
|
9
|
+
static get operation () { return 'command' }
|
|
10
|
+
|
|
11
|
+
start ({ channel = {}, method, fields }) {
|
|
12
|
+
if (method !== 'basic.publish') return
|
|
13
|
+
|
|
14
|
+
const stream = (channel.connection && channel.connection.stream) || {}
|
|
15
|
+
const span = this.startSpan('amqp.command', {
|
|
16
|
+
service: this.config.service || `${this.tracer._service}-amqp`,
|
|
17
|
+
resource: getResourceName(method, fields),
|
|
18
|
+
kind: 'producer',
|
|
19
|
+
meta: {
|
|
20
|
+
'out.host': stream._host,
|
|
21
|
+
'out.port': stream.remotePort,
|
|
22
|
+
'amqp.queue': fields.queue,
|
|
23
|
+
'amqp.exchange': fields.exchange,
|
|
24
|
+
'amqp.routingKey': fields.routingKey,
|
|
25
|
+
'amqp.consumerTag': fields.consumerTag,
|
|
26
|
+
'amqp.source': fields.source,
|
|
27
|
+
'amqp.destination': fields.destination
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
fields.headers = fields.headers || {}
|
|
32
|
+
|
|
33
|
+
this.tracer.inject(span, TEXT_MAP, fields.headers)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = AmqplibProducerPlugin
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
function getResourceName (method, fields = {}) {
|
|
4
|
+
return [
|
|
5
|
+
method,
|
|
6
|
+
fields.exchange,
|
|
7
|
+
fields.routingKey,
|
|
8
|
+
fields.queue,
|
|
9
|
+
fields.source,
|
|
10
|
+
fields.destination
|
|
11
|
+
].filter(val => val).join(' ')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = { getResourceName }
|
|
@@ -1,98 +1,23 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const tags = {
|
|
20
|
-
'service.name': this.config.service || this.tracer._service,
|
|
21
|
-
'span.kind': 'client'
|
|
3
|
+
const CompositePlugin = require('../../dd-trace/src/plugins/composite')
|
|
4
|
+
const DNSLookupPlugin = require('./lookup')
|
|
5
|
+
const DNSLookupServicePlugin = require('./lookup_service')
|
|
6
|
+
const DNSResolvePlugin = require('./resolve')
|
|
7
|
+
const DNSReversePlugin = require('./reverse')
|
|
8
|
+
|
|
9
|
+
// TODO: Are DNS spans really client spans?
|
|
10
|
+
|
|
11
|
+
class DNSPlugin extends CompositePlugin {
|
|
12
|
+
static get name () { return 'dns' }
|
|
13
|
+
static get plugins () {
|
|
14
|
+
return {
|
|
15
|
+
lookup: DNSLookupPlugin,
|
|
16
|
+
lookup_service: DNSLookupServicePlugin,
|
|
17
|
+
resolve: DNSResolvePlugin,
|
|
18
|
+
reverse: DNSReversePlugin
|
|
22
19
|
}
|
|
23
|
-
for (const tag in customTags) {
|
|
24
|
-
tags[tag] = customTags[tag]
|
|
25
|
-
}
|
|
26
|
-
const span = this.tracer.startSpan(name, {
|
|
27
|
-
childOf: store ? store.span : null,
|
|
28
|
-
tags
|
|
29
|
-
})
|
|
30
|
-
analyticsSampler.sample(span, this.config.measured)
|
|
31
|
-
return span
|
|
32
20
|
}
|
|
33
|
-
|
|
34
|
-
constructor (...args) {
|
|
35
|
-
super(...args)
|
|
36
|
-
|
|
37
|
-
this.addSubs('lookup', ([hostname]) => {
|
|
38
|
-
const store = storage.getStore()
|
|
39
|
-
const span = this.startSpan('dns.lookup', {
|
|
40
|
-
'resource.name': hostname,
|
|
41
|
-
'dns.hostname': hostname
|
|
42
|
-
}, store)
|
|
43
|
-
this.enter(span, store)
|
|
44
|
-
}, (result) => {
|
|
45
|
-
const { span } = storage.getStore()
|
|
46
|
-
|
|
47
|
-
if (Array.isArray(result)) {
|
|
48
|
-
const addresses = Array.isArray(result)
|
|
49
|
-
? result.map(address => address.address).sort()
|
|
50
|
-
: [result]
|
|
51
|
-
|
|
52
|
-
span.setTag('dns.address', addresses[0])
|
|
53
|
-
span.setTag('dns.addresses', addresses.join(','))
|
|
54
|
-
} else {
|
|
55
|
-
span.setTag('dns.address', result)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
span.finish()
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
this.addSubs('lookup_service', ([address, port]) => {
|
|
62
|
-
const store = storage.getStore()
|
|
63
|
-
const span = this.startSpan('dns.lookup_service', {
|
|
64
|
-
'resource.name': `${address}:${port}`,
|
|
65
|
-
'dns.address': address,
|
|
66
|
-
'dns.port': port
|
|
67
|
-
}, store)
|
|
68
|
-
this.enter(span, store)
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
this.addSubs('resolve', ([hostname, maybeType]) => {
|
|
72
|
-
const store = storage.getStore()
|
|
73
|
-
const rrtype = typeof maybeType === 'string' ? maybeType : 'A'
|
|
74
|
-
const span = this.startSpan('dns.resolve', {
|
|
75
|
-
'resource.name': `${rrtype} ${hostname}`,
|
|
76
|
-
'dns.hostname': hostname,
|
|
77
|
-
'dns.rrtype': rrtype
|
|
78
|
-
}, store)
|
|
79
|
-
this.enter(span, store)
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
this.addSubs('reverse', ([ip]) => {
|
|
83
|
-
const store = storage.getStore()
|
|
84
|
-
const span = this.startSpan('dns.reverse', { 'resource.name': ip, 'dns.ip': ip }, store)
|
|
85
|
-
this.enter(span, store)
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function defaultFinish () {
|
|
91
|
-
storage.getStore().span.finish()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function errorHandler (error) {
|
|
95
|
-
storage.getStore().span.setTag('error', error)
|
|
96
21
|
}
|
|
97
22
|
|
|
98
23
|
module.exports = DNSPlugin
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
|
+
|
|
5
|
+
class DNSLookupPlugin extends ClientPlugin {
|
|
6
|
+
static get name () { return 'dns' }
|
|
7
|
+
static get operation () { return 'lookup' }
|
|
8
|
+
|
|
9
|
+
start ([hostname]) {
|
|
10
|
+
this.startSpan('dns.lookup', {
|
|
11
|
+
service: this.config.service,
|
|
12
|
+
resource: hostname,
|
|
13
|
+
kind: 'client',
|
|
14
|
+
meta: {
|
|
15
|
+
'dns.hostname': hostname,
|
|
16
|
+
'dns.address': '',
|
|
17
|
+
'dns.addresses': ''
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
finish (result) {
|
|
23
|
+
const span = this.activeSpan
|
|
24
|
+
|
|
25
|
+
if (Array.isArray(result)) {
|
|
26
|
+
const addresses = Array.isArray(result)
|
|
27
|
+
? result.map(address => address.address).sort()
|
|
28
|
+
: [result]
|
|
29
|
+
|
|
30
|
+
span.setTag('dns.address', addresses[0])
|
|
31
|
+
span.setTag('dns.addresses', addresses.join(','))
|
|
32
|
+
} else {
|
|
33
|
+
span.setTag('dns.address', result)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
span.finish()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module.exports = DNSLookupPlugin
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
|
+
|
|
5
|
+
class DNSLookupServicePlugin extends ClientPlugin {
|
|
6
|
+
static get name () { return 'dns' }
|
|
7
|
+
static get operation () { return 'lookup_service' }
|
|
8
|
+
|
|
9
|
+
start ([address, port]) {
|
|
10
|
+
this.startSpan('dns.lookup_service', {
|
|
11
|
+
service: this.config.service,
|
|
12
|
+
resource: `${address}:${port}`,
|
|
13
|
+
kind: 'client',
|
|
14
|
+
meta: {
|
|
15
|
+
'dns.address': address
|
|
16
|
+
},
|
|
17
|
+
metrics: {
|
|
18
|
+
'dns.port': port
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = DNSLookupServicePlugin
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
|
+
|
|
5
|
+
class DNSResolvePlugin extends ClientPlugin {
|
|
6
|
+
static get name () { return 'dns' }
|
|
7
|
+
static get operation () { return 'resolve' }
|
|
8
|
+
|
|
9
|
+
start ([hostname, maybeType]) {
|
|
10
|
+
const rrtype = typeof maybeType === 'string' ? maybeType : 'A'
|
|
11
|
+
|
|
12
|
+
this.startSpan('dns.resolve', {
|
|
13
|
+
service: this.config.service,
|
|
14
|
+
resource: `${rrtype} ${hostname}`,
|
|
15
|
+
kind: 'client',
|
|
16
|
+
meta: {
|
|
17
|
+
'dns.hostname': hostname,
|
|
18
|
+
'dns.rrtype': rrtype
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = DNSResolvePlugin
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
|
+
|
|
5
|
+
class DNSReversePlugin extends ClientPlugin {
|
|
6
|
+
static get name () { return 'dns' }
|
|
7
|
+
static get operation () { return 'reverse' }
|
|
8
|
+
|
|
9
|
+
start ([ip]) {
|
|
10
|
+
this.startSpan('dns.reverse', {
|
|
11
|
+
service: this.config.service,
|
|
12
|
+
resource: ip,
|
|
13
|
+
kind: 'client',
|
|
14
|
+
meta: {
|
|
15
|
+
'dns.ip': ip
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
module.exports = DNSReversePlugin
|
|
@@ -8,23 +8,23 @@ class ElasticsearchPlugin extends DatabasePlugin {
|
|
|
8
8
|
start ({ params }) {
|
|
9
9
|
const body = getBody(params.body || params.bulkBody)
|
|
10
10
|
|
|
11
|
-
this.startSpan(
|
|
11
|
+
this.startSpan(`${this.system}.query`, {
|
|
12
12
|
service: this.config.service,
|
|
13
13
|
resource: `${params.method} ${quantizePath(params.path)}`,
|
|
14
14
|
type: 'elasticsearch',
|
|
15
15
|
kind: 'client',
|
|
16
16
|
meta: {
|
|
17
|
-
'db.type':
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
'db.type': this.system,
|
|
18
|
+
[`${this.system}.url`]: params.path,
|
|
19
|
+
[`${this.system}.method`]: params.method,
|
|
20
|
+
[`${this.system}.body`]: body,
|
|
21
|
+
[`${this.system}.params`]: JSON.stringify(params.querystring || params.query)
|
|
22
22
|
}
|
|
23
23
|
})
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
finish ({ params }) {
|
|
27
|
-
const span = this.activeSpan
|
|
27
|
+
const span = this.activeSpan
|
|
28
28
|
this.config.hooks.query(span, params)
|
|
29
29
|
super.finish({ params })
|
|
30
30
|
}
|