dd-trace 5.61.1 → 5.63.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 (215) hide show
  1. package/README.md +0 -5
  2. package/package.json +2 -2
  3. package/packages/datadog-instrumentations/src/ai.js +140 -0
  4. package/packages/datadog-instrumentations/src/apollo-server.js +50 -8
  5. package/packages/datadog-instrumentations/src/aws-sdk.js +49 -60
  6. package/packages/datadog-instrumentations/src/couchbase.js +102 -65
  7. package/packages/datadog-instrumentations/src/fastify.js +61 -55
  8. package/packages/datadog-instrumentations/src/graphql.js +90 -122
  9. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  10. package/packages/datadog-instrumentations/src/helpers/register.js +2 -22
  11. package/packages/datadog-instrumentations/src/hono.js +11 -8
  12. package/packages/datadog-instrumentations/src/http2/server.js +14 -20
  13. package/packages/datadog-instrumentations/src/knex.js +15 -17
  14. package/packages/datadog-instrumentations/src/microgateway-core.js +16 -15
  15. package/packages/datadog-instrumentations/src/mongodb-core.js +35 -32
  16. package/packages/datadog-instrumentations/src/mongodb.js +9 -13
  17. package/packages/datadog-instrumentations/src/mongoose.js +25 -29
  18. package/packages/datadog-instrumentations/src/next.js +4 -8
  19. package/packages/datadog-instrumentations/src/openai.js +0 -2
  20. package/packages/datadog-instrumentations/src/oracledb.js +39 -33
  21. package/packages/datadog-instrumentations/src/pg.js +38 -48
  22. package/packages/datadog-plugin-aerospike/src/index.js +11 -11
  23. package/packages/datadog-plugin-ai/src/index.js +17 -0
  24. package/packages/datadog-plugin-ai/src/tracing.js +33 -0
  25. package/packages/datadog-plugin-ai/src/utils.js +28 -0
  26. package/packages/datadog-plugin-amqp10/src/consumer.js +2 -2
  27. package/packages/datadog-plugin-amqp10/src/index.js +1 -1
  28. package/packages/datadog-plugin-amqp10/src/producer.js +3 -3
  29. package/packages/datadog-plugin-amqplib/src/client.js +3 -3
  30. package/packages/datadog-plugin-amqplib/src/consumer.js +2 -2
  31. package/packages/datadog-plugin-amqplib/src/index.js +1 -1
  32. package/packages/datadog-plugin-amqplib/src/producer.js +2 -2
  33. package/packages/datadog-plugin-apollo/src/gateway/execute.js +2 -4
  34. package/packages/datadog-plugin-apollo/src/gateway/fetch.js +2 -4
  35. package/packages/datadog-plugin-apollo/src/gateway/index.js +1 -1
  36. package/packages/datadog-plugin-apollo/src/gateway/plan.js +2 -4
  37. package/packages/datadog-plugin-apollo/src/gateway/postprocessing.js +2 -4
  38. package/packages/datadog-plugin-apollo/src/gateway/request.js +2 -4
  39. package/packages/datadog-plugin-apollo/src/gateway/validate.js +2 -4
  40. package/packages/datadog-plugin-apollo/src/index.js +1 -1
  41. package/packages/datadog-plugin-avsc/src/index.js +2 -2
  42. package/packages/datadog-plugin-aws-sdk/src/base.js +70 -46
  43. package/packages/datadog-plugin-aws-sdk/src/index.js +1 -3
  44. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +1 -3
  45. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
  46. package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
  47. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +3 -3
  48. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
  49. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +22 -20
  50. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +1 -1
  51. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +1 -1
  52. package/packages/datadog-plugin-aws-sdk/src/services/s3.js +3 -3
  53. package/packages/datadog-plugin-aws-sdk/src/services/sfn.js +1 -1
  54. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +3 -3
  55. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +17 -15
  56. package/packages/datadog-plugin-aws-sdk/src/services/states.js +1 -1
  57. package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +1 -1
  58. package/packages/datadog-plugin-azure-functions/src/index.js +5 -5
  59. package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
  60. package/packages/datadog-plugin-azure-service-bus/src/producer.js +2 -2
  61. package/packages/datadog-plugin-bunyan/src/index.js +3 -5
  62. package/packages/datadog-plugin-cassandra-driver/src/index.js +3 -3
  63. package/packages/datadog-plugin-child_process/src/index.js +2 -2
  64. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/batch-consumer.js +1 -3
  65. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/consumer.js +1 -3
  66. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
  67. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/producer.js +1 -3
  68. package/packages/datadog-plugin-connect/src/index.js +1 -3
  69. package/packages/datadog-plugin-couchbase/src/index.js +39 -19
  70. package/packages/datadog-plugin-cucumber/src/index.js +1 -3
  71. package/packages/datadog-plugin-cypress/src/index.js +1 -3
  72. package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -3
  73. package/packages/datadog-plugin-dns/src/index.js +1 -1
  74. package/packages/datadog-plugin-dns/src/lookup.js +2 -2
  75. package/packages/datadog-plugin-dns/src/lookup_service.js +2 -2
  76. package/packages/datadog-plugin-dns/src/resolve.js +2 -2
  77. package/packages/datadog-plugin-dns/src/reverse.js +2 -2
  78. package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
  79. package/packages/datadog-plugin-express/src/code_origin.js +1 -3
  80. package/packages/datadog-plugin-express/src/index.js +1 -1
  81. package/packages/datadog-plugin-express/src/tracing.js +1 -3
  82. package/packages/datadog-plugin-fastify/src/code_origin.js +1 -3
  83. package/packages/datadog-plugin-fastify/src/index.js +1 -1
  84. package/packages/datadog-plugin-fastify/src/tracing.js +18 -3
  85. package/packages/datadog-plugin-fetch/src/index.js +2 -2
  86. package/packages/datadog-plugin-find-my-way/src/index.js +1 -3
  87. package/packages/datadog-plugin-fs/src/index.js +2 -2
  88. package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +3 -3
  89. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -2
  90. package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -1
  91. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +2 -2
  92. package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +1 -1
  93. package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +2 -4
  94. package/packages/datadog-plugin-graphql/src/execute.js +16 -9
  95. package/packages/datadog-plugin-graphql/src/index.js +1 -1
  96. package/packages/datadog-plugin-graphql/src/parse.js +12 -7
  97. package/packages/datadog-plugin-graphql/src/resolve.js +50 -16
  98. package/packages/datadog-plugin-graphql/src/validate.js +13 -7
  99. package/packages/datadog-plugin-grpc/src/client.js +4 -4
  100. package/packages/datadog-plugin-grpc/src/index.js +1 -1
  101. package/packages/datadog-plugin-grpc/src/server.js +3 -3
  102. package/packages/datadog-plugin-hapi/src/index.js +1 -3
  103. package/packages/datadog-plugin-hono/src/index.js +1 -3
  104. package/packages/datadog-plugin-http/src/client.js +2 -2
  105. package/packages/datadog-plugin-http/src/index.js +1 -1
  106. package/packages/datadog-plugin-http/src/server.js +3 -7
  107. package/packages/datadog-plugin-http2/src/client.js +2 -2
  108. package/packages/datadog-plugin-http2/src/index.js +1 -1
  109. package/packages/datadog-plugin-http2/src/server.js +22 -11
  110. package/packages/datadog-plugin-ioredis/src/index.js +1 -3
  111. package/packages/datadog-plugin-iovalkey/src/index.js +2 -4
  112. package/packages/datadog-plugin-jest/src/index.js +1 -3
  113. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -2
  114. package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -2
  115. package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
  116. package/packages/datadog-plugin-kafkajs/src/producer.js +3 -3
  117. package/packages/datadog-plugin-koa/src/index.js +1 -3
  118. package/packages/datadog-plugin-langchain/src/index.js +2 -2
  119. package/packages/datadog-plugin-langchain/src/tracing.js +30 -48
  120. package/packages/datadog-plugin-mariadb/src/index.js +2 -2
  121. package/packages/datadog-plugin-memcached/src/index.js +1 -1
  122. package/packages/datadog-plugin-microgateway-core/src/index.js +4 -4
  123. package/packages/datadog-plugin-mocha/src/index.js +1 -3
  124. package/packages/datadog-plugin-moleculer/src/client.js +2 -2
  125. package/packages/datadog-plugin-moleculer/src/index.js +1 -1
  126. package/packages/datadog-plugin-moleculer/src/server.js +2 -2
  127. package/packages/datadog-plugin-mongodb-core/src/index.js +9 -5
  128. package/packages/datadog-plugin-mongoose/src/index.js +20 -0
  129. package/packages/datadog-plugin-mysql/src/index.js +2 -2
  130. package/packages/datadog-plugin-mysql2/src/index.js +1 -1
  131. package/packages/datadog-plugin-net/src/index.js +1 -1
  132. package/packages/datadog-plugin-net/src/ipc.js +2 -2
  133. package/packages/datadog-plugin-net/src/tcp.js +2 -2
  134. package/packages/datadog-plugin-next/src/index.js +1 -3
  135. package/packages/datadog-plugin-nyc/src/index.js +1 -3
  136. package/packages/datadog-plugin-openai/src/index.js +1 -1
  137. package/packages/datadog-plugin-openai/src/tracing.js +7 -411
  138. package/packages/datadog-plugin-opensearch/src/index.js +1 -3
  139. package/packages/datadog-plugin-oracledb/src/index.js +9 -5
  140. package/packages/datadog-plugin-pg/src/index.js +8 -5
  141. package/packages/datadog-plugin-pino/src/index.js +3 -5
  142. package/packages/datadog-plugin-playwright/src/index.js +1 -3
  143. package/packages/datadog-plugin-prisma/src/client.js +4 -6
  144. package/packages/datadog-plugin-prisma/src/engine.js +3 -3
  145. package/packages/datadog-plugin-prisma/src/index.js +1 -1
  146. package/packages/datadog-plugin-protobufjs/src/index.js +2 -6
  147. package/packages/datadog-plugin-redis/src/index.js +2 -2
  148. package/packages/datadog-plugin-restify/src/index.js +1 -3
  149. package/packages/datadog-plugin-rhea/src/consumer.js +1 -1
  150. package/packages/datadog-plugin-rhea/src/index.js +1 -1
  151. package/packages/datadog-plugin-rhea/src/producer.js +2 -2
  152. package/packages/datadog-plugin-router/src/index.js +1 -3
  153. package/packages/datadog-plugin-selenium/src/index.js +1 -3
  154. package/packages/datadog-plugin-sharedb/src/index.js +1 -1
  155. package/packages/datadog-plugin-tedious/src/index.js +3 -3
  156. package/packages/datadog-plugin-undici/src/index.js +2 -4
  157. package/packages/datadog-plugin-vitest/src/index.js +1 -3
  158. package/packages/datadog-plugin-web/src/index.js +1 -3
  159. package/packages/datadog-plugin-winston/src/index.js +3 -5
  160. package/packages/dd-trace/src/appsec/channels.js +1 -0
  161. package/packages/dd-trace/src/appsec/graphql.js +14 -12
  162. package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +14 -7
  163. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +4 -4
  164. package/packages/dd-trace/src/appsec/recommended.json +271 -2
  165. package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
  166. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +1 -3
  167. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +1 -3
  168. package/packages/dd-trace/src/config.js +1 -1
  169. package/packages/dd-trace/src/datastreams/checkpointer.js +23 -2
  170. package/packages/dd-trace/src/datastreams/processor.js +4 -3
  171. package/packages/dd-trace/src/guardrails/telemetry.js +18 -2
  172. package/packages/dd-trace/src/llmobs/plugins/ai/index.js +351 -0
  173. package/packages/dd-trace/src/llmobs/plugins/ai/util.js +179 -0
  174. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +30 -50
  175. package/packages/dd-trace/src/llmobs/plugins/openai.js +3 -5
  176. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +3 -5
  177. package/packages/dd-trace/src/llmobs/writers/base.js +3 -2
  178. package/packages/dd-trace/src/opentracing/propagation/text_map.js +25 -2
  179. package/packages/dd-trace/src/opentracing/span_context.js +4 -0
  180. package/packages/dd-trace/src/plugin_manager.js +8 -4
  181. package/packages/dd-trace/src/plugins/apollo.js +3 -3
  182. package/packages/dd-trace/src/plugins/cache.js +1 -1
  183. package/packages/dd-trace/src/plugins/client.js +3 -3
  184. package/packages/dd-trace/src/plugins/consumer.js +3 -3
  185. package/packages/dd-trace/src/plugins/database.js +2 -2
  186. package/packages/dd-trace/src/plugins/index.js +2 -0
  187. package/packages/dd-trace/src/plugins/log_plugin.js +1 -5
  188. package/packages/dd-trace/src/plugins/outbound.js +1 -1
  189. package/packages/dd-trace/src/plugins/plugin.js +1 -1
  190. package/packages/dd-trace/src/plugins/producer.js +3 -3
  191. package/packages/dd-trace/src/plugins/server.js +3 -3
  192. package/packages/dd-trace/src/plugins/storage.js +1 -1
  193. package/packages/dd-trace/src/plugins/tracing.js +24 -6
  194. package/packages/dd-trace/src/plugins/util/ci.js +11 -7
  195. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +15 -19
  196. package/packages/dd-trace/src/plugins/util/ip_extractor.js +44 -3
  197. package/packages/dd-trace/src/plugins/util/tags.js +2 -0
  198. package/packages/dd-trace/src/plugins/util/web.js +26 -7
  199. package/packages/dd-trace/src/profiling/config.js +2 -0
  200. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +2 -21
  201. package/packages/dd-trace/src/profiling/libuv-size.js +49 -0
  202. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -6
  203. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +1 -3
  204. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +1 -3
  205. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +1 -3
  206. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +1 -3
  207. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +24 -23
  208. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +3 -9
  209. package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +3 -9
  210. package/packages/dd-trace/src/profiling/profilers/events.js +83 -64
  211. package/packages/dd-trace/src/profiling/profilers/poisson.js +105 -0
  212. package/packages/dd-trace/src/profiling/profilers/wall.js +3 -3
  213. package/packages/dd-trace/src/remote_config/manager.js +1 -1
  214. package/packages/dd-trace/src/supported-configurations.json +2 -0
  215. package/packages/dd-trace/src/tracer_metadata.js +1 -1
@@ -2,13 +2,12 @@
2
2
 
3
3
  const log = require('../../../dd-trace/src/log')
4
4
  const BaseAwsSdkPlugin = require('../base')
5
- const { storage } = require('../../../datadog-core')
6
5
  const { DsmPathwayCodec, getHeadersSize } = require('../../../dd-trace/src/datastreams')
7
6
 
8
7
  class Sqs extends BaseAwsSdkPlugin {
9
- static get id () { return 'sqs' }
10
- static get peerServicePrecursors () { return ['queuename'] }
11
- static get isPayloadReporter () { return true }
8
+ static id = 'sqs'
9
+ static peerServicePrecursors = ['queuename']
10
+ static isPayloadReporter = true
12
11
 
13
12
  constructor (...args) {
14
13
  super(...args)
@@ -17,36 +16,39 @@ class Sqs extends BaseAwsSdkPlugin {
17
16
  // in the base class
18
17
  this.requestTags = new WeakMap()
19
18
 
20
- this.addSub('apm:aws:response:start:sqs', obj => {
21
- const { request, response } = obj
22
- const store = storage('legacy').getStore()
19
+ this.addBind('apm:aws:response:start:sqs', ctx => {
20
+ const { request, response } = ctx
23
21
  const contextExtraction = this.responseExtract(request.params, request.operation, response)
22
+
23
+ let store = this._parentMap.get(request)
24
24
  let span
25
25
  let parsedMessageAttributes = null
26
26
  if (contextExtraction && contextExtraction.datadogContext) {
27
- obj.needsFinish = true
27
+ ctx.needsFinish = true
28
28
  const options = {
29
29
  childOf: contextExtraction.datadogContext,
30
- tags: {
30
+ meta: {
31
31
  ...this.requestTags.get(request),
32
32
  'span.kind': 'server'
33
33
  },
34
34
  integrationName: 'aws-sdk'
35
35
  }
36
36
  parsedMessageAttributes = contextExtraction.parsedAttributes
37
- span = this.tracer.startSpan('aws.response', options)
38
- this.enter(span, store)
37
+ span = this.startSpan('aws.response', options, ctx)
38
+ store = ctx.currentStore
39
39
  }
40
- // extract DSM context after as we might not have a parent-child but may have a DSM context
41
40
 
41
+ // extract DSM context after as we might not have a parent-child but may have a DSM context
42
42
  this.responseExtractDSMContext(
43
43
  request.operation, request.params, response, span || null, { parsedAttributes: parsedMessageAttributes }
44
44
  )
45
+
46
+ return store
45
47
  })
46
48
 
47
- this.addSub('apm:aws:response:finish:sqs', err => {
48
- const { span } = storage('legacy').getStore()
49
- this.finish(span, null, err)
49
+ this.addSub('apm:aws:response:finish:sqs', ctx => {
50
+ if (!ctx.needsFinish) return
51
+ this.finish(ctx)
50
52
  })
51
53
  }
52
54
 
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
  const Stepfunctions = require('./stepfunctions')
3
3
  class States extends Stepfunctions {
4
- static get id () { return 'states' }
4
+ static id = 'states'
5
5
  }
6
6
 
7
7
  module.exports = States
@@ -3,7 +3,7 @@ const log = require('../../../dd-trace/src/log')
3
3
  const BaseAwsSdkPlugin = require('../base')
4
4
 
5
5
  class Stepfunctions extends BaseAwsSdkPlugin {
6
- static get id () { return 'stepfunctions' }
6
+ static id = 'stepfunctions'
7
7
 
8
8
  // This is the shape of StartExecutionInput, as defined in
9
9
  // https://github.com/aws/aws-sdk-js/blob/master/apis/states-2016-11-23.normal.json
@@ -16,11 +16,11 @@ const triggerMap = {
16
16
  }
17
17
 
18
18
  class AzureFunctionsPlugin extends TracingPlugin {
19
- static get id () { return 'azure-functions' }
20
- static get operation () { return 'invoke' }
21
- static get kind () { return 'server' }
22
- static get type () { return 'serverless' }
23
- static get prefix () { return 'tracing:datadog:azure:functions:invoke' }
19
+ static id = 'azure-functions'
20
+ static operation = 'invoke'
21
+ static kind = 'server'
22
+ static type = 'serverless'
23
+ static prefix = 'tracing:datadog:azure:functions:invoke'
24
24
 
25
25
  bindStart (ctx) {
26
26
  const childOf = extractTraceContext(this._tracer, ctx)
@@ -4,7 +4,7 @@ const ProducerPlugin = require('./producer')
4
4
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
5
5
 
6
6
  class AzureServiceBusPlugin extends CompositePlugin {
7
- static get id () { return 'azure-service-bus' }
7
+ static id = 'azure-service-bus'
8
8
  static get plugins () {
9
9
  return {
10
10
  producer: ProducerPlugin
@@ -3,8 +3,8 @@
3
3
  const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
4
4
 
5
5
  class AzureServiceBusProducerPlugin extends ProducerPlugin {
6
- static get id () { return 'azure-service-bus' }
7
- static get operation () { return 'send' }
6
+ static id = 'azure-service-bus'
7
+ static operation = 'send'
8
8
 
9
9
  bindStart (ctx) {
10
10
  const { sender, msg } = ctx
@@ -1,10 +1,8 @@
1
1
  'use strict'
2
2
 
3
- const StructuredLogPlugin = require('../../dd-trace/src/plugins/structured_log_plugin')
3
+ const LogPlugin = require('../../dd-trace/src/plugins/log_plugin')
4
4
 
5
- class BunyanPlugin extends StructuredLogPlugin {
6
- static get id () {
7
- return 'bunyan'
8
- }
5
+ class BunyanPlugin extends LogPlugin {
6
+ static id = 'bunyan'
9
7
  }
10
8
  module.exports = BunyanPlugin
@@ -4,9 +4,9 @@ const DatabasePlugin = require('../../dd-trace/src/plugins/database')
4
4
  const CASSANDRA_CONTACT_POINTS_KEY = 'db.cassandra.contact.points'
5
5
 
6
6
  class CassandraDriverPlugin extends DatabasePlugin {
7
- static get id () { return 'cassandra-driver' }
8
- static get system () { return 'cassandra' }
9
- static get peerServicePrecursors () { return [CASSANDRA_CONTACT_POINTS_KEY] }
7
+ static id = 'cassandra-driver'
8
+ static system = 'cassandra'
9
+ static peerServicePrecursors = [CASSANDRA_CONTACT_POINTS_KEY]
10
10
 
11
11
  bindStart (ctx) {
12
12
  let { keyspace, query, contactPoints = {} } = ctx
@@ -28,8 +28,8 @@ function truncateCommand (cmdFields) {
28
28
  }
29
29
 
30
30
  class ChildProcessPlugin extends TracingPlugin {
31
- static get id () { return 'child_process' }
32
- static get prefix () { return 'tracing:datadog:child_process:execution' }
31
+ static id = 'child_process'
32
+ static prefix = 'tracing:datadog:child_process:execution'
33
33
 
34
34
  get tracer () {
35
35
  return this._tracer
@@ -3,9 +3,7 @@
3
3
  const KafkajsBatchConsumerPlugin = require('../../datadog-plugin-kafkajs/src/batch-consumer')
4
4
 
5
5
  class ConfluentKafkaJsBatchConsumerPlugin extends KafkajsBatchConsumerPlugin {
6
- static get id () {
7
- return 'confluentinc-kafka-javascript'
8
- }
6
+ static id = 'confluentinc-kafka-javascript'
9
7
  }
10
8
 
11
9
  module.exports = ConfluentKafkaJsBatchConsumerPlugin
@@ -3,9 +3,7 @@
3
3
  const KafkajsConsumerPlugin = require('../../datadog-plugin-kafkajs/src/consumer')
4
4
 
5
5
  class ConfluentKafkaJsConsumerPlugin extends KafkajsConsumerPlugin {
6
- static get id () {
7
- return 'confluentinc-kafka-javascript'
8
- }
6
+ static id = 'confluentinc-kafka-javascript'
9
7
  }
10
8
 
11
9
  module.exports = ConfluentKafkaJsConsumerPlugin
@@ -6,7 +6,7 @@ const BatchConsumerPlugin = require('./batch-consumer')
6
6
  const KafkajsPlugin = require('../../datadog-plugin-kafkajs/src/index')
7
7
 
8
8
  class ConfluentKafkaJsPlugin extends KafkajsPlugin {
9
- static get id () { return 'confluentinc-kafka-javascript' }
9
+ static id = 'confluentinc-kafka-javascript'
10
10
  static get plugins () {
11
11
  return {
12
12
  producer: ProducerPlugin,
@@ -3,9 +3,7 @@
3
3
  const KafkajsProducerPlugin = require('../../datadog-plugin-kafkajs/src/producer')
4
4
 
5
5
  class ConfluentKafkaJsProducerPlugin extends KafkajsProducerPlugin {
6
- static get id () {
7
- return 'confluentinc-kafka-javascript'
8
- }
6
+ static id = 'confluentinc-kafka-javascript'
9
7
  }
10
8
 
11
9
  module.exports = ConfluentKafkaJsProducerPlugin
@@ -3,9 +3,7 @@
3
3
  const RouterPlugin = require('../../datadog-plugin-router/src')
4
4
 
5
5
  class ConnectPlugin extends RouterPlugin {
6
- static get id () {
7
- return 'connect'
8
- }
6
+ static id = 'connect'
9
7
 
10
8
  constructor (...args) {
11
9
  super(...args)
@@ -4,16 +4,18 @@ const StoragePlugin = require('../../dd-trace/src/plugins/storage')
4
4
  const { storage } = require('../../datadog-core')
5
5
 
6
6
  class CouchBasePlugin extends StoragePlugin {
7
- static get id () { return 'couchbase' }
8
- static get peerServicePrecursors () { return ['db.couchbase.seed.nodes'] }
7
+ static id = 'couchbase'
8
+ static peerServicePrecursors = ['db.couchbase.seed.nodes']
9
9
 
10
- addSubs (func, start) {
11
- this.addSub(`apm:couchbase:${func}:start`, start)
12
- this.addSub(`apm:couchbase:${func}:error`, error => this.addError(error))
13
- this.addSub(`apm:couchbase:${func}:finish`, message => this.finish(message))
10
+ addBinds (func, start) {
11
+ this.addBind(`apm:couchbase:${func}:start`, start)
12
+ this.addSub(`apm:couchbase:${func}:error`, ({ error }) => this.addError(error))
13
+ this.addSub(`apm:couchbase:${func}:finish`, ctx => this.finish(ctx))
14
+ this.addBind(`apm:couchbase:${func}:callback:start`, callbackStart)
15
+ this.addBind(`apm:couchbase:${func}:callback:finish`, callbackFinish)
14
16
  }
15
17
 
16
- startSpan (operation, customTags, store, { bucket, collection, seedNodes }) {
18
+ startSpan (operation, customTags, { bucket, collection, seedNodes }, ctx) {
17
19
  const tags = {
18
20
  'db.type': 'couchbase',
19
21
  component: 'couchbase',
@@ -34,26 +36,34 @@ class CouchBasePlugin extends StoragePlugin {
34
36
  {
35
37
  service: this.serviceName({ pluginConfig: this.config }),
36
38
  meta: tags
37
- }
39
+ },
40
+ ctx
38
41
  )
39
42
  }
40
43
 
41
44
  constructor (...args) {
42
45
  super(...args)
43
46
 
44
- this.addSubs('query', ({ resource, bucket, seedNodes }) => {
45
- const store = storage('legacy').getStore()
46
- const span = this.startSpan(
47
- 'query', {
47
+ this.addBinds('query', (ctx) => {
48
+ const { resource, bucket, seedNodes } = ctx
49
+
50
+ this.startSpan(
51
+ 'query',
52
+ {
48
53
  'span.type': 'sql',
49
54
  'resource.name': resource,
50
55
  'span.kind': this.constructor.kind
51
56
  },
52
- store,
53
- { bucket, seedNodes }
57
+ { bucket, seedNodes },
58
+ ctx
54
59
  )
55
- this.enter(span, store)
60
+
61
+ return ctx.currentStore
56
62
  })
63
+ this.addBind('apm:couchbase:bucket:maybeInvoke:callback:start', callbackStart)
64
+ this.addBind('apm:couchbase:bucket:maybeInvoke:callback:finish', callbackFinish)
65
+ this.addBind('apm:couchbase:cluster:maybeInvoke:callback:start', callbackStart)
66
+ this.addBind('apm:couchbase:cluster:maybeInvoke:callback:finish', callbackFinish)
57
67
 
58
68
  this._addCommandSubs('upsert')
59
69
  this._addCommandSubs('insert')
@@ -63,12 +73,22 @@ class CouchBasePlugin extends StoragePlugin {
63
73
  }
64
74
 
65
75
  _addCommandSubs (name) {
66
- this.addSubs(name, ({ bucket, collection, seedNodes }) => {
67
- const store = storage('legacy').getStore()
68
- const span = this.startSpan(name, {}, store, { bucket, collection, seedNodes })
69
- this.enter(span, store)
76
+ this.addBinds(name, (ctx) => {
77
+ const { bucket, collection, seedNodes } = ctx
78
+
79
+ this.startSpan(name, {}, { bucket, collection, seedNodes }, ctx)
80
+ return ctx.currentStore
70
81
  })
71
82
  }
72
83
  }
73
84
 
85
+ function callbackStart (ctx) {
86
+ ctx.parentStore = storage('legacy').getStore()
87
+ return ctx.parentStore
88
+ }
89
+
90
+ function callbackFinish (ctx) {
91
+ return ctx.parentStore
92
+ }
93
+
74
94
  module.exports = CouchBasePlugin
@@ -75,9 +75,7 @@ function getTestSuiteTags (testSuiteSpan) {
75
75
  }
76
76
 
77
77
  class CucumberPlugin extends CiPlugin {
78
- static get id () {
79
- return 'cucumber'
80
- }
78
+ static id = 'cucumber'
81
79
 
82
80
  constructor (...args) {
83
81
  super(...args)
@@ -5,9 +5,7 @@ const Plugin = require('../../dd-trace/src/plugins/plugin')
5
5
  // Cypress plugin does not patch any library. This is just a placeholder to
6
6
  // follow the structure of the plugins
7
7
  class CypressPlugin extends Plugin {
8
- static get id () {
9
- return 'cypress'
10
- }
8
+ static id = 'cypress'
11
9
  }
12
10
 
13
11
  module.exports = CypressPlugin
@@ -12,9 +12,7 @@ const injectionEnabledTag =
12
12
  `injection_enabled:${getEnvironmentVariable('DD_INJECTION_ENABLED') ? 'yes' : 'no'}`
13
13
 
14
14
  module.exports = class DdTraceApiPlugin extends Plugin {
15
- static get id () {
16
- return 'dd-trace-api'
17
- }
15
+ static id = 'dd-trace-api'
18
16
 
19
17
  constructor (...args) {
20
18
  super(...args)
@@ -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 id () { return 'dns' }
12
+ static id = 'dns'
13
13
  static get plugins () {
14
14
  return {
15
15
  lookup: DNSLookupPlugin,
@@ -3,8 +3,8 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class DNSLookupPlugin extends ClientPlugin {
6
- static get id () { return 'dns' }
7
- static get operation () { return 'lookup' }
6
+ static id = 'dns'
7
+ static operation = 'lookup'
8
8
 
9
9
  bindStart (ctx) {
10
10
  const [hostname] = ctx.args
@@ -3,8 +3,8 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class DNSLookupServicePlugin extends ClientPlugin {
6
- static get id () { return 'dns' }
7
- static get operation () { return 'lookup_service' }
6
+ static id = 'dns'
7
+ static operation = 'lookup_service'
8
8
 
9
9
  bindStart (ctx) {
10
10
  const [address, port] = ctx.args
@@ -3,8 +3,8 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class DNSResolvePlugin extends ClientPlugin {
6
- static get id () { return 'dns' }
7
- static get operation () { return 'resolve' }
6
+ static id = 'dns'
7
+ static operation = 'resolve'
8
8
 
9
9
  bindStart (ctx) {
10
10
  const [hostname, maybeType] = ctx.args
@@ -3,8 +3,8 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class DNSReversePlugin extends ClientPlugin {
6
- static get id () { return 'dns' }
7
- static get operation () { return 'reverse' }
6
+ static id = 'dns'
7
+ static operation = 'reverse'
8
8
 
9
9
  bindStart (ctx) {
10
10
  const [ip] = ctx.args
@@ -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 id () { return 'elasticsearch' }
6
+ static id = 'elasticsearch'
7
7
 
8
8
  bindStart (ctx) {
9
9
  const { params } = ctx
@@ -5,9 +5,7 @@ const Plugin = require('../../dd-trace/src/plugins/plugin')
5
5
  const web = require('../../dd-trace/src/plugins/util/web')
6
6
 
7
7
  class ExpressCodeOriginForSpansPlugin extends Plugin {
8
- static get id () {
9
- return 'express'
10
- }
8
+ static id = 'express'
11
9
 
12
10
  constructor (...args) {
13
11
  super(...args)
@@ -5,7 +5,7 @@ const ExpressCodeOriginForSpansPlugin = require('./code_origin')
5
5
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
6
6
 
7
7
  class ExpressPlugin extends CompositePlugin {
8
- static get id () { return 'express' }
8
+ static id = 'express'
9
9
  static get plugins () {
10
10
  return {
11
11
  tracing: ExpressTracingPlugin,
@@ -3,9 +3,7 @@
3
3
  const RouterPlugin = require('../../datadog-plugin-router/src')
4
4
 
5
5
  class ExpressTracingPlugin extends RouterPlugin {
6
- static get id () {
7
- return 'express'
8
- }
6
+ static id = 'express'
9
7
 
10
8
  constructor (...args) {
11
9
  super(...args)
@@ -7,9 +7,7 @@ const web = require('../../dd-trace/src/plugins/util/web')
7
7
  const kCodeOriginForSpansTagsSym = Symbol('datadog.codeOriginForSpansTags')
8
8
 
9
9
  class FastifyCodeOriginForSpansPlugin extends Plugin {
10
- static get id () {
11
- return 'fastify'
12
- }
10
+ static id = 'fastify'
13
11
 
14
12
  constructor (...args) {
15
13
  super(...args)
@@ -5,7 +5,7 @@ const FastifyCodeOriginForSpansPlugin = require('./code_origin')
5
5
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
6
6
 
7
7
  class FastifyPlugin extends CompositePlugin {
8
- static get id () { return 'fastify' }
8
+ static id = 'fastify'
9
9
  static get plugins () {
10
10
  return {
11
11
  tracing: FastifyTracingPlugin,
@@ -1,11 +1,10 @@
1
1
  'use strict'
2
2
 
3
3
  const RouterPlugin = require('../../datadog-plugin-router/src')
4
+ const { storage } = require('../../datadog-core')
4
5
 
5
6
  class FastifyTracingPlugin extends RouterPlugin {
6
- static get id () {
7
- return 'fastify'
8
- }
7
+ static id = 'fastify'
9
8
 
10
9
  constructor (...args) {
11
10
  super(...args)
@@ -13,7 +12,23 @@ class FastifyTracingPlugin extends RouterPlugin {
13
12
  this.addSub('apm:fastify:request:handle', ({ req }) => {
14
13
  this.setFramework(req, 'fastify', this.config)
15
14
  })
15
+
16
+ this.addBind('datadog:fastify:pre-parsing:start', getParentStore)
17
+ this.addBind('datadog:fastify:pre-validation:start', getParentStore)
18
+
19
+ this.addSub('datadog:fastify:pre-parsing:finish', (ctx) => {
20
+ return ctx.parentStore
21
+ })
22
+ this.addSub('datadog:fastify:pre-validation:finish', (ctx) => {
23
+ return ctx.parentStore
24
+ })
25
+ this.addSub('datadog:fastify:callback:execute', getParentStore)
16
26
  }
17
27
  }
18
28
 
29
+ function getParentStore (ctx) {
30
+ ctx.parentStore = ctx.parentStore ?? storage('legacy').getStore()
31
+ return ctx.parentStore
32
+ }
33
+
19
34
  module.exports = FastifyTracingPlugin
@@ -3,8 +3,8 @@
3
3
  const HttpClientPlugin = require('../../datadog-plugin-http/src/client')
4
4
 
5
5
  class FetchPlugin extends HttpClientPlugin {
6
- static get id () { return 'fetch' }
7
- static get prefix () { return 'tracing:apm:fetch:request' }
6
+ static id = 'fetch'
7
+ static prefix = 'tracing:apm:fetch:request'
8
8
 
9
9
  bindStart (ctx) {
10
10
  const req = ctx.req
@@ -4,9 +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 id () {
8
- return 'find-my-way'
9
- }
7
+ static id = 'find-my-way'
10
8
 
11
9
  constructor (...args) {
12
10
  super(...args)
@@ -3,8 +3,8 @@
3
3
  const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
4
 
5
5
  class FsPlugin extends TracingPlugin {
6
- static get id () { return 'fs' }
7
- static get operation () { return 'operation' }
6
+ static id = 'fs'
7
+ static operation = 'operation'
8
8
 
9
9
  configure (...args) {
10
10
  return super.configure(...args)
@@ -3,9 +3,9 @@
3
3
  const ClientPlugin = require('../../dd-trace/src/plugins/client')
4
4
 
5
5
  class GoogleCloudPubsubClientPlugin extends ClientPlugin {
6
- static get id () { return 'google-cloud-pubsub' }
7
- static get type () { return 'messaging' }
8
- static get operation () { return 'request' }
6
+ static id = 'google-cloud-pubsub'
7
+ static type = 'messaging'
8
+ static operation = 'request'
9
9
 
10
10
  start (ctx) {
11
11
  const { request, api, projectId } = ctx
@@ -4,8 +4,8 @@ const { getMessageSize } = require('../../dd-trace/src/datastreams')
4
4
  const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
5
5
 
6
6
  class GoogleCloudPubsubConsumerPlugin extends ConsumerPlugin {
7
- static get id () { return 'google-cloud-pubsub' }
8
- static get operation () { return 'receive' }
7
+ static id = 'google-cloud-pubsub'
8
+ static operation = 'receive'
9
9
 
10
10
  bindStart (ctx) {
11
11
  const { message } = ctx
@@ -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 id () { return 'google-cloud-pubsub' }
10
+ static id = 'google-cloud-pubsub'
11
11
  static get plugins () {
12
12
  return {
13
13
  producer: ProducerPlugin,
@@ -4,8 +4,8 @@ const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
4
4
  const { DsmPathwayCodec, getHeadersSize } = require('../../dd-trace/src/datastreams')
5
5
 
6
6
  class GoogleCloudPubsubProducerPlugin extends ProducerPlugin {
7
- static get id () { return 'google-cloud-pubsub' }
8
- static get operation () { return 'request' }
7
+ static id = 'google-cloud-pubsub'
8
+ static operation = 'request'
9
9
 
10
10
  bindStart (ctx) {
11
11
  const { request, api, projectId } = ctx
@@ -5,7 +5,7 @@ const GoogleVertexAITracingPlugin = require('./tracing')
5
5
  const VertexAILLMObsPlugin = require('../../dd-trace/src/llmobs/plugins/vertexai')
6
6
 
7
7
  class GoogleCloudVertexAIPlugin extends CompositePlugin {
8
- static get id () { return 'google-cloud-vertexai' }
8
+ static id = 'google-cloud-vertexai'
9
9
  static get plugins () {
10
10
  return {
11
11
  llmobs: VertexAILLMObsPlugin,
@@ -10,10 +10,8 @@ const {
10
10
  } = require('./utils')
11
11
 
12
12
  class GoogleCloudVertexAITracingPlugin extends TracingPlugin {
13
- static get id () { return 'google-cloud-vertexai' }
14
- static get prefix () {
15
- return 'tracing:apm:vertexai:request'
16
- }
13
+ static id = 'google-cloud-vertexai'
14
+ static prefix = 'tracing:apm:vertexai:request'
17
15
 
18
16
  constructor () {
19
17
  super(...arguments)