dd-trace 3.21.0 → 3.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 +1 -0
- package/package.json +3 -2
- package/packages/datadog-esbuild/index.js +13 -1
- 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/pg.js +14 -11
- 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/datadog-plugin-router/src/index.js +12 -1
- 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/telemetry/logs.js +1 -1
- 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 +36 -5
- 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/telemetry/index.js +5 -6
- package/packages/dd-trace/src/telemetry/send-data.js +17 -5
- package/packages/dd-trace/src/plugins/incoming.js +0 -7
|
@@ -4,15 +4,16 @@ const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
|
4
4
|
|
|
5
5
|
class GoogleCloudPubsubClientPlugin extends ClientPlugin {
|
|
6
6
|
static get id () { return 'google-cloud-pubsub' }
|
|
7
|
+
static get type () { return 'messaging' }
|
|
7
8
|
static get operation () { return 'request' }
|
|
8
9
|
|
|
9
10
|
start ({ request, api, projectId }) {
|
|
10
11
|
if (api === 'publish') return
|
|
11
12
|
|
|
12
|
-
this.startSpan(
|
|
13
|
-
service: this.config.service ||
|
|
13
|
+
this.startSpan(this.operationName(), {
|
|
14
|
+
service: this.config.service || this.serviceName(),
|
|
14
15
|
resource: [api, request.name].filter(x => x).join(' '),
|
|
15
|
-
kind:
|
|
16
|
+
kind: this.constructor.kind,
|
|
16
17
|
meta: {
|
|
17
18
|
'pubsub.method': api,
|
|
18
19
|
'gcloud.project_id': projectId
|
|
@@ -11,11 +11,9 @@ class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
|
|
|
11
11
|
const topic = subscription.metadata && subscription.metadata.topic
|
|
12
12
|
const childOf = this.tracer.extract('text_map', message.attributes) || null
|
|
13
13
|
|
|
14
|
-
this.startSpan(
|
|
14
|
+
this.startSpan({
|
|
15
15
|
childOf,
|
|
16
|
-
service: this.config.service,
|
|
17
16
|
resource: topic,
|
|
18
|
-
kind: 'consumer',
|
|
19
17
|
type: 'worker',
|
|
20
18
|
meta: {
|
|
21
19
|
'gcloud.project_id': subscription.pubsub.projectId,
|
|
@@ -11,10 +11,8 @@ class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
|
|
|
11
11
|
|
|
12
12
|
const messages = request.messages || []
|
|
13
13
|
const topic = request.topic
|
|
14
|
-
const span = this.startSpan(
|
|
15
|
-
service: this.config.service || `${this.tracer._service}-pubsub`,
|
|
14
|
+
const span = this.startSpan({ // TODO: rename
|
|
16
15
|
resource: `${api} ${topic}`,
|
|
17
|
-
kind: 'producer',
|
|
18
16
|
meta: {
|
|
19
17
|
'gcloud.project_id': projectId,
|
|
20
18
|
'pubsub.method': api, // TODO: remove
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
4
4
|
const { storage } = require('../../datadog-core')
|
|
5
5
|
const tags = require('../../../ext/tags')
|
|
6
6
|
const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
|
|
@@ -9,97 +9,99 @@ const HTTP_HEADERS = formats.HTTP_HEADERS
|
|
|
9
9
|
const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
|
|
10
10
|
const log = require('../../dd-trace/src/log')
|
|
11
11
|
const url = require('url')
|
|
12
|
-
const { COMPONENT, ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
|
|
12
|
+
const { CLIENT_PORT_KEY, COMPONENT, ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
|
|
13
13
|
|
|
14
14
|
const HTTP_STATUS_CODE = tags.HTTP_STATUS_CODE
|
|
15
15
|
const HTTP_REQUEST_HEADERS = tags.HTTP_REQUEST_HEADERS
|
|
16
16
|
const HTTP_RESPONSE_HEADERS = tags.HTTP_RESPONSE_HEADERS
|
|
17
17
|
|
|
18
|
-
class HttpClientPlugin extends
|
|
18
|
+
class HttpClientPlugin extends ClientPlugin {
|
|
19
19
|
static get id () {
|
|
20
20
|
return 'http'
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.addSub('apm:http:client:request:start', ({ args, http }) => {
|
|
27
|
-
const store = storage.getStore()
|
|
28
|
-
const options = args.options
|
|
29
|
-
const agent = options.agent || options._defaultAgent || http.globalAgent
|
|
30
|
-
const protocol = options.protocol || agent.protocol || 'http:'
|
|
31
|
-
const hostname = options.hostname || options.host || 'localhost'
|
|
32
|
-
const host = options.port ? `${hostname}:${options.port}` : hostname
|
|
33
|
-
const path = options.path ? options.path.split(/[?#]/)[0] : '/'
|
|
34
|
-
const uri = `${protocol}//${host}${path}`
|
|
35
|
-
const allowed = this.config.filter(uri)
|
|
36
|
-
|
|
37
|
-
const method = (options.method || 'GET').toUpperCase()
|
|
38
|
-
const childOf = store && allowed ? store.span : null
|
|
39
|
-
const span = this.tracer.startSpan('http.request', {
|
|
40
|
-
childOf,
|
|
41
|
-
tags: {
|
|
42
|
-
[COMPONENT]: this.constructor.id,
|
|
43
|
-
'span.kind': 'client',
|
|
44
|
-
'service.name': getServiceName(this.tracer, this.config, options),
|
|
45
|
-
'resource.name': method,
|
|
46
|
-
'span.type': 'http',
|
|
47
|
-
'http.method': method,
|
|
48
|
-
'http.url': uri,
|
|
49
|
-
'out.host': hostname
|
|
50
|
-
}
|
|
51
|
-
})
|
|
23
|
+
addTraceSub (eventName, handler) {
|
|
24
|
+
this.addSub(`apm:${this.constructor.id}:client:${this.operation}:${eventName}`, handler)
|
|
25
|
+
}
|
|
52
26
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
27
|
+
start ({ args, http }) {
|
|
28
|
+
const store = storage.getStore()
|
|
29
|
+
const options = args.options
|
|
30
|
+
const agent = options.agent || options._defaultAgent || http.globalAgent
|
|
31
|
+
const protocol = options.protocol || agent.protocol || 'http:'
|
|
32
|
+
const hostname = options.hostname || options.host || 'localhost'
|
|
33
|
+
const host = options.port ? `${hostname}:${options.port}` : hostname
|
|
34
|
+
const path = options.path ? options.path.split(/[?#]/)[0] : '/'
|
|
35
|
+
const uri = `${protocol}//${host}${path}`
|
|
36
|
+
const allowed = this.config.filter(uri)
|
|
37
|
+
|
|
38
|
+
const method = (options.method || 'GET').toUpperCase()
|
|
39
|
+
const childOf = store && allowed ? store.span : null
|
|
40
|
+
// TODO delegate to super.startspan
|
|
41
|
+
const span = this.startSpan('http.request', {
|
|
42
|
+
childOf,
|
|
43
|
+
meta: {
|
|
44
|
+
[COMPONENT]: this.constructor.id,
|
|
45
|
+
'span.kind': 'client',
|
|
46
|
+
'service.name': getServiceName(this.tracer, this.config, options),
|
|
47
|
+
'resource.name': method,
|
|
48
|
+
'span.type': 'http',
|
|
49
|
+
'http.method': method,
|
|
50
|
+
'http.url': uri,
|
|
51
|
+
'out.host': hostname
|
|
52
|
+
},
|
|
53
|
+
metrics: {
|
|
54
|
+
[CLIENT_PORT_KEY]: parseInt(options.port)
|
|
56
55
|
}
|
|
56
|
+
})
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
// TODO: Figure out a better way to do this for any span.
|
|
59
|
+
if (!allowed) {
|
|
60
|
+
span._spanContext._trace.record = false
|
|
61
|
+
}
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
}
|
|
63
|
+
if (!(hasAmazonSignature(options) || !this.config.propagationFilter(uri))) {
|
|
64
|
+
this.tracer.inject(span, HTTP_HEADERS, options.headers)
|
|
65
|
+
}
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
span.setTag(HTTP_STATUS_CODE, res.statusCode)
|
|
67
|
+
analyticsSampler.sample(span, this.config.measured)
|
|
68
|
+
this.enter(span, store)
|
|
69
|
+
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
finish ({ req, res }) {
|
|
72
|
+
const span = storage.getStore().span
|
|
73
|
+
if (res) {
|
|
74
|
+
span.setTag(HTTP_STATUS_CODE, res.statusCode)
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
if (!this.config.validateStatus(res.statusCode)) {
|
|
77
|
+
span.setTag('error', 1)
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
|
|
80
|
+
addResponseHeaders(res, span, this.config)
|
|
81
|
+
}
|
|
79
82
|
|
|
80
|
-
|
|
81
|
-
span.finish()
|
|
82
|
-
})
|
|
83
|
+
addRequestHeaders(req, span, this.config)
|
|
83
84
|
|
|
84
|
-
this.
|
|
85
|
+
this.config.hooks.request(span, req, res)
|
|
86
|
+
span.finish()
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
}
|
|
89
|
+
error (err) {
|
|
90
|
+
const span = storage.getStore().span
|
|
91
91
|
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
if (err) {
|
|
93
|
+
span.addTags({
|
|
94
|
+
[ERROR_TYPE]: err.name,
|
|
95
|
+
[ERROR_MESSAGE]: err.message || err.code,
|
|
96
|
+
[ERROR_STACK]: err.stack
|
|
97
|
+
})
|
|
98
|
+
} else {
|
|
99
|
+
span.setTag('error', 1)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
94
102
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
[ERROR_TYPE]: err.name,
|
|
98
|
-
[ERROR_MESSAGE]: err.message || err.code,
|
|
99
|
-
[ERROR_STACK]: err.stack
|
|
100
|
-
})
|
|
101
|
-
} else {
|
|
102
|
-
span.setTag('error', 1)
|
|
103
|
+
configure (config) {
|
|
104
|
+
return super.configure(normalizeClientConfig(config))
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
107
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { storage } = require('../../datadog-core')
|
|
4
|
-
const
|
|
4
|
+
const ClientPlugin = require('../../dd-trace/src/plugins/client')
|
|
5
5
|
|
|
6
6
|
const URL = require('url').URL
|
|
7
7
|
const log = require('../../dd-trace/src/log')
|
|
@@ -24,7 +24,7 @@ const HTTP2_HEADER_PATH = ':path'
|
|
|
24
24
|
const HTTP2_HEADER_STATUS = ':status'
|
|
25
25
|
const HTTP2_METHOD_GET = 'GET'
|
|
26
26
|
|
|
27
|
-
class Http2ClientPlugin extends
|
|
27
|
+
class Http2ClientPlugin extends ClientPlugin {
|
|
28
28
|
static get id () {
|
|
29
29
|
return 'http2'
|
|
30
30
|
}
|
|
@@ -32,47 +32,6 @@ class Http2ClientPlugin extends Plugin {
|
|
|
32
32
|
constructor (...args) {
|
|
33
33
|
super(...args)
|
|
34
34
|
|
|
35
|
-
this.addSub('apm:http2:client:request:start', ({ authority, options, headers = {} }) => {
|
|
36
|
-
const sessionDetails = extractSessionDetails(authority, options)
|
|
37
|
-
const path = headers[HTTP2_HEADER_PATH] || '/'
|
|
38
|
-
const pathname = path.split(/[?#]/)[0]
|
|
39
|
-
const method = headers[HTTP2_HEADER_METHOD] || HTTP2_METHOD_GET
|
|
40
|
-
const uri = `${sessionDetails.protocol}//${sessionDetails.host}:${sessionDetails.port}${pathname}`
|
|
41
|
-
const allowed = this.config.filter(uri)
|
|
42
|
-
|
|
43
|
-
const store = storage.getStore()
|
|
44
|
-
const childOf = store && allowed ? store.span : null
|
|
45
|
-
const span = this.tracer.startSpan('http.request', {
|
|
46
|
-
childOf,
|
|
47
|
-
tags: {
|
|
48
|
-
[COMPONENT]: this.constructor.id,
|
|
49
|
-
[CLIENT_PORT_KEY]: parseInt(sessionDetails.port),
|
|
50
|
-
[SPAN_KIND]: CLIENT,
|
|
51
|
-
'service.name': getServiceName(this.tracer, this.config, sessionDetails),
|
|
52
|
-
'resource.name': method,
|
|
53
|
-
'span.type': 'http',
|
|
54
|
-
'http.method': method,
|
|
55
|
-
'http.url': uri,
|
|
56
|
-
'out.host': sessionDetails.host
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
// TODO: Figure out a better way to do this for any span.
|
|
61
|
-
if (!allowed) {
|
|
62
|
-
span._spanContext._trace.record = false
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
addHeaderTags(span, headers, HTTP_REQUEST_HEADERS, this.config)
|
|
66
|
-
|
|
67
|
-
if (!hasAmazonSignature(headers, path)) {
|
|
68
|
-
this.tracer.inject(span, HTTP_HEADERS, headers)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
analyticsSampler.sample(span, this.config.measured)
|
|
72
|
-
|
|
73
|
-
this.enter(span, store)
|
|
74
|
-
})
|
|
75
|
-
|
|
76
35
|
this.addSub('apm:http2:client:response', (headers) => {
|
|
77
36
|
const span = storage.getStore().span
|
|
78
37
|
const status = headers && headers[HTTP2_HEADER_STATUS]
|
|
@@ -85,14 +44,58 @@ class Http2ClientPlugin extends Plugin {
|
|
|
85
44
|
|
|
86
45
|
addHeaderTags(span, headers, HTTP_RESPONSE_HEADERS, this.config)
|
|
87
46
|
})
|
|
47
|
+
}
|
|
88
48
|
|
|
89
|
-
|
|
90
|
-
|
|
49
|
+
addTraceSub (eventName, handler) {
|
|
50
|
+
this.addSub(`apm:${this.constructor.id}:client:${this.operation}:${eventName}`, handler)
|
|
51
|
+
}
|
|
91
52
|
|
|
92
|
-
|
|
53
|
+
start ({ authority, options, headers = {} }) {
|
|
54
|
+
const sessionDetails = extractSessionDetails(authority, options)
|
|
55
|
+
const path = headers[HTTP2_HEADER_PATH] || '/'
|
|
56
|
+
const pathname = path.split(/[?#]/)[0]
|
|
57
|
+
const method = headers[HTTP2_HEADER_METHOD] || HTTP2_METHOD_GET
|
|
58
|
+
const uri = `${sessionDetails.protocol}//${sessionDetails.host}:${sessionDetails.port}${pathname}`
|
|
59
|
+
const allowed = this.config.filter(uri)
|
|
60
|
+
|
|
61
|
+
const store = storage.getStore()
|
|
62
|
+
const childOf = store && allowed ? store.span : null
|
|
63
|
+
const span = this.startSpan('http.request', {
|
|
64
|
+
childOf,
|
|
65
|
+
meta: {
|
|
66
|
+
[COMPONENT]: this.constructor.id,
|
|
67
|
+
[SPAN_KIND]: CLIENT,
|
|
68
|
+
'service.name': getServiceName(this.tracer, this.config, sessionDetails),
|
|
69
|
+
'resource.name': method,
|
|
70
|
+
'span.type': 'http',
|
|
71
|
+
'http.method': method,
|
|
72
|
+
'http.url': uri,
|
|
73
|
+
'out.host': sessionDetails.host
|
|
74
|
+
},
|
|
75
|
+
metrics: {
|
|
76
|
+
[CLIENT_PORT_KEY]: parseInt(sessionDetails.port)
|
|
77
|
+
}
|
|
93
78
|
})
|
|
94
79
|
|
|
95
|
-
|
|
80
|
+
// TODO: Figure out a better way to do this for any span.
|
|
81
|
+
if (!allowed) {
|
|
82
|
+
span._spanContext._trace.record = false
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
addHeaderTags(span, headers, HTTP_REQUEST_HEADERS, this.config)
|
|
86
|
+
|
|
87
|
+
if (!hasAmazonSignature(headers, path)) {
|
|
88
|
+
this.tracer.inject(span, HTTP_HEADERS, headers)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
analyticsSampler.sample(span, this.config.measured)
|
|
92
|
+
|
|
93
|
+
this.enter(span, store)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
finish () {
|
|
97
|
+
const span = storage.getStore().span
|
|
98
|
+
span.finish()
|
|
96
99
|
}
|
|
97
100
|
|
|
98
101
|
configure (config) {
|
|
@@ -118,8 +118,8 @@ class JestPlugin extends CiPlugin {
|
|
|
118
118
|
|
|
119
119
|
this.addSub('ci:jest:worker-report:coverage', data => {
|
|
120
120
|
const formattedCoverages = JSON.parse(data).map(coverage => ({
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
sessionId: id(coverage.sessionId),
|
|
122
|
+
suiteId: id(coverage.suiteId),
|
|
123
123
|
files: coverage.files
|
|
124
124
|
}))
|
|
125
125
|
formattedCoverages.forEach(formattedCoverage => {
|
|
@@ -150,9 +150,10 @@ class JestPlugin extends CiPlugin {
|
|
|
150
150
|
* fetching the ITR config.
|
|
151
151
|
*/
|
|
152
152
|
this.addSub('ci:jest:test-suite:code-coverage', (coverageFiles) => {
|
|
153
|
+
const { _traceId, _spanId } = this.testSuiteSpan.context()
|
|
153
154
|
const formattedCoverage = {
|
|
154
|
-
|
|
155
|
-
|
|
155
|
+
sessionId: _traceId,
|
|
156
|
+
suiteId: _spanId,
|
|
156
157
|
files: coverageFiles
|
|
157
158
|
}
|
|
158
159
|
this.tracer._exporter.exportCoverage(formattedCoverage)
|
|
@@ -8,12 +8,9 @@ class KafkajsConsumerPlugin extends ConsumerPlugin {
|
|
|
8
8
|
|
|
9
9
|
start ({ topic, partition, message }) {
|
|
10
10
|
const childOf = extract(this.tracer, message.headers)
|
|
11
|
-
|
|
12
|
-
this.startSpan('kafka.consume', {
|
|
11
|
+
this.startSpan({
|
|
13
12
|
childOf,
|
|
14
|
-
service: this.config.service || `${this.tracer._service}-kafka`,
|
|
15
13
|
resource: topic,
|
|
16
|
-
kind: 'consumer',
|
|
17
14
|
type: 'worker',
|
|
18
15
|
meta: {
|
|
19
16
|
'component': 'kafkajs',
|
|
@@ -7,10 +7,8 @@ class KafkajsProducerPlugin extends ProducerPlugin {
|
|
|
7
7
|
static get operation () { return 'produce' }
|
|
8
8
|
|
|
9
9
|
start ({ topic, messages }) {
|
|
10
|
-
const span = this.startSpan(
|
|
11
|
-
service: this.config.service || `${this.tracer._service}-kafka`,
|
|
10
|
+
const span = this.startSpan({
|
|
12
11
|
resource: topic,
|
|
13
|
-
kind: 'producer',
|
|
14
12
|
meta: {
|
|
15
13
|
'component': 'kafkajs',
|
|
16
14
|
'kafka.topic': topic
|
|
@@ -9,11 +9,10 @@ class MemcachedPlugin extends CachePlugin {
|
|
|
9
9
|
start ({ client, server, query }) {
|
|
10
10
|
const address = getAddress(client, server, query)
|
|
11
11
|
|
|
12
|
-
this.startSpan(
|
|
13
|
-
service: this.config.
|
|
12
|
+
this.startSpan({
|
|
13
|
+
service: this.serviceName(this.config, this.system),
|
|
14
14
|
resource: query.type,
|
|
15
15
|
type: 'memcached',
|
|
16
|
-
kind: 'client',
|
|
17
16
|
meta: {
|
|
18
17
|
'memcached.command': query.command,
|
|
19
18
|
'out.host': address[0],
|
|
@@ -36,9 +36,11 @@ class MochaPlugin extends CiPlugin {
|
|
|
36
36
|
const relativeCoverageFiles = [...coverageFiles, suiteFile]
|
|
37
37
|
.map(filename => getTestSuitePath(filename, this.sourceRoot))
|
|
38
38
|
|
|
39
|
+
const { _traceId, _spanId } = testSuiteSpan.context()
|
|
40
|
+
|
|
39
41
|
const formattedCoverage = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
sessionId: _traceId,
|
|
43
|
+
suiteId: _spanId,
|
|
42
44
|
files: relativeCoverageFiles
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -13,11 +13,10 @@ class RedisPlugin extends CachePlugin {
|
|
|
13
13
|
const normalizedCommand = command.toUpperCase()
|
|
14
14
|
if (!this.config.filter(normalizedCommand)) return this.skip()
|
|
15
15
|
|
|
16
|
-
this.startSpan(
|
|
17
|
-
service: getService(this.config, connectionName),
|
|
16
|
+
this.startSpan({
|
|
18
17
|
resource,
|
|
18
|
+
service: this.serviceName(this.config, this.system, connectionName),
|
|
19
19
|
type: 'redis',
|
|
20
|
-
kind: 'client',
|
|
21
20
|
meta: {
|
|
22
21
|
'db.type': 'redis',
|
|
23
22
|
'db.name': db || '0',
|
|
@@ -33,16 +32,6 @@ class RedisPlugin extends CachePlugin {
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
function getService (config, connectionName) {
|
|
37
|
-
if (config.splitByInstance && connectionName) {
|
|
38
|
-
return config.service
|
|
39
|
-
? `${config.service}-${connectionName}`
|
|
40
|
-
: connectionName
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return config.service
|
|
44
|
-
}
|
|
45
|
-
|
|
46
35
|
function formatCommand (command, args) {
|
|
47
36
|
if (!args || command === 'AUTH') return command
|
|
48
37
|
|
|
@@ -19,12 +19,10 @@ class RheaConsumerPlugin extends ConsumerPlugin {
|
|
|
19
19
|
const name = getResourceNameFromMessage(msgObj)
|
|
20
20
|
const childOf = extractTextMap(msgObj, this.tracer)
|
|
21
21
|
|
|
22
|
-
this.startSpan(
|
|
22
|
+
this.startSpan({
|
|
23
23
|
childOf,
|
|
24
|
-
service: this.config.service,
|
|
25
24
|
resource: name,
|
|
26
25
|
type: 'worker',
|
|
27
|
-
kind: 'consumer',
|
|
28
26
|
meta: {
|
|
29
27
|
'component': 'rhea',
|
|
30
28
|
'amqp.link.source.address': name,
|
|
@@ -9,17 +9,13 @@ class RheaProducerPlugin extends ProducerPlugin {
|
|
|
9
9
|
|
|
10
10
|
constructor (...args) {
|
|
11
11
|
super(...args)
|
|
12
|
-
|
|
13
12
|
this.addTraceSub('encode', this.encode.bind(this))
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
start ({ targetAddress, host, port }) {
|
|
17
16
|
const name = targetAddress || 'amq.topic'
|
|
18
|
-
|
|
19
|
-
this.startSpan('amqp.send', {
|
|
20
|
-
service: this.config.service || `${this.tracer._service}-amqp-producer`,
|
|
17
|
+
this.startSpan({
|
|
21
18
|
resource: name,
|
|
22
|
-
kind: 'producer',
|
|
23
19
|
meta: {
|
|
24
20
|
'component': 'rhea',
|
|
25
21
|
'amqp.link.target.address': name,
|
|
@@ -130,7 +130,7 @@ class RouterPlugin extends WebPlugin {
|
|
|
130
130
|
route = context.stack.join('')
|
|
131
131
|
|
|
132
132
|
// Longer route is more likely to be the actual route handler route.
|
|
133
|
-
if (route
|
|
133
|
+
if (isMoreSpecificThan(route, context.route)) {
|
|
134
134
|
context.route = route
|
|
135
135
|
}
|
|
136
136
|
} else {
|
|
@@ -148,4 +148,15 @@ class RouterPlugin extends WebPlugin {
|
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
function isMoreSpecificThan (routeA, routeB) {
|
|
152
|
+
if (!routeIsRegex(routeA) && routeIsRegex(routeB)) {
|
|
153
|
+
return true
|
|
154
|
+
}
|
|
155
|
+
return routeA.length > routeB.length
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function routeIsRegex (route) {
|
|
159
|
+
return route.includes('(/') && route.includes('/)')
|
|
160
|
+
}
|
|
161
|
+
|
|
151
162
|
module.exports = RouterPlugin
|
|
@@ -1,108 +1,9 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
'use strict'
|
|
3
3
|
|
|
4
|
-
const html =
|
|
5
|
-
<!DOCTYPE html>
|
|
6
|
-
<html lang="en">
|
|
4
|
+
const html = `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>You've been blocked</title><style>a,body,div,html,span{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}body{background:-webkit-radial-gradient(26% 19%,circle,#fff,#f4f7f9);background:radial-gradient(circle at 26% 19%,#fff,#f4f7f9);display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;width:100%;min-height:100vh;line-height:1;flex-direction:column}p{display:block}main{text-align:center;flex:1;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:center;align-content:center;flex-direction:column}p{font-size:18px;line-height:normal;color:#646464;font-family:sans-serif;font-weight:400}a{color:#4842b7}footer{width:100%;text-align:center}footer p{font-size:16px}</style></head><body><main><p>Sorry, you cannot access this page. Please contact the customer service team.</p></main><footer><p>Security provided by <a href="https://www.datadoghq.com/product/security-platform/application-security-monitoring/" target="_blank">Datadog</a></p></footer></body></html>`
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
<meta charset="UTF-8">
|
|
10
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
11
|
-
<title>You've been blocked</title>
|
|
12
|
-
<style>
|
|
13
|
-
a,
|
|
14
|
-
body,
|
|
15
|
-
div,
|
|
16
|
-
html,
|
|
17
|
-
span {
|
|
18
|
-
margin: 0;
|
|
19
|
-
padding: 0;
|
|
20
|
-
border: 0;
|
|
21
|
-
font-size: 100%;
|
|
22
|
-
font: inherit;
|
|
23
|
-
vertical-align: baseline
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
body {
|
|
27
|
-
background: -webkit-radial-gradient(26% 19%, circle, #fff, #f4f7f9);
|
|
28
|
-
background: radial-gradient(circle at 26% 19%, #fff, #f4f7f9);
|
|
29
|
-
display: -webkit-box;
|
|
30
|
-
display: -ms-flexbox;
|
|
31
|
-
display: flex;
|
|
32
|
-
-webkit-box-pack: center;
|
|
33
|
-
-ms-flex-pack: center;
|
|
34
|
-
justify-content: center;
|
|
35
|
-
-webkit-box-align: center;
|
|
36
|
-
-ms-flex-align: center;
|
|
37
|
-
align-items: center;
|
|
38
|
-
-ms-flex-line-pack: center;
|
|
39
|
-
align-content: center;
|
|
40
|
-
width: 100%;
|
|
41
|
-
min-height: 100vh;
|
|
42
|
-
line-height: 1;
|
|
43
|
-
flex-direction: column
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
p {
|
|
47
|
-
display: block
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
main {
|
|
52
|
-
text-align: center;
|
|
53
|
-
flex: 1;
|
|
54
|
-
display: -webkit-box;
|
|
55
|
-
display: -ms-flexbox;
|
|
56
|
-
display: flex;
|
|
57
|
-
-webkit-box-pack: center;
|
|
58
|
-
-ms-flex-pack: center;
|
|
59
|
-
justify-content: center;
|
|
60
|
-
-webkit-box-align: center;
|
|
61
|
-
-ms-flex-align: center;
|
|
62
|
-
align-items: center;
|
|
63
|
-
-ms-flex-line-pack: center;
|
|
64
|
-
align-content: center;
|
|
65
|
-
flex-direction: column
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
p {
|
|
69
|
-
font-size: 18px;
|
|
70
|
-
line-height: normal;
|
|
71
|
-
color: #646464;
|
|
72
|
-
font-family: sans-serif;
|
|
73
|
-
font-weight: 400
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
a {
|
|
77
|
-
color: #4842b7
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
footer {
|
|
81
|
-
width: 100%;
|
|
82
|
-
text-align: center
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
footer p {
|
|
86
|
-
font-size: 16px
|
|
87
|
-
}
|
|
88
|
-
</style>
|
|
89
|
-
</head>
|
|
90
|
-
|
|
91
|
-
<body>
|
|
92
|
-
<main>
|
|
93
|
-
<p>Sorry, you cannot access this page. Please contact the customer service team.</p>
|
|
94
|
-
</main>
|
|
95
|
-
<footer>
|
|
96
|
-
<p>Security provided by <a
|
|
97
|
-
href="https://www.datadoghq.com/product/security-platform/application-security-monitoring/"
|
|
98
|
-
target="_blank">Datadog</a></p>
|
|
99
|
-
</footer>
|
|
100
|
-
</body>
|
|
101
|
-
|
|
102
|
-
</html>
|
|
103
|
-
`
|
|
104
|
-
|
|
105
|
-
const json = `{"errors": [{"title": "You've been blocked", "detail": "Sorry, you cannot access this page. Please contact the customer service team. Security provided by Datadog."}]}`
|
|
6
|
+
const json = `{"errors":[{"title":"You've been blocked","detail":"Sorry, you cannot access this page. Please contact the customer service team. Security provided by Datadog."}]}`
|
|
106
7
|
|
|
107
8
|
module.exports = {
|
|
108
9
|
html,
|