dd-trace 2.27.1 → 2.29.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 (187) hide show
  1. package/LICENSE-3rdparty.csv +2 -2
  2. package/README.md +9 -5
  3. package/ci/init.js +9 -1
  4. package/ext/exporters.d.ts +2 -1
  5. package/ext/exporters.js +2 -1
  6. package/index.d.ts +36 -3
  7. package/package.json +21 -19
  8. package/packages/datadog-instrumentations/src/cucumber.js +80 -3
  9. package/packages/datadog-instrumentations/src/google-cloud-pubsub.js +100 -27
  10. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  11. package/packages/datadog-instrumentations/src/jest.js +35 -3
  12. package/packages/datadog-instrumentations/src/ldapjs.js +12 -2
  13. package/packages/datadog-instrumentations/src/mariadb.js +130 -11
  14. package/packages/datadog-instrumentations/src/mocha.js +30 -6
  15. package/packages/datadog-instrumentations/src/mongodb-core.js +8 -2
  16. package/packages/datadog-instrumentations/src/mongoose.js +1 -1
  17. package/packages/datadog-instrumentations/src/next.js +33 -4
  18. package/packages/datadog-instrumentations/src/playwright.js +42 -13
  19. package/packages/datadog-plugin-amqp10/src/consumer.js +1 -1
  20. package/packages/datadog-plugin-amqp10/src/index.js +1 -1
  21. package/packages/datadog-plugin-amqp10/src/producer.js +3 -2
  22. package/packages/datadog-plugin-amqplib/src/client.js +3 -2
  23. package/packages/datadog-plugin-amqplib/src/consumer.js +1 -1
  24. package/packages/datadog-plugin-amqplib/src/index.js +1 -1
  25. package/packages/datadog-plugin-amqplib/src/producer.js +3 -2
  26. package/packages/datadog-plugin-aws-sdk/src/base.js +7 -2
  27. package/packages/datadog-plugin-aws-sdk/src/index.js +1 -1
  28. package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +2 -0
  29. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +2 -0
  30. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -0
  31. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +2 -0
  32. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +2 -0
  33. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +2 -0
  34. package/packages/datadog-plugin-aws-sdk/src/services/s3.js +2 -0
  35. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +2 -0
  36. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +2 -0
  37. package/packages/datadog-plugin-bunyan/src/index.js +1 -1
  38. package/packages/datadog-plugin-cassandra-driver/src/index.js +3 -2
  39. package/packages/datadog-plugin-connect/src/index.js +1 -1
  40. package/packages/datadog-plugin-couchbase/src/index.js +1 -1
  41. package/packages/datadog-plugin-cucumber/src/index.js +33 -6
  42. package/packages/datadog-plugin-cypress/src/index.js +1 -1
  43. package/packages/datadog-plugin-cypress/src/plugin.js +40 -33
  44. package/packages/datadog-plugin-dns/src/index.js +1 -1
  45. package/packages/datadog-plugin-dns/src/lookup.js +1 -1
  46. package/packages/datadog-plugin-dns/src/lookup_service.js +1 -1
  47. package/packages/datadog-plugin-dns/src/resolve.js +1 -1
  48. package/packages/datadog-plugin-dns/src/reverse.js +1 -1
  49. package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
  50. package/packages/datadog-plugin-express/src/index.js +1 -1
  51. package/packages/datadog-plugin-fastify/src/index.js +1 -1
  52. package/packages/datadog-plugin-find-my-way/src/index.js +1 -1
  53. package/packages/datadog-plugin-fs/src/index.js +1 -1
  54. package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +5 -5
  55. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +1 -1
  56. package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -1
  57. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +7 -6
  58. package/packages/datadog-plugin-graphql/src/execute.js +1 -1
  59. package/packages/datadog-plugin-graphql/src/index.js +1 -1
  60. package/packages/datadog-plugin-graphql/src/parse.js +1 -1
  61. package/packages/datadog-plugin-graphql/src/resolve.js +1 -1
  62. package/packages/datadog-plugin-graphql/src/validate.js +1 -1
  63. package/packages/datadog-plugin-grpc/src/client.js +1 -1
  64. package/packages/datadog-plugin-grpc/src/index.js +1 -1
  65. package/packages/datadog-plugin-grpc/src/server.js +1 -1
  66. package/packages/datadog-plugin-hapi/src/index.js +1 -1
  67. package/packages/datadog-plugin-http/src/client.js +2 -2
  68. package/packages/datadog-plugin-http/src/index.js +1 -1
  69. package/packages/datadog-plugin-http/src/server.js +3 -3
  70. package/packages/datadog-plugin-http2/src/client.js +4 -3
  71. package/packages/datadog-plugin-http2/src/index.js +1 -1
  72. package/packages/datadog-plugin-http2/src/server.js +3 -3
  73. package/packages/datadog-plugin-ioredis/src/index.js +1 -1
  74. package/packages/datadog-plugin-jest/src/index.js +53 -19
  75. package/packages/datadog-plugin-kafkajs/src/consumer.js +1 -1
  76. package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
  77. package/packages/datadog-plugin-kafkajs/src/producer.js +1 -1
  78. package/packages/datadog-plugin-koa/src/index.js +1 -1
  79. package/packages/datadog-plugin-mariadb/src/index.js +18 -1
  80. package/packages/datadog-plugin-memcached/src/index.js +3 -2
  81. package/packages/datadog-plugin-microgateway-core/src/index.js +1 -1
  82. package/packages/datadog-plugin-mocha/src/index.js +13 -9
  83. package/packages/datadog-plugin-moleculer/src/client.js +1 -1
  84. package/packages/datadog-plugin-moleculer/src/index.js +1 -1
  85. package/packages/datadog-plugin-moleculer/src/server.js +1 -1
  86. package/packages/datadog-plugin-mongodb-core/src/index.js +1 -1
  87. package/packages/datadog-plugin-mysql/src/index.js +3 -2
  88. package/packages/datadog-plugin-mysql2/src/index.js +1 -1
  89. package/packages/datadog-plugin-net/src/index.js +9 -75
  90. package/packages/datadog-plugin-net/src/ipc.js +1 -1
  91. package/packages/datadog-plugin-net/src/tcp.js +3 -2
  92. package/packages/datadog-plugin-next/src/index.js +3 -3
  93. package/packages/datadog-plugin-opensearch/src/index.js +1 -1
  94. package/packages/datadog-plugin-oracledb/src/index.js +3 -2
  95. package/packages/datadog-plugin-paperplane/src/index.js +1 -1
  96. package/packages/datadog-plugin-paperplane/src/logger.js +1 -1
  97. package/packages/datadog-plugin-paperplane/src/server.js +1 -1
  98. package/packages/datadog-plugin-pg/src/index.js +3 -2
  99. package/packages/datadog-plugin-pino/src/index.js +1 -1
  100. package/packages/datadog-plugin-playwright/src/index.js +5 -4
  101. package/packages/datadog-plugin-redis/src/index.js +3 -2
  102. package/packages/datadog-plugin-restify/src/index.js +1 -1
  103. package/packages/datadog-plugin-rhea/src/consumer.js +1 -1
  104. package/packages/datadog-plugin-rhea/src/index.js +1 -1
  105. package/packages/datadog-plugin-rhea/src/producer.js +3 -2
  106. package/packages/datadog-plugin-router/src/index.js +8 -8
  107. package/packages/datadog-plugin-sharedb/src/index.js +1 -1
  108. package/packages/datadog-plugin-tedious/src/index.js +3 -2
  109. package/packages/datadog-plugin-web/src/index.js +1 -1
  110. package/packages/datadog-plugin-winston/src/index.js +1 -1
  111. package/packages/dd-trace/src/appsec/addresses.js +3 -1
  112. package/packages/dd-trace/src/appsec/blocking.js +35 -9
  113. package/packages/dd-trace/src/appsec/gateway/engine/runner.js +2 -1
  114. package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +2 -0
  115. package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +2 -2
  116. package/packages/dd-trace/src/appsec/iast/iast-context.js +6 -2
  117. package/packages/dd-trace/src/appsec/iast/iast-log.js +111 -0
  118. package/packages/dd-trace/src/appsec/iast/index.js +10 -6
  119. package/packages/dd-trace/src/appsec/iast/path-line.js +3 -6
  120. package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +2 -0
  121. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +2 -0
  122. package/packages/dd-trace/src/appsec/iast/taint-tracking/origin-types.js +2 -0
  123. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +2 -0
  124. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +9 -4
  125. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +5 -3
  126. package/packages/dd-trace/src/appsec/iast/telemetry/log_collector.js +96 -0
  127. package/packages/dd-trace/src/appsec/iast/telemetry/logs.js +87 -0
  128. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +27 -2
  129. package/packages/dd-trace/src/appsec/index.js +4 -4
  130. package/packages/dd-trace/src/appsec/recommended.json +76 -75
  131. package/packages/dd-trace/src/appsec/remote_config/capabilities.js +2 -1
  132. package/packages/dd-trace/src/appsec/remote_config/index.js +3 -0
  133. package/packages/dd-trace/src/appsec/sdk/index.js +19 -1
  134. package/packages/dd-trace/src/appsec/sdk/noop.js +6 -0
  135. package/packages/dd-trace/src/appsec/sdk/set_user.js +30 -0
  136. package/packages/dd-trace/src/appsec/sdk/track_event.js +2 -2
  137. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +73 -0
  138. package/packages/dd-trace/src/ci-visibility/encode/json-encoder.js +27 -0
  139. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +17 -9
  140. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +14 -8
  141. package/packages/dd-trace/src/ci-visibility/exporters/jest-worker/index.js +33 -0
  142. package/packages/dd-trace/src/ci-visibility/exporters/jest-worker/writer.js +37 -0
  143. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-itr-configuration.js +12 -4
  144. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +12 -4
  145. package/packages/dd-trace/src/config.js +24 -5
  146. package/packages/dd-trace/src/constants.js +2 -1
  147. package/packages/dd-trace/src/datastreams/encoding.js +80 -0
  148. package/packages/dd-trace/src/exporter.js +7 -9
  149. package/packages/dd-trace/src/exporters/common/agents.js +42 -0
  150. package/packages/dd-trace/src/exporters/common/docker.js +4 -1
  151. package/packages/dd-trace/src/exporters/common/request.js +1 -4
  152. package/packages/dd-trace/src/lambda/handler.js +19 -12
  153. package/packages/dd-trace/src/log/writer.js +32 -24
  154. package/packages/dd-trace/src/metrics.js +18 -0
  155. package/packages/dd-trace/src/noop/proxy.js +2 -2
  156. package/packages/dd-trace/src/opentracing/span.js +5 -0
  157. package/packages/dd-trace/src/opentracing/span_context.js +1 -1
  158. package/packages/dd-trace/src/plugin_manager.js +7 -7
  159. package/packages/dd-trace/src/plugins/ci_plugin.js +20 -17
  160. package/packages/dd-trace/src/plugins/index.js +1 -0
  161. package/packages/dd-trace/src/plugins/log_plugin.js +1 -1
  162. package/packages/dd-trace/src/plugins/outgoing.js +2 -1
  163. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  164. package/packages/dd-trace/src/plugins/util/ci.js +12 -0
  165. package/packages/dd-trace/src/plugins/util/exec.js +2 -2
  166. package/packages/dd-trace/src/plugins/util/git.js +16 -1
  167. package/packages/dd-trace/src/plugins/util/ip_extractor.js +23 -27
  168. package/packages/dd-trace/src/plugins/util/test.js +26 -7
  169. package/packages/dd-trace/src/profiler.js +3 -0
  170. package/packages/dd-trace/src/profiling/config.js +92 -20
  171. package/packages/dd-trace/src/profiling/constants.js +16 -0
  172. package/packages/dd-trace/src/profiling/exporter_cli.js +62 -0
  173. package/packages/dd-trace/src/profiling/exporters/agent.js +2 -1
  174. package/packages/dd-trace/src/profiling/exporters/file.js +13 -2
  175. package/packages/dd-trace/src/profiling/profiler.js +42 -12
  176. package/packages/dd-trace/src/profiling/profilers/space.js +21 -1
  177. package/packages/dd-trace/src/profiling/profilers/wall.js +1 -0
  178. package/packages/dd-trace/src/proxy.js +1 -1
  179. package/packages/dd-trace/src/span_processor.js +1 -1
  180. package/packages/dd-trace/src/span_sampler.js +71 -54
  181. package/packages/dd-trace/src/startup-log.js +3 -6
  182. package/packages/dd-trace/src/telemetry/index.js +16 -2
  183. package/packages/dd-trace/src/tracer.js +0 -16
  184. package/packages/dd-trace/src/util.js +10 -1
  185. package/scripts/install_plugin_modules.js +5 -1
  186. package/scripts/junit_report.js +0 -25
  187. package/scripts/tdd.js +0 -34
@@ -3,6 +3,8 @@
3
3
  const BaseAwsSdkPlugin = require('../base')
4
4
 
5
5
  class S3 extends BaseAwsSdkPlugin {
6
+ static get id () { return 's3' }
7
+
6
8
  generateTags (params, operation, response) {
7
9
  const tags = {}
8
10
 
@@ -3,6 +3,8 @@ const log = require('../../../dd-trace/src/log')
3
3
  const BaseAwsSdkPlugin = require('../base')
4
4
 
5
5
  class Sns extends BaseAwsSdkPlugin {
6
+ static get id () { return 'sns' }
7
+
6
8
  generateTags (params, operation, response) {
7
9
  if (!params) return {}
8
10
 
@@ -5,6 +5,8 @@ const BaseAwsSdkPlugin = require('../base')
5
5
  const { storage } = require('../../../datadog-core')
6
6
 
7
7
  class Sqs extends BaseAwsSdkPlugin {
8
+ static get id () { return 'sqs' }
9
+
8
10
  constructor (...args) {
9
11
  super(...args)
10
12
  //
@@ -3,7 +3,7 @@
3
3
  const LogPlugin = require('../../dd-trace/src/plugins/log_plugin')
4
4
 
5
5
  class BunyanPlugin extends LogPlugin {
6
- static get name () {
6
+ static get id () {
7
7
  return 'bunyan'
8
8
  }
9
9
  }
@@ -1,9 +1,10 @@
1
1
  'use strict'
2
2
 
3
+ const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
3
4
  const DatabasePlugin = require('../../dd-trace/src/plugins/database')
4
5
 
5
6
  class CassandraDriverPlugin extends DatabasePlugin {
6
- static get name () { return 'cassandra-driver' }
7
+ static get id () { return 'cassandra-driver' }
7
8
  static get system () { return 'cassandra' }
8
9
 
9
10
  start ({ keyspace, query, connectionOptions = {} }) {
@@ -21,7 +22,7 @@ class CassandraDriverPlugin extends DatabasePlugin {
21
22
  'cassandra.query': query,
22
23
  'cassandra.keyspace': keyspace,
23
24
  'out.host': connectionOptions.host,
24
- 'out.port': connectionOptions.port
25
+ [CLIENT_PORT_KEY]: connectionOptions.port
25
26
  }
26
27
  })
27
28
  }
@@ -3,7 +3,7 @@
3
3
  const RouterPlugin = require('../../datadog-plugin-router/src')
4
4
 
5
5
  class ConnectPlugin extends RouterPlugin {
6
- static get name () {
6
+ static get id () {
7
7
  return 'connect'
8
8
  }
9
9
 
@@ -5,7 +5,7 @@ const { storage } = require('../../datadog-core')
5
5
  const analyticsSampler = require('../../dd-trace/src/analytics_sampler')
6
6
 
7
7
  class CouchBasePlugin extends Plugin {
8
- static get name () {
8
+ static get id () {
9
9
  return 'couchbase'
10
10
  }
11
11
 
@@ -8,13 +8,14 @@ const {
8
8
  TEST_STATUS,
9
9
  finishAllTraceSpans,
10
10
  getTestSuitePath,
11
- getTestSuiteCommonTags
11
+ getTestSuiteCommonTags,
12
+ addIntelligentTestRunnerSpanTags
12
13
  } = require('../../dd-trace/src/plugins/util/test')
13
14
  const { RESOURCE_NAME } = require('../../../ext/tags')
14
15
  const { COMPONENT, ERROR_MESSAGE } = require('../../dd-trace/src/constants')
15
16
 
16
17
  class CucumberPlugin extends CiPlugin {
17
- static get name () {
18
+ static get id () {
18
19
  return 'cucumber'
19
20
  }
20
21
 
@@ -23,12 +24,21 @@ class CucumberPlugin extends CiPlugin {
23
24
 
24
25
  this.sourceRoot = process.cwd()
25
26
 
26
- this.addSub('ci:cucumber:session:finish', (status) => {
27
+ this.addSub('ci:cucumber:session:finish', ({ status, isSuitesSkipped, testCodeCoverageLinesTotal }) => {
28
+ const { isSuitesSkippingEnabled, isCodeCoverageEnabled } = this.itrConfig || {}
29
+ addIntelligentTestRunnerSpanTags(
30
+ this.testSessionSpan,
31
+ this.testModuleSpan,
32
+ { isSuitesSkipped, isSuitesSkippingEnabled, isCodeCoverageEnabled, testCodeCoverageLinesTotal }
33
+ )
34
+
27
35
  this.testSessionSpan.setTag(TEST_STATUS, status)
28
36
  this.testModuleSpan.setTag(TEST_STATUS, status)
29
37
  this.testModuleSpan.finish()
30
38
  this.testSessionSpan.finish()
31
39
  finishAllTraceSpans(this.testSessionSpan)
40
+
41
+ this.itrConfig = null
32
42
  this.tracer._exporter.flush()
33
43
  })
34
44
 
@@ -36,12 +46,13 @@ class CucumberPlugin extends CiPlugin {
36
46
  const testSuiteMetadata = getTestSuiteCommonTags(
37
47
  this.command,
38
48
  this.frameworkVersion,
39
- getTestSuitePath(testSuiteFullPath, this.sourceRoot)
49
+ getTestSuitePath(testSuiteFullPath, this.sourceRoot),
50
+ 'cucumber'
40
51
  )
41
52
  this.testSuiteSpan = this.tracer.startSpan('cucumber.test_suite', {
42
53
  childOf: this.testModuleSpan,
43
54
  tags: {
44
- [COMPONENT]: this.constructor.name,
55
+ [COMPONENT]: this.constructor.id,
45
56
  ...this.testEnvironmentMetadata,
46
57
  ...testSuiteMetadata
47
58
  }
@@ -53,6 +64,22 @@ class CucumberPlugin extends CiPlugin {
53
64
  this.testSuiteSpan.finish()
54
65
  })
55
66
 
67
+ this.addSub('ci:cucumber:test-suite:code-coverage', ({ coverageFiles, suiteFile }) => {
68
+ if (!this.itrConfig || !this.itrConfig.isCodeCoverageEnabled) {
69
+ return
70
+ }
71
+ const relativeCoverageFiles = [...coverageFiles, suiteFile]
72
+ .map(filename => getTestSuitePath(filename, this.sourceRoot))
73
+
74
+ const formattedCoverage = {
75
+ traceId: this.testSuiteSpan.context()._traceId,
76
+ spanId: this.testSuiteSpan.context()._spanId,
77
+ files: relativeCoverageFiles
78
+ }
79
+
80
+ this.tracer._exporter.exportCoverage(formattedCoverage)
81
+ })
82
+
56
83
  this.addSub('ci:cucumber:test:start', ({ testName, fullTestSuite }) => {
57
84
  const store = storage.getStore()
58
85
  const testSuite = getTestSuitePath(fullTestSuite, this.sourceRoot)
@@ -67,7 +94,7 @@ class CucumberPlugin extends CiPlugin {
67
94
  const span = this.tracer.startSpan('cucumber.step', {
68
95
  childOf,
69
96
  tags: {
70
- [COMPONENT]: this.constructor.name,
97
+ [COMPONENT]: this.constructor.id,
71
98
  'cucumber.step': resource,
72
99
  [RESOURCE_NAME]: resource
73
100
  }
@@ -3,7 +3,7 @@ const Plugin = require('../../dd-trace/src/plugins/plugin')
3
3
  // Cypress plugin does not patch any library. This is just a placeholder to
4
4
  // follow the structure of the plugins
5
5
  class CypressPlugin extends Plugin {
6
- static get name () {
6
+ static get id () {
7
7
  return 'cypress'
8
8
  }
9
9
  }
@@ -15,10 +15,12 @@ const {
15
15
  TEST_MODULE_ID,
16
16
  TEST_SESSION_ID,
17
17
  TEST_COMMAND,
18
- TEST_BUNDLE,
18
+ TEST_MODULE,
19
19
  finishAllTraceSpans
20
20
  } = require('../../dd-trace/src/plugins/util/test')
21
21
 
22
+ const TEST_FRAMEWORK_NAME = 'cypress'
23
+
22
24
  const { ORIGIN_KEY, COMPONENT } = require('../../dd-trace/src/constants')
23
25
 
24
26
  const CYPRESS_STATUS_TO_TEST_STATUS = {
@@ -51,9 +53,9 @@ function getCypressVersion (details) {
51
53
 
52
54
  function getCypressCommand (details) {
53
55
  if (!details) {
54
- return 'cypress'
56
+ return TEST_FRAMEWORK_NAME
55
57
  }
56
- return `cypress ${details.specPattern || ''}`
58
+ return `${TEST_FRAMEWORK_NAME} ${details.specPattern || ''}`
57
59
  }
58
60
 
59
61
  function getSessionStatus (summary) {
@@ -78,7 +80,7 @@ function getSuiteStatus (suiteStats) {
78
80
 
79
81
  module.exports = (on, config) => {
80
82
  const tracer = require('../../dd-trace')
81
- const testEnvironmentMetadata = getTestEnvironmentMetadata('cypress')
83
+ const testEnvironmentMetadata = getTestEnvironmentMetadata(TEST_FRAMEWORK_NAME)
82
84
 
83
85
  const codeOwnersEntries = getCodeOwnersFileEntries()
84
86
 
@@ -95,21 +97,21 @@ module.exports = (on, config) => {
95
97
  command = getCypressCommand(details)
96
98
  frameworkVersion = getCypressVersion(details)
97
99
 
98
- const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion)
99
- const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion)
100
+ const testSessionSpanMetadata = getTestSessionCommonTags(command, frameworkVersion, TEST_FRAMEWORK_NAME)
101
+ const testModuleSpanMetadata = getTestModuleCommonTags(command, frameworkVersion, TEST_FRAMEWORK_NAME)
100
102
 
101
- testSessionSpan = tracer.startSpan('cypress.test_session', {
103
+ testSessionSpan = tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test_session`, {
102
104
  childOf,
103
105
  tags: {
104
- [COMPONENT]: 'cypress',
106
+ [COMPONENT]: TEST_FRAMEWORK_NAME,
105
107
  ...testEnvironmentMetadata,
106
108
  ...testSessionSpanMetadata
107
109
  }
108
110
  })
109
- testModuleSpan = tracer.startSpan('cypress.test_module', {
111
+ testModuleSpan = tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test_module`, {
110
112
  childOf: testSessionSpan,
111
113
  tags: {
112
- [COMPONENT]: 'cypress',
114
+ [COMPONENT]: TEST_FRAMEWORK_NAME,
113
115
  ...testEnvironmentMetadata,
114
116
  ...testModuleSpanMetadata
115
117
  }
@@ -117,14 +119,16 @@ module.exports = (on, config) => {
117
119
  })
118
120
 
119
121
  on('after:run', (suiteStats) => {
120
- const testStatus = getSessionStatus(suiteStats)
121
- testModuleSpan.setTag(TEST_STATUS, testStatus)
122
- testSessionSpan.setTag(TEST_STATUS, testStatus)
122
+ if (testSessionSpan && testModuleSpan) {
123
+ const testStatus = getSessionStatus(suiteStats)
124
+ testModuleSpan.setTag(TEST_STATUS, testStatus)
125
+ testSessionSpan.setTag(TEST_STATUS, testStatus)
123
126
 
124
- testModuleSpan.finish()
125
- testSessionSpan.finish()
127
+ testModuleSpan.finish()
128
+ testSessionSpan.finish()
126
129
 
127
- finishAllTraceSpans(testSessionSpan)
130
+ finishAllTraceSpans(testSessionSpan)
131
+ }
128
132
 
129
133
  return new Promise(resolve => {
130
134
  tracer._tracer._exporter._writer.flush(() => {
@@ -137,11 +141,11 @@ module.exports = (on, config) => {
137
141
  if (testSuiteSpan) {
138
142
  return null
139
143
  }
140
- const testSuiteSpanMetadata = getTestSuiteCommonTags(command, frameworkVersion, suite)
141
- testSuiteSpan = tracer.startSpan('cypress.test_suite', {
144
+ const testSuiteSpanMetadata = getTestSuiteCommonTags(command, frameworkVersion, suite, TEST_FRAMEWORK_NAME)
145
+ testSuiteSpan = tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test_suite`, {
142
146
  childOf: testModuleSpan,
143
147
  tags: {
144
- [COMPONENT]: 'cypress',
148
+ [COMPONENT]: TEST_FRAMEWORK_NAME,
145
149
  ...testEnvironmentMetadata,
146
150
  ...testSuiteSpanMetadata
147
151
  }
@@ -149,25 +153,28 @@ module.exports = (on, config) => {
149
153
  return null
150
154
  },
151
155
  'dd:testSuiteFinish': (suiteStats) => {
152
- const status = getSuiteStatus(suiteStats)
153
- testSuiteSpan.setTag(TEST_STATUS, status)
154
- testSuiteSpan.finish()
155
- testSuiteSpan = null
156
+ if (testSuiteSpan) {
157
+ const status = getSuiteStatus(suiteStats)
158
+ testSuiteSpan.setTag(TEST_STATUS, status)
159
+ testSuiteSpan.finish()
160
+ testSuiteSpan = null
161
+ }
156
162
  return null
157
163
  },
158
164
  'dd:beforeEach': (test) => {
159
165
  const { testName, testSuite } = test
160
- const testSuiteId = testSuiteSpan.context().toSpanId()
161
- const testSessionId = testSessionSpan.context().toTraceId()
162
- const testModuleId = testModuleSpan.context().toSpanId()
163
166
 
164
167
  const testSuiteTags = {
165
- [TEST_SUITE_ID]: testSuiteId,
166
- [TEST_SESSION_ID]: testSessionId,
167
168
  [TEST_COMMAND]: command,
168
- [TEST_MODULE_ID]: testModuleId,
169
169
  [TEST_COMMAND]: command,
170
- [TEST_BUNDLE]: command
170
+ [TEST_MODULE]: TEST_FRAMEWORK_NAME
171
+ }
172
+ if (testSuiteSpan) {
173
+ testSuiteTags[TEST_SUITE_ID] = testSuiteSpan.context().toSpanId()
174
+ }
175
+ if (testSessionSpan && testModuleSpan) {
176
+ testSuiteTags[TEST_SESSION_ID] = testSessionSpan.context().toTraceId()
177
+ testSuiteTags[TEST_MODULE_ID] = testModuleSpan.context().toSpanId()
171
178
  }
172
179
 
173
180
  const {
@@ -183,10 +190,10 @@ module.exports = (on, config) => {
183
190
  }
184
191
 
185
192
  if (!activeSpan) {
186
- activeSpan = tracer.startSpan('cypress.test', {
193
+ activeSpan = tracer.startSpan(`${TEST_FRAMEWORK_NAME}.test`, {
187
194
  childOf,
188
195
  tags: {
189
- [COMPONENT]: 'cypress',
196
+ [COMPONENT]: TEST_FRAMEWORK_NAME,
190
197
  [ORIGIN_KEY]: CI_APP_ORIGIN,
191
198
  ...testSpanMetadata,
192
199
  ...testEnvironmentMetadata,
@@ -194,7 +201,7 @@ module.exports = (on, config) => {
194
201
  }
195
202
  })
196
203
  }
197
- return activeSpan ? activeSpan._spanContext._traceId.toString(10) : null
204
+ return activeSpan ? activeSpan.context().toTraceId() : null
198
205
  },
199
206
  'dd:afterEach': (test) => {
200
207
  const { state, error, isRUMActive } = test
@@ -9,7 +9,7 @@ const DNSReversePlugin = require('./reverse')
9
9
  // TODO: Are DNS spans really client spans?
10
10
 
11
11
  class DNSPlugin extends CompositePlugin {
12
- static get name () { return 'dns' }
12
+ static get id () { return 'dns' }
13
13
  static get plugins () {
14
14
  return {
15
15
  lookup: DNSLookupPlugin,
@@ -3,7 +3,7 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class DNSLookupPlugin extends ClientPlugin {
6
- static get name () { return 'dns' }
6
+ static get id () { return 'dns' }
7
7
  static get operation () { return 'lookup' }
8
8
 
9
9
  start ([hostname]) {
@@ -3,7 +3,7 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class DNSLookupServicePlugin extends ClientPlugin {
6
- static get name () { return 'dns' }
6
+ static get id () { return 'dns' }
7
7
  static get operation () { return 'lookup_service' }
8
8
 
9
9
  start ([address, port]) {
@@ -3,7 +3,7 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class DNSResolvePlugin extends ClientPlugin {
6
- static get name () { return 'dns' }
6
+ static get id () { return 'dns' }
7
7
  static get operation () { return 'resolve' }
8
8
 
9
9
  start ([hostname, maybeType]) {
@@ -3,7 +3,7 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class DNSReversePlugin extends ClientPlugin {
6
- static get name () { return 'dns' }
6
+ static get id () { return 'dns' }
7
7
  static get operation () { return 'reverse' }
8
8
 
9
9
  start ([ip]) {
@@ -3,7 +3,7 @@
3
3
  const DatabasePlugin = require('../../dd-trace/src/plugins/database')
4
4
 
5
5
  class ElasticsearchPlugin extends DatabasePlugin {
6
- static get name () { return 'elasticsearch' }
6
+ static get id () { return 'elasticsearch' }
7
7
 
8
8
  start ({ params }) {
9
9
  const body = getBody(params.body || params.bulkBody)
@@ -3,7 +3,7 @@
3
3
  const RouterPlugin = require('../../datadog-plugin-router/src')
4
4
 
5
5
  class ExpressPlugin extends RouterPlugin {
6
- static get name () {
6
+ static get id () {
7
7
  return 'express'
8
8
  }
9
9
 
@@ -3,7 +3,7 @@
3
3
  const RouterPlugin = require('../../datadog-plugin-router/src')
4
4
 
5
5
  class FastifyPlugin extends RouterPlugin {
6
- static get name () {
6
+ static get id () {
7
7
  return 'fastify'
8
8
  }
9
9
 
@@ -4,7 +4,7 @@ const Plugin = require('../../dd-trace/src/plugins/plugin')
4
4
  const web = require('../../dd-trace/src/plugins/util/web')
5
5
 
6
6
  class FindMyWayPlugin extends Plugin {
7
- static get name () {
7
+ static get id () {
8
8
  return 'find-my-way'
9
9
  }
10
10
 
@@ -3,7 +3,7 @@
3
3
  const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
4
 
5
5
  class FsPlugin extends TracingPlugin {
6
- static get name () { return 'fs' }
6
+ static get id () { return 'fs' }
7
7
  static get operation () { return 'operation' }
8
8
 
9
9
  configure (...args) {
@@ -3,18 +3,18 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class GoogleCloudPubsubClientPlugin extends ClientPlugin {
6
- static get name () { return 'google-cloud-pubsub' }
6
+ static get id () { return 'google-cloud-pubsub' }
7
7
  static get operation () { return 'request' }
8
8
 
9
- start ({ cfg, projectId }) {
10
- if (cfg.method === 'publish') return
9
+ start ({ request, api, projectId }) {
10
+ if (api === 'publish') return
11
11
 
12
12
  this.startSpan('pubsub.request', {
13
13
  service: this.config.service || `${this.tracer._service}-pubsub`,
14
- resource: [cfg.method, cfg.reqOpts.name].filter(x => x).join(' '),
14
+ resource: [api, request.name].filter(x => x).join(' '),
15
15
  kind: 'client',
16
16
  meta: {
17
- 'pubsub.method': cfg.method,
17
+ 'pubsub.method': api,
18
18
  'gcloud.project_id': projectId
19
19
  }
20
20
  })
@@ -3,7 +3,7 @@
3
3
  const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
4
4
 
5
5
  class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
6
- static get name () { return 'google-cloud-pubsub' }
6
+ static get id () { return 'google-cloud-pubsub' }
7
7
  static get operation () { return 'receive' }
8
8
 
9
9
  start ({ message }) {
@@ -7,7 +7,7 @@ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
7
7
 
8
8
  // TODO: Consider splitting channels for publish/receive in the instrumentation.
9
9
  class GoogleCloudPubsubPlugin extends CompositePlugin {
10
- static get name () { return 'google-cloud-pubsub' }
10
+ static get id () { return 'google-cloud-pubsub' }
11
11
  static get plugins () {
12
12
  return {
13
13
  producer: ProducerPlugin,
@@ -3,20 +3,21 @@
3
3
  const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
4
4
 
5
5
  class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
6
- static get name () { return 'google-cloud-pubsub' }
6
+ static get id () { return 'google-cloud-pubsub' }
7
7
  static get operation () { return 'request' }
8
8
 
9
- start ({ cfg, projectId, messages }) {
10
- if (cfg.method !== 'publish') return
9
+ start ({ request, api, projectId }) {
10
+ if (api !== 'publish') return
11
11
 
12
- const topic = cfg.reqOpts.topic
12
+ const messages = request.messages || []
13
+ const topic = request.topic
13
14
  const span = this.startSpan('pubsub.request', { // TODO: rename
14
15
  service: this.config.service || `${this.tracer._service}-pubsub`,
15
- resource: `${cfg.method} ${topic}`,
16
+ resource: `${api} ${topic}`,
16
17
  kind: 'producer',
17
18
  meta: {
18
19
  'gcloud.project_id': projectId,
19
- 'pubsub.method': cfg.method, // TODO: remove
20
+ 'pubsub.method': api, // TODO: remove
20
21
  'pubsub.topic': topic
21
22
  }
22
23
  })
@@ -5,7 +5,7 @@ const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
5
5
  let tools
6
6
 
7
7
  class GraphQLExecutePlugin extends TracingPlugin {
8
- static get name () { return 'graphql' }
8
+ static get id () { return 'graphql' }
9
9
  static get operation () { return 'execute' }
10
10
 
11
11
  start ({ operation, args, docSource }) {
@@ -8,7 +8,7 @@ const GraphQLValidatePlugin = require('./validate')
8
8
  const GraphQLResolvePlugin = require('./resolve')
9
9
 
10
10
  class GraphQLPlugin extends CompositePlugin {
11
- static get name () { return 'graphql' }
11
+ static get id () { return 'graphql' }
12
12
  static get plugins () {
13
13
  return {
14
14
  execute: GraphQLExecutePlugin,
@@ -3,7 +3,7 @@
3
3
  const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
4
 
5
5
  class GraphQLParsePlugin extends TracingPlugin {
6
- static get name () { return 'graphql' }
6
+ static get id () { return 'graphql' }
7
7
  static get operation () { return 'parser' }
8
8
 
9
9
  start () {
@@ -5,7 +5,7 @@ const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
5
5
  const collapsedPathSym = Symbol('collapsedPaths')
6
6
 
7
7
  class GraphQLResolvePlugin extends TracingPlugin {
8
- static get name () { return 'graphql' }
8
+ static get id () { return 'graphql' }
9
9
  static get operation () { return 'resolve' }
10
10
 
11
11
  start ({ info, context }) {
@@ -3,7 +3,7 @@
3
3
  const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
4
 
5
5
  class GraphQLValidatePlugin extends TracingPlugin {
6
- static get name () { return 'graphql' }
6
+ static get id () { return 'graphql' }
7
7
  static get operation () { return 'validate' }
8
8
 
9
9
  start ({ docSource, document }) {
@@ -5,7 +5,7 @@ const { TEXT_MAP } = require('../../../ext/formats')
5
5
  const { addMetadataTags, getFilter, getMethodMetadata } = require('./util')
6
6
 
7
7
  class GrpcClientPlugin extends ClientPlugin {
8
- static get name () { return 'grpc' }
8
+ static get id () { return 'grpc' }
9
9
  static get operation () { return 'client:request' }
10
10
 
11
11
  start ({ metadata, path, type }) {
@@ -5,7 +5,7 @@ const GrpcClientPlugin = require('./client')
5
5
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
6
6
 
7
7
  class GrpcPlugin extends CompositePlugin {
8
- static get name () { return 'grpc' }
8
+ static get id () { return 'grpc' }
9
9
  static get plugins () {
10
10
  return {
11
11
  server: GrpcServerPlugin,
@@ -5,7 +5,7 @@ const { TEXT_MAP } = require('../../../ext/formats')
5
5
  const { addMetadataTags, getFilter, getMethodMetadata } = require('./util')
6
6
 
7
7
  class GrpcServerPlugin extends ServerPlugin {
8
- static get name () { return 'grpc' }
8
+ static get id () { return 'grpc' }
9
9
  static get operation () { return 'server:request' }
10
10
 
11
11
  constructor (...args) {
@@ -5,7 +5,7 @@ const RouterPlugin = require('../../datadog-plugin-router/src')
5
5
  const web = require('../../dd-trace/src/plugins/util/web')
6
6
 
7
7
  class HapiPlugin extends RouterPlugin {
8
- static get name () {
8
+ static get id () {
9
9
  return 'hapi'
10
10
  }
11
11
 
@@ -16,7 +16,7 @@ const HTTP_REQUEST_HEADERS = tags.HTTP_REQUEST_HEADERS
16
16
  const HTTP_RESPONSE_HEADERS = tags.HTTP_RESPONSE_HEADERS
17
17
 
18
18
  class HttpClientPlugin extends Plugin {
19
- static get name () {
19
+ static get id () {
20
20
  return 'http'
21
21
  }
22
22
 
@@ -39,7 +39,7 @@ class HttpClientPlugin extends Plugin {
39
39
  const span = this.tracer.startSpan('http.request', {
40
40
  childOf,
41
41
  tags: {
42
- [COMPONENT]: this.constructor.name,
42
+ [COMPONENT]: this.constructor.id,
43
43
  'span.kind': 'client',
44
44
  'service.name': getServiceName(this.tracer, this.config, options),
45
45
  'resource.name': method,
@@ -5,7 +5,7 @@ const HttpClientPlugin = require('./client')
5
5
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
6
6
 
7
7
  class HttpPlugin extends CompositePlugin {
8
- static get name () { return 'http' }
8
+ static get id () { return 'http' }
9
9
  static get plugins () {
10
10
  return {
11
11
  server: HttpServerPlugin,