dd-trace 5.61.0 → 5.62.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 (192) hide show
  1. package/package.json +1 -1
  2. package/packages/datadog-instrumentations/src/apollo-server.js +50 -8
  3. package/packages/datadog-instrumentations/src/aws-sdk.js +49 -60
  4. package/packages/datadog-instrumentations/src/fastify.js +61 -55
  5. package/packages/datadog-instrumentations/src/graphql.js +90 -122
  6. package/packages/datadog-instrumentations/src/http2/server.js +14 -20
  7. package/packages/datadog-instrumentations/src/microgateway-core.js +16 -15
  8. package/packages/datadog-instrumentations/src/mongodb-core.js +34 -29
  9. package/packages/datadog-instrumentations/src/mongodb.js +9 -13
  10. package/packages/datadog-instrumentations/src/mongoose.js +25 -29
  11. package/packages/datadog-instrumentations/src/openai.js +0 -2
  12. package/packages/datadog-instrumentations/src/oracledb.js +39 -33
  13. package/packages/datadog-instrumentations/src/router.js +1 -1
  14. package/packages/datadog-plugin-aerospike/src/index.js +5 -9
  15. package/packages/datadog-plugin-amqp10/src/consumer.js +2 -2
  16. package/packages/datadog-plugin-amqp10/src/index.js +1 -1
  17. package/packages/datadog-plugin-amqp10/src/producer.js +3 -3
  18. package/packages/datadog-plugin-amqplib/src/client.js +3 -3
  19. package/packages/datadog-plugin-amqplib/src/consumer.js +2 -2
  20. package/packages/datadog-plugin-amqplib/src/index.js +1 -1
  21. package/packages/datadog-plugin-amqplib/src/producer.js +2 -2
  22. package/packages/datadog-plugin-apollo/src/gateway/execute.js +2 -4
  23. package/packages/datadog-plugin-apollo/src/gateway/fetch.js +2 -4
  24. package/packages/datadog-plugin-apollo/src/gateway/index.js +1 -1
  25. package/packages/datadog-plugin-apollo/src/gateway/plan.js +2 -4
  26. package/packages/datadog-plugin-apollo/src/gateway/postprocessing.js +2 -4
  27. package/packages/datadog-plugin-apollo/src/gateway/request.js +2 -4
  28. package/packages/datadog-plugin-apollo/src/gateway/validate.js +2 -4
  29. package/packages/datadog-plugin-apollo/src/index.js +1 -1
  30. package/packages/datadog-plugin-avsc/src/index.js +2 -2
  31. package/packages/datadog-plugin-aws-sdk/src/base.js +70 -46
  32. package/packages/datadog-plugin-aws-sdk/src/index.js +1 -3
  33. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +1 -3
  34. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/tracing.js +1 -1
  35. package/packages/datadog-plugin-aws-sdk/src/services/cloudwatchlogs.js +1 -1
  36. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +3 -3
  37. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +2 -2
  38. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +22 -20
  39. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +1 -1
  40. package/packages/datadog-plugin-aws-sdk/src/services/redshift.js +1 -1
  41. package/packages/datadog-plugin-aws-sdk/src/services/s3.js +3 -3
  42. package/packages/datadog-plugin-aws-sdk/src/services/sfn.js +1 -1
  43. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +3 -3
  44. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +17 -15
  45. package/packages/datadog-plugin-aws-sdk/src/services/states.js +1 -1
  46. package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +1 -1
  47. package/packages/datadog-plugin-azure-functions/src/index.js +5 -5
  48. package/packages/datadog-plugin-azure-service-bus/src/index.js +1 -1
  49. package/packages/datadog-plugin-azure-service-bus/src/producer.js +2 -2
  50. package/packages/datadog-plugin-bunyan/src/index.js +3 -5
  51. package/packages/datadog-plugin-cassandra-driver/src/index.js +3 -3
  52. package/packages/datadog-plugin-child_process/src/index.js +2 -2
  53. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/batch-consumer.js +1 -3
  54. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/consumer.js +1 -3
  55. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/index.js +1 -1
  56. package/packages/datadog-plugin-confluentinc-kafka-javascript/src/producer.js +1 -3
  57. package/packages/datadog-plugin-connect/src/index.js +1 -3
  58. package/packages/datadog-plugin-couchbase/src/index.js +2 -2
  59. package/packages/datadog-plugin-cucumber/src/index.js +1 -3
  60. package/packages/datadog-plugin-cypress/src/index.js +1 -3
  61. package/packages/datadog-plugin-dd-trace-api/src/index.js +1 -3
  62. package/packages/datadog-plugin-dns/src/index.js +1 -1
  63. package/packages/datadog-plugin-dns/src/lookup.js +2 -2
  64. package/packages/datadog-plugin-dns/src/lookup_service.js +2 -2
  65. package/packages/datadog-plugin-dns/src/resolve.js +2 -2
  66. package/packages/datadog-plugin-dns/src/reverse.js +2 -2
  67. package/packages/datadog-plugin-elasticsearch/src/index.js +1 -1
  68. package/packages/datadog-plugin-express/src/code_origin.js +1 -3
  69. package/packages/datadog-plugin-express/src/index.js +1 -1
  70. package/packages/datadog-plugin-express/src/tracing.js +1 -3
  71. package/packages/datadog-plugin-fastify/src/code_origin.js +1 -3
  72. package/packages/datadog-plugin-fastify/src/index.js +1 -1
  73. package/packages/datadog-plugin-fastify/src/tracing.js +18 -3
  74. package/packages/datadog-plugin-fetch/src/index.js +2 -2
  75. package/packages/datadog-plugin-find-my-way/src/index.js +1 -3
  76. package/packages/datadog-plugin-fs/src/index.js +2 -2
  77. package/packages/datadog-plugin-google-cloud-pubsub/src/client.js +3 -3
  78. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -2
  79. package/packages/datadog-plugin-google-cloud-pubsub/src/index.js +1 -1
  80. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +2 -2
  81. package/packages/datadog-plugin-google-cloud-vertexai/src/index.js +1 -1
  82. package/packages/datadog-plugin-google-cloud-vertexai/src/tracing.js +2 -4
  83. package/packages/datadog-plugin-graphql/src/execute.js +16 -9
  84. package/packages/datadog-plugin-graphql/src/index.js +1 -1
  85. package/packages/datadog-plugin-graphql/src/parse.js +12 -7
  86. package/packages/datadog-plugin-graphql/src/resolve.js +50 -16
  87. package/packages/datadog-plugin-graphql/src/validate.js +13 -7
  88. package/packages/datadog-plugin-grpc/src/client.js +4 -4
  89. package/packages/datadog-plugin-grpc/src/index.js +1 -1
  90. package/packages/datadog-plugin-grpc/src/server.js +3 -3
  91. package/packages/datadog-plugin-hapi/src/index.js +1 -3
  92. package/packages/datadog-plugin-hono/src/index.js +1 -3
  93. package/packages/datadog-plugin-http/src/client.js +2 -2
  94. package/packages/datadog-plugin-http/src/index.js +1 -1
  95. package/packages/datadog-plugin-http/src/server.js +3 -7
  96. package/packages/datadog-plugin-http2/src/client.js +2 -2
  97. package/packages/datadog-plugin-http2/src/index.js +1 -1
  98. package/packages/datadog-plugin-http2/src/server.js +22 -11
  99. package/packages/datadog-plugin-ioredis/src/index.js +1 -3
  100. package/packages/datadog-plugin-iovalkey/src/index.js +2 -4
  101. package/packages/datadog-plugin-jest/src/index.js +1 -3
  102. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -2
  103. package/packages/datadog-plugin-kafkajs/src/consumer.js +2 -2
  104. package/packages/datadog-plugin-kafkajs/src/index.js +1 -1
  105. package/packages/datadog-plugin-kafkajs/src/producer.js +3 -3
  106. package/packages/datadog-plugin-koa/src/index.js +1 -3
  107. package/packages/datadog-plugin-langchain/src/index.js +2 -2
  108. package/packages/datadog-plugin-langchain/src/tracing.js +30 -48
  109. package/packages/datadog-plugin-mariadb/src/index.js +2 -2
  110. package/packages/datadog-plugin-memcached/src/index.js +1 -1
  111. package/packages/datadog-plugin-microgateway-core/src/index.js +4 -4
  112. package/packages/datadog-plugin-mocha/src/index.js +1 -3
  113. package/packages/datadog-plugin-moleculer/src/client.js +2 -2
  114. package/packages/datadog-plugin-moleculer/src/index.js +1 -1
  115. package/packages/datadog-plugin-moleculer/src/server.js +2 -2
  116. package/packages/datadog-plugin-mongodb-core/src/index.js +9 -5
  117. package/packages/datadog-plugin-mongoose/src/index.js +20 -0
  118. package/packages/datadog-plugin-mysql/src/index.js +2 -2
  119. package/packages/datadog-plugin-mysql2/src/index.js +1 -1
  120. package/packages/datadog-plugin-net/src/index.js +1 -1
  121. package/packages/datadog-plugin-net/src/ipc.js +2 -2
  122. package/packages/datadog-plugin-net/src/tcp.js +2 -2
  123. package/packages/datadog-plugin-next/src/index.js +1 -3
  124. package/packages/datadog-plugin-nyc/src/index.js +1 -3
  125. package/packages/datadog-plugin-openai/src/index.js +1 -1
  126. package/packages/datadog-plugin-openai/src/tracing.js +7 -411
  127. package/packages/datadog-plugin-opensearch/src/index.js +1 -3
  128. package/packages/datadog-plugin-oracledb/src/index.js +9 -5
  129. package/packages/datadog-plugin-pg/src/index.js +3 -3
  130. package/packages/datadog-plugin-pino/src/index.js +3 -5
  131. package/packages/datadog-plugin-playwright/src/index.js +1 -3
  132. package/packages/datadog-plugin-prisma/src/client.js +4 -6
  133. package/packages/datadog-plugin-prisma/src/engine.js +3 -3
  134. package/packages/datadog-plugin-prisma/src/index.js +1 -1
  135. package/packages/datadog-plugin-protobufjs/src/index.js +2 -6
  136. package/packages/datadog-plugin-redis/src/index.js +2 -2
  137. package/packages/datadog-plugin-restify/src/index.js +1 -3
  138. package/packages/datadog-plugin-rhea/src/consumer.js +1 -1
  139. package/packages/datadog-plugin-rhea/src/index.js +1 -1
  140. package/packages/datadog-plugin-rhea/src/producer.js +2 -2
  141. package/packages/datadog-plugin-router/src/index.js +1 -3
  142. package/packages/datadog-plugin-selenium/src/index.js +1 -3
  143. package/packages/datadog-plugin-sharedb/src/index.js +1 -1
  144. package/packages/datadog-plugin-tedious/src/index.js +3 -3
  145. package/packages/datadog-plugin-undici/src/index.js +2 -4
  146. package/packages/datadog-plugin-vitest/src/index.js +1 -3
  147. package/packages/datadog-plugin-web/src/index.js +1 -3
  148. package/packages/datadog-plugin-winston/src/index.js +3 -5
  149. package/packages/dd-trace/src/appsec/channels.js +1 -0
  150. package/packages/dd-trace/src/appsec/graphql.js +14 -12
  151. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +1 -1
  152. package/packages/dd-trace/src/appsec/waf/waf_manager.js +1 -1
  153. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +1 -3
  154. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +1 -3
  155. package/packages/dd-trace/src/config.js +1 -1
  156. package/packages/dd-trace/src/datastreams/checkpointer.js +23 -2
  157. package/packages/dd-trace/src/datastreams/processor.js +4 -3
  158. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +30 -50
  159. package/packages/dd-trace/src/llmobs/plugins/openai.js +3 -5
  160. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +3 -5
  161. package/packages/dd-trace/src/opentracing/propagation/text_map.js +25 -2
  162. package/packages/dd-trace/src/plugins/apollo.js +3 -3
  163. package/packages/dd-trace/src/plugins/cache.js +1 -1
  164. package/packages/dd-trace/src/plugins/client.js +3 -3
  165. package/packages/dd-trace/src/plugins/consumer.js +3 -3
  166. package/packages/dd-trace/src/plugins/database.js +2 -2
  167. package/packages/dd-trace/src/plugins/index.js +1 -0
  168. package/packages/dd-trace/src/plugins/log_plugin.js +1 -5
  169. package/packages/dd-trace/src/plugins/outbound.js +1 -1
  170. package/packages/dd-trace/src/plugins/plugin.js +1 -1
  171. package/packages/dd-trace/src/plugins/producer.js +3 -3
  172. package/packages/dd-trace/src/plugins/server.js +3 -3
  173. package/packages/dd-trace/src/plugins/storage.js +1 -1
  174. package/packages/dd-trace/src/plugins/tracing.js +24 -6
  175. package/packages/dd-trace/src/plugins/util/ci.js +11 -7
  176. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +15 -19
  177. package/packages/dd-trace/src/plugins/util/tags.js +2 -0
  178. package/packages/dd-trace/src/plugins/util/web.js +26 -7
  179. package/packages/dd-trace/src/profiling/config.js +2 -0
  180. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +2 -21
  181. package/packages/dd-trace/src/profiling/libuv-size.js +49 -0
  182. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -6
  183. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +1 -3
  184. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +1 -3
  185. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +1 -3
  186. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +1 -3
  187. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +3 -9
  188. package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +3 -9
  189. package/packages/dd-trace/src/profiling/profilers/events.js +80 -62
  190. package/packages/dd-trace/src/profiling/profilers/poisson.js +105 -0
  191. package/packages/dd-trace/src/profiling/profilers/wall.js +1 -1
  192. package/packages/dd-trace/src/remote_config/manager.js +1 -1
@@ -4,8 +4,8 @@ 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
10
  addSubs (func, start) {
11
11
  this.addSub(`apm:couchbase:${func}:start`, start)
@@ -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)
@@ -6,12 +6,14 @@ const { extractErrorIntoSpanEvent } = require('./utils')
6
6
  let tools
7
7
 
8
8
  class GraphQLExecutePlugin extends TracingPlugin {
9
- static get id () { return 'graphql' }
10
- static get operation () { return 'execute' }
11
- static get type () { return 'graphql' }
12
- static get kind () { return 'server' }
9
+ static id = 'graphql'
10
+ static operation = 'execute'
11
+ static type = 'graphql'
12
+ static kind = 'server'
13
+
14
+ bindStart (ctx) {
15
+ const { operation, args, docSource } = ctx
13
16
 
14
- start ({ operation, args, docSource }) {
15
17
  const type = operation && operation.operation
16
18
  const name = operation && operation.name && operation.name.value
17
19
  const document = args.document
@@ -27,20 +29,25 @@ class GraphQLExecutePlugin extends TracingPlugin {
27
29
  'graphql.operation.name': name,
28
30
  'graphql.source': source
29
31
  }
30
- })
32
+ }, ctx)
31
33
 
32
34
  addVariableTags(this.config, span, args.variableValues)
35
+
36
+ return ctx.currentStore
33
37
  }
34
38
 
35
- finish ({ res, args }) {
36
- const span = this.activeSpan
39
+ finish (ctx) {
40
+ const { res, args } = ctx
41
+ const span = ctx?.currentStore?.span || this.activeSpan
37
42
  this.config.hooks.execute(span, args, res)
38
43
  if (res?.errors) {
39
44
  for (const err of res.errors) {
40
45
  extractErrorIntoSpanEvent(this._tracerConfig, span, err)
41
46
  }
42
47
  }
43
- super.finish()
48
+ super.finish(ctx)
49
+
50
+ return ctx.parentStore
44
51
  }
45
52
  }
46
53
 
@@ -9,7 +9,7 @@ const GraphQLValidatePlugin = require('./validate')
9
9
  const GraphQLResolvePlugin = require('./resolve')
10
10
 
11
11
  class GraphQLPlugin extends CompositePlugin {
12
- static get id () { return 'graphql' }
12
+ static id = 'graphql'
13
13
  static get plugins () {
14
14
  return {
15
15
  execute: GraphQLExecutePlugin,
@@ -3,19 +3,22 @@
3
3
  const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
4
 
5
5
  class GraphQLParsePlugin extends TracingPlugin {
6
- static get id () { return 'graphql' }
7
- static get operation () { return 'parser' }
6
+ static id = 'graphql'
7
+ static operation = 'parser'
8
8
 
9
- start () {
9
+ bindStart (ctx) {
10
10
  this.startSpan('graphql.parse', {
11
11
  service: this.config.service,
12
12
  type: 'graphql',
13
13
  meta: {}
14
- })
14
+ }, ctx)
15
+
16
+ return ctx.currentStore
15
17
  }
16
18
 
17
- finish ({ source, document, docSource }) {
18
- const span = this.activeSpan
19
+ finish (ctx) {
20
+ const { source, document, docSource } = ctx
21
+ const span = ctx?.currentStore?.span || this.activeSpan
19
22
 
20
23
  if (this.config.source && document) {
21
24
  span.setTag('graphql.source', docSource)
@@ -23,7 +26,9 @@ class GraphQLParsePlugin extends TracingPlugin {
23
26
 
24
27
  this.config.hooks.parse(span, source, document)
25
28
 
26
- super.finish()
29
+ super.finish(ctx)
30
+
31
+ return ctx.parentStore
27
32
  }
28
33
  }
29
34
 
@@ -6,28 +6,37 @@ const dc = require('dc-polyfill')
6
6
  const collapsedPathSym = Symbol('collapsedPaths')
7
7
 
8
8
  class GraphQLResolvePlugin extends TracingPlugin {
9
- static get id () { return 'graphql' }
10
- static get operation () { return 'resolve' }
9
+ static id = 'graphql'
10
+ static operation = 'resolve'
11
+
12
+ start (fieldCtx) {
13
+ const { info, rootCtx, args } = fieldCtx
11
14
 
12
- start ({ info, context, args }) {
13
15
  const path = getPath(info, this.config)
14
16
 
17
+ // we need to get the parent span to the field if it exists for correct span parenting
18
+ // of nested fields
19
+ const parentField = getParentField(rootCtx, pathToArray(info && info.path))
20
+ const childOf = parentField?.ctx?.currentStore?.span
21
+
22
+ fieldCtx.parent = parentField
23
+
15
24
  if (!shouldInstrument(this.config, path)) return
16
25
  const computedPathString = path.join('.')
17
26
 
18
27
  if (this.config.collapse) {
19
- if (context.fields[computedPathString]) return
28
+ if (rootCtx.fields[computedPathString]) return
20
29
 
21
- if (!context[collapsedPathSym]) {
22
- context[collapsedPathSym] = {}
23
- } else if (context[collapsedPathSym][computedPathString]) {
30
+ if (!rootCtx[collapsedPathSym]) {
31
+ rootCtx[collapsedPathSym] = {}
32
+ } else if (rootCtx[collapsedPathSym][computedPathString]) {
24
33
  return
25
34
  }
26
35
 
27
- context[collapsedPathSym][computedPathString] = true
36
+ rootCtx[collapsedPathSym][computedPathString] = true
28
37
  }
29
38
 
30
- const document = context.source
39
+ const document = rootCtx.source
31
40
  const fieldNode = info.fieldNodes.find(fieldNode => fieldNode.kind === 'Field')
32
41
  const loc = this.config.source && document && fieldNode && fieldNode.loc
33
42
  const source = loc && document.slice(loc.start, loc.end)
@@ -35,6 +44,7 @@ class GraphQLResolvePlugin extends TracingPlugin {
35
44
  const span = this.startSpan('graphql.resolve', {
36
45
  service: this.config.service,
37
46
  resource: `${info.fieldName}:${info.returnType}`,
47
+ childOf,
38
48
  type: 'graphql',
39
49
  meta: {
40
50
  'graphql.field.name': info.fieldName,
@@ -42,7 +52,7 @@ class GraphQLResolvePlugin extends TracingPlugin {
42
52
  'graphql.field.type': info.returnType.name,
43
53
  'graphql.source': source
44
54
  }
45
- })
55
+ }, fieldCtx)
46
56
 
47
57
  if (fieldNode && this.config.variables && fieldNode.arguments) {
48
58
  const variables = this.config.variables(info.variableValues)
@@ -56,21 +66,25 @@ class GraphQLResolvePlugin extends TracingPlugin {
56
66
  }
57
67
 
58
68
  if (this.resolverStartCh.hasSubscribers) {
59
- this.resolverStartCh.publish({ context, resolverInfo: getResolverInfo(info, args) })
69
+ this.resolverStartCh.publish({ ctx: rootCtx, resolverInfo: getResolverInfo(info, args) })
60
70
  }
71
+
72
+ return fieldCtx.currentStore
61
73
  }
62
74
 
63
75
  constructor (...args) {
64
76
  super(...args)
65
77
 
66
- this.addTraceSub('updateField', ({ field, info, err }) => {
78
+ this.addTraceSub('updateField', (ctx) => {
79
+ const { field, info, error } = ctx
80
+
67
81
  const path = getPath(info, this.config)
68
82
 
69
83
  if (!shouldInstrument(this.config, path)) return
70
84
 
71
- const span = this.activeSpan
85
+ const span = ctx?.currentStore?.span || this.activeSpan
72
86
  field.finishTime = span._getTime ? span._getTime() : 0
73
- field.error = field.error || err
87
+ field.error = field.error || error
74
88
  })
75
89
 
76
90
  this.resolverStartCh = dc.channel('datadog:graphql:resolver:start')
@@ -81,8 +95,13 @@ class GraphQLResolvePlugin extends TracingPlugin {
81
95
  super.configure(config.depth === 0 ? false : config)
82
96
  }
83
97
 
84
- finish (finishTime) {
85
- this.activeSpan.finish(finishTime)
98
+ finish (ctx) {
99
+ const { finishTime } = ctx
100
+
101
+ const span = ctx?.currentStore?.span || this.activeSpan
102
+ span.finish(finishTime)
103
+
104
+ return ctx.parentStore
86
105
  }
87
106
  }
88
107
 
@@ -154,4 +173,19 @@ function getResolverInfo (info, args) {
154
173
  return resolverInfo
155
174
  }
156
175
 
176
+ function getParentField (parentCtx, path) {
177
+ for (let i = path.length - 1; i > 0; i--) {
178
+ const field = getField(parentCtx, path.slice(0, i))
179
+ if (field) {
180
+ return field
181
+ }
182
+ }
183
+
184
+ return null
185
+ }
186
+
187
+ function getField (parentCtx, path) {
188
+ return parentCtx.fields[path.join('.')]
189
+ }
190
+
157
191
  module.exports = GraphQLResolvePlugin
@@ -4,10 +4,11 @@ const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
4
  const { extractErrorIntoSpanEvent } = require('./utils')
5
5
 
6
6
  class GraphQLValidatePlugin extends TracingPlugin {
7
- static get id () { return 'graphql' }
8
- static get operation () { return 'validate' }
7
+ static id = 'graphql'
8
+ static operation = 'validate'
9
9
 
10
- start ({ docSource, document }) {
10
+ bindStart (ctx) {
11
+ const { docSource, document } = ctx
11
12
  const source = this.config.source && document && docSource
12
13
 
13
14
  this.startSpan('graphql.validate', {
@@ -16,18 +17,23 @@ class GraphQLValidatePlugin extends TracingPlugin {
16
17
  meta: {
17
18
  'graphql.source': source
18
19
  }
19
- })
20
+ }, ctx)
21
+
22
+ return ctx.currentStore
20
23
  }
21
24
 
22
- finish ({ document, errors }) {
23
- const span = this.activeSpan
25
+ finish (ctx) {
26
+ const { document, errors } = ctx
27
+ const span = ctx?.currentStore?.span || this.activeSpan
24
28
  this.config.hooks.validate(span, document, errors)
25
29
  if (errors) {
26
30
  for (const err of errors) {
27
31
  extractErrorIntoSpanEvent(this._tracerConfig, span, err)
28
32
  }
29
33
  }
30
- super.finish()
34
+ super.finish(ctx)
35
+
36
+ return ctx.parentStore
31
37
  }
32
38
  }
33
39
 
@@ -6,10 +6,10 @@ const { TEXT_MAP } = require('../../../ext/formats')
6
6
  const { addMetadataTags, getFilter, getMethodMetadata } = require('./util')
7
7
 
8
8
  class GrpcClientPlugin extends ClientPlugin {
9
- static get id () { return 'grpc' }
10
- static get operation () { return 'client:request' }
11
- static get prefix () { return 'apm:grpc:client:request' }
12
- static get peerServicePrecursors () { return ['rpc.service'] }
9
+ static id = 'grpc'
10
+ static operation = 'client:request'
11
+ static prefix = 'apm:grpc:client:request'
12
+ static peerServicePrecursors = ['rpc.service']
13
13
 
14
14
  constructor (...args) {
15
15
  super(...args)
@@ -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 id () { return 'grpc' }
8
+ static id = 'grpc'
9
9
  static get plugins () {
10
10
  return {
11
11
  server: GrpcServerPlugin,
@@ -6,9 +6,9 @@ const { TEXT_MAP } = require('../../../ext/formats')
6
6
  const { addMetadataTags, getFilter, getMethodMetadata } = require('./util')
7
7
 
8
8
  class GrpcServerPlugin extends ServerPlugin {
9
- static get id () { return 'grpc' }
10
- static get operation () { return 'server:request' }
11
- static get prefix () { return 'apm:grpc:server:request' }
9
+ static id = 'grpc'
10
+ static operation = 'server:request'
11
+ static prefix = 'apm:grpc:server:request'
12
12
 
13
13
  constructor (...args) {
14
14
  super(...args)
@@ -5,9 +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 id () {
9
- return 'hapi'
10
- }
8
+ static id = 'hapi'
11
9
 
12
10
  constructor (...args) {
13
11
  super(...args)