dd-trace 3.21.0 → 3.22.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.
Files changed (85) hide show
  1. package/package.json +2 -2
  2. package/packages/datadog-instrumentations/src/cucumber.js +13 -0
  3. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  4. package/packages/datadog-instrumentations/src/http/client.js +2 -1
  5. package/packages/datadog-instrumentations/src/http/server.js +14 -0
  6. package/packages/datadog-instrumentations/src/http2/client.js +4 -0
  7. package/packages/datadog-instrumentations/src/playwright.js +1 -1
  8. package/packages/datadog-instrumentations/src/sequelize.js +51 -0
  9. package/packages/datadog-plugin-amqp10/src/consumer.js +1 -3
  10. package/packages/datadog-plugin-amqp10/src/producer.js +1 -3
  11. package/packages/datadog-plugin-amqplib/src/client.js +4 -3
  12. package/packages/datadog-plugin-amqplib/src/consumer.js +1 -3
  13. package/packages/datadog-plugin-amqplib/src/producer.js +1 -3
  14. package/packages/datadog-plugin-cucumber/src/index.js +2 -2
  15. package/packages/datadog-plugin-cypress/src/plugin.js +150 -30
  16. package/packages/datadog-plugin-cypress/src/support.js +6 -3
  17. package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +4 -3
  18. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -3
  19. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +1 -3
  20. package/packages/datadog-plugin-http/src/client.js +70 -68
  21. package/packages/datadog-plugin-http2/src/client.js +50 -47
  22. package/packages/datadog-plugin-jest/src/index.js +5 -4
  23. package/packages/datadog-plugin-kafkajs/src/consumer.js +1 -4
  24. package/packages/datadog-plugin-kafkajs/src/producer.js +1 -3
  25. package/packages/datadog-plugin-memcached/src/index.js +2 -3
  26. package/packages/datadog-plugin-mocha/src/index.js +4 -2
  27. package/packages/datadog-plugin-pg/src/index.js +1 -1
  28. package/packages/datadog-plugin-redis/src/index.js +2 -13
  29. package/packages/datadog-plugin-rhea/src/consumer.js +1 -3
  30. package/packages/datadog-plugin-rhea/src/producer.js +1 -5
  31. package/packages/dd-trace/src/appsec/blocked_templates.js +2 -101
  32. package/packages/dd-trace/src/appsec/blocking.js +60 -11
  33. package/packages/dd-trace/src/appsec/channels.js +3 -2
  34. package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +7 -5
  35. package/packages/dd-trace/src/appsec/iast/analyzers/index.js +3 -0
  36. package/packages/dd-trace/src/appsec/iast/analyzers/insecure-cookie-analyzer.js +31 -0
  37. package/packages/dd-trace/src/appsec/iast/analyzers/path-traversal-analyzer.js +4 -0
  38. package/packages/dd-trace/src/appsec/iast/analyzers/set-cookies-header-interceptor.js +47 -0
  39. package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +30 -5
  40. package/packages/dd-trace/src/appsec/iast/analyzers/ssrf-analyzer.js +26 -0
  41. package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +35 -3
  42. package/packages/dd-trace/src/appsec/iast/path-line.js +14 -7
  43. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +19 -4
  44. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +25 -2
  45. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +49 -0
  46. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +3 -1
  47. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +7 -5
  48. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +0 -33
  49. package/packages/dd-trace/src/appsec/recommended.json +45 -46
  50. package/packages/dd-trace/src/appsec/remote_config/capabilities.js +3 -1
  51. package/packages/dd-trace/src/appsec/remote_config/index.js +4 -0
  52. package/packages/dd-trace/src/appsec/rule_manager.js +49 -6
  53. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +2 -7
  54. package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +1 -1
  55. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +1 -6
  56. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +10 -4
  57. package/packages/dd-trace/src/config.js +29 -2
  58. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +11 -3
  59. package/packages/dd-trace/src/exporters/common/util.js +9 -0
  60. package/packages/dd-trace/src/exporters/common/writer.js +3 -2
  61. package/packages/dd-trace/src/plugin_manager.js +2 -0
  62. package/packages/dd-trace/src/plugins/cache.js +7 -0
  63. package/packages/dd-trace/src/plugins/ci_plugin.js +2 -0
  64. package/packages/dd-trace/src/plugins/client.js +3 -2
  65. package/packages/dd-trace/src/plugins/consumer.js +14 -2
  66. package/packages/dd-trace/src/plugins/database.js +2 -2
  67. package/packages/dd-trace/src/plugins/inbound.js +7 -0
  68. package/packages/dd-trace/src/plugins/{outgoing.js → outbound.js} +2 -2
  69. package/packages/dd-trace/src/plugins/producer.js +19 -2
  70. package/packages/dd-trace/src/plugins/server.js +2 -2
  71. package/packages/dd-trace/src/plugins/storage.js +2 -0
  72. package/packages/dd-trace/src/plugins/tracing.js +11 -0
  73. package/packages/dd-trace/src/plugins/util/ci.js +1 -1
  74. package/packages/dd-trace/src/profiling/config.js +4 -2
  75. package/packages/dd-trace/src/service-naming/index.js +30 -0
  76. package/packages/dd-trace/src/service-naming/schemas/definition.js +24 -0
  77. package/packages/dd-trace/src/service-naming/schemas/index.js +6 -0
  78. package/packages/dd-trace/src/service-naming/schemas/util.js +5 -0
  79. package/packages/dd-trace/src/service-naming/schemas/v0/index.js +5 -0
  80. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +64 -0
  81. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +33 -0
  82. package/packages/dd-trace/src/service-naming/schemas/v1/index.js +5 -0
  83. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +52 -0
  84. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +21 -0
  85. package/packages/dd-trace/src/plugins/incoming.js +0 -7
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const Plugin = require('../../dd-trace/src/plugins/plugin')
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 Plugin {
18
+ class HttpClientPlugin extends ClientPlugin {
19
19
  static get id () {
20
20
  return 'http'
21
21
  }
22
22
 
23
- constructor (...args) {
24
- super(...args)
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
- // TODO: Figure out a better way to do this for any span.
54
- if (!allowed) {
55
- span._spanContext._trace.record = false
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
- if (!(hasAmazonSignature(options) || !this.config.propagationFilter(uri))) {
59
- this.tracer.inject(span, HTTP_HEADERS, options.headers)
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
- analyticsSampler.sample(span, this.config.measured)
63
- this.enter(span, store)
64
- })
63
+ if (!(hasAmazonSignature(options) || !this.config.propagationFilter(uri))) {
64
+ this.tracer.inject(span, HTTP_HEADERS, options.headers)
65
+ }
65
66
 
66
- this.addSub('apm:http:client:request:finish', ({ req, res }) => {
67
- const span = storage.getStore().span
68
- if (res) {
69
- span.setTag(HTTP_STATUS_CODE, res.statusCode)
67
+ analyticsSampler.sample(span, this.config.measured)
68
+ this.enter(span, store)
69
+ }
70
70
 
71
- if (!this.config.validateStatus(res.statusCode)) {
72
- span.setTag('error', 1)
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
- addResponseHeaders(res, span, this.config)
76
+ if (!this.config.validateStatus(res.statusCode)) {
77
+ span.setTag('error', 1)
76
78
  }
77
79
 
78
- addRequestHeaders(req, span, this.config)
80
+ addResponseHeaders(res, span, this.config)
81
+ }
79
82
 
80
- this.config.hooks.request(span, req, res)
81
- span.finish()
82
- })
83
+ addRequestHeaders(req, span, this.config)
83
84
 
84
- this.addSub('apm:http:client:request:error', errorHandler)
85
+ this.config.hooks.request(span, req, res)
86
+ span.finish()
85
87
  }
86
88
 
87
- configure (config) {
88
- return super.configure(normalizeClientConfig(config))
89
- }
90
- }
89
+ error (err) {
90
+ const span = storage.getStore().span
91
91
 
92
- function errorHandler (err) {
93
- const span = storage.getStore().span
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
- if (err) {
96
- span.addTags({
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 Plugin = require('../../dd-trace/src/plugins/plugin')
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 Plugin {
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
- this.addSub('apm:http2:client:request:finish', () => {
90
- const span = storage.getStore().span
49
+ addTraceSub (eventName, handler) {
50
+ this.addSub(`apm:${this.constructor.id}:client:${this.operation}:${eventName}`, handler)
51
+ }
91
52
 
92
- span.finish()
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
- this.addSub('apm:http2:client:request:error', this.addError)
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
- traceId: id(coverage.traceId),
122
- spanId: id(coverage.spanId),
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
- traceId: this.testSuiteSpan.context()._traceId,
155
- spanId: this.testSuiteSpan.context()._spanId,
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('kafka.produce', {
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('memcached.command', {
13
- service: this.config.service,
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
- traceId: testSuiteSpan.context()._traceId,
41
- spanId: testSuiteSpan.context()._spanId,
42
+ sessionId: _traceId,
43
+ suiteId: _spanId,
42
44
  files: relativeCoverageFiles
43
45
  }
44
46
 
@@ -27,7 +27,7 @@ class PGPlugin extends DatabasePlugin {
27
27
  }
28
28
  })
29
29
 
30
- query.text = this.injectDbmQuery(query.text, service)
30
+ query.text = this.injectDbmQuery(query.text, service, !!query.name)
31
31
  }
32
32
  }
33
33
 
@@ -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('redis.command', {
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('amqp.receive', {
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,
@@ -1,108 +1,9 @@
1
1
  /* eslint-disable max-len */
2
2
  'use strict'
3
3
 
4
- const html = `<!-- Sorry, you’ve been blocked -->
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
- <head>
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,