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
@@ -0,0 +1,28 @@
1
+ 'use strict'
2
+
3
+ const { parseModelId } = require('../../datadog-plugin-aws-sdk/src/services/bedrockruntime/utils')
4
+
5
+ /**
6
+ * Get the model provider from the span tags or attributes.
7
+ * This is normalized to LLM Observability model provider standards.
8
+ *
9
+ * @param {Record<string, string>} tags
10
+ * @returns {string}
11
+ */
12
+ function getModelProvider (tags) {
13
+ const modelProviderTag = tags['ai.model.provider']
14
+ const providerParts = modelProviderTag?.split('.')
15
+ const provider = providerParts?.[0]
16
+
17
+ if (provider === 'amazon-bedrock') {
18
+ const modelId = tags['ai.model.id']
19
+ const model = modelId && parseModelId(modelId)
20
+ return model?.modelProvider ?? provider
21
+ }
22
+
23
+ return provider
24
+ }
25
+
26
+ module.exports = {
27
+ getModelProvider
28
+ }
@@ -4,8 +4,8 @@ const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
4
4
  const { getAddress, getShortName } = require('./util')
5
5
 
6
6
  class Amqp10ConsumerPlugin extends ConsumerPlugin {
7
- static get id () { return 'amqp10' }
8
- static get system () { return 'amqp' }
7
+ static id = 'amqp10'
8
+ static system = 'amqp'
9
9
 
10
10
  bindStart (ctx) {
11
11
  const { link } = ctx
@@ -5,7 +5,7 @@ const ConsumerPlugin = require('./consumer')
5
5
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
6
6
 
7
7
  class Amqp10Plugin extends CompositePlugin {
8
- static get id () { return 'amqp10' }
8
+ static id = 'amqp10'
9
9
  static get plugins () {
10
10
  return {
11
11
  producer: ProducerPlugin,
@@ -5,9 +5,9 @@ const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
5
5
  const { getAddress, getShortName } = require('./util')
6
6
 
7
7
  class Amqp10ProducerPlugin extends ProducerPlugin {
8
- static get id () { return 'amqp10' }
9
- static get operation () { return 'send' }
10
- static get system () { return 'amqp' }
8
+ static id = 'amqp10'
9
+ static operation = 'send'
10
+ static system = 'amqp'
11
11
 
12
12
  bindStart (ctx) {
13
13
  const { link } = ctx
@@ -6,9 +6,9 @@ const ClientPlugin = require('../../dd-trace/src/plugins/client')
6
6
  const { getResourceName } = require('./util')
7
7
 
8
8
  class AmqplibClientPlugin extends ClientPlugin {
9
- static get id () { return 'amqplib' }
10
- static get type () { return 'messaging' }
11
- static get operation () { return 'command' }
9
+ static id = 'amqplib'
10
+ static type = 'messaging'
11
+ static operation = 'command'
12
12
 
13
13
  bindStart (ctx) {
14
14
  const { channel = {}, method, fields } = ctx
@@ -6,8 +6,8 @@ const { getAmqpMessageSize } = require('../../dd-trace/src/datastreams')
6
6
  const { getResourceName } = require('./util')
7
7
 
8
8
  class AmqplibConsumerPlugin extends ConsumerPlugin {
9
- static get id () { return 'amqplib' }
10
- static get operation () { return 'consume' }
9
+ static id = 'amqplib'
10
+ static operation = 'consume'
11
11
 
12
12
  bindStart (ctx) {
13
13
  const { method, fields, message, queue } = 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 AmqplibPlugin extends CompositePlugin {
10
- static get id () { return 'amqplib' }
10
+ static id = 'amqplib'
11
11
  static get plugins () {
12
12
  return {
13
13
  producer: ProducerPlugin,
@@ -7,8 +7,8 @@ const { DsmPathwayCodec, getAmqpMessageSize } = require('../../dd-trace/src/data
7
7
  const { getResourceName } = require('./util')
8
8
 
9
9
  class AmqplibProducerPlugin extends ProducerPlugin {
10
- static get id () { return 'amqplib' }
11
- static get operation () { return 'publish' }
10
+ static id = 'amqplib'
11
+ static operation = 'publish'
12
12
 
13
13
  bindStart (ctx) {
14
14
  const { channel = {}, method, fields, message } = ctx
@@ -3,10 +3,8 @@
3
3
  const ApolloBasePlugin = require('../../../dd-trace/src/plugins/apollo')
4
4
 
5
5
  class ApolloGatewayExecutePlugin extends ApolloBasePlugin {
6
- static get operation () { return 'execute' }
7
- static get prefix () {
8
- return 'tracing:apm:apollo:gateway:execute'
9
- }
6
+ static operation = 'execute'
7
+ static prefix = 'tracing:apm:apollo:gateway:execute'
10
8
  }
11
9
 
12
10
  module.exports = ApolloGatewayExecutePlugin
@@ -4,10 +4,8 @@ const { storage } = require('../../../datadog-core')
4
4
  const ApolloBasePlugin = require('../../../dd-trace/src/plugins/apollo')
5
5
 
6
6
  class ApolloGatewayFetchPlugin extends ApolloBasePlugin {
7
- static get operation () { return 'fetch' }
8
- static get prefix () {
9
- return 'tracing:apm:apollo:gateway:fetch'
10
- }
7
+ static operation = 'fetch'
8
+ static prefix = 'tracing:apm:apollo:gateway:fetch'
11
9
 
12
10
  bindStart (ctx) {
13
11
  const store = storage('legacy').getStore()
@@ -10,7 +10,7 @@ const ApolloGatewayValidatePlugin = require('./validate')
10
10
  const ApolloGatewayFetchPlugin = require('./fetch')
11
11
 
12
12
  class ApolloGatewayPlugin extends CompositePlugin {
13
- static get id () { return 'gateway' }
13
+ static id = 'gateway'
14
14
  static get plugins () {
15
15
  return {
16
16
  execute: ApolloGatewayExecutePlugin,
@@ -3,10 +3,8 @@
3
3
  const ApolloBasePlugin = require('../../../dd-trace/src/plugins/apollo')
4
4
 
5
5
  class ApolloGatewayPlanPlugin extends ApolloBasePlugin {
6
- static get operation () { return 'plan' }
7
- static get prefix () {
8
- return 'tracing:apm:apollo:gateway:plan'
9
- }
6
+ static operation = 'plan'
7
+ static prefix = 'tracing:apm:apollo:gateway:plan'
10
8
  }
11
9
 
12
10
  module.exports = ApolloGatewayPlanPlugin
@@ -3,10 +3,8 @@
3
3
  const ApolloBasePlugin = require('../../../dd-trace/src/plugins/apollo')
4
4
 
5
5
  class ApolloGatewayPostProcessingPlugin extends ApolloBasePlugin {
6
- static get operation () { return 'postprocessing' }
7
- static get prefix () {
8
- return 'tracing:apm:apollo:gateway:postprocessing'
9
- }
6
+ static operation = 'postprocessing'
7
+ static prefix = 'tracing:apm:apollo:gateway:postprocessing'
10
8
  }
11
9
 
12
10
  module.exports = ApolloGatewayPostProcessingPlugin
@@ -9,10 +9,8 @@ const OPERATION_DEFINITION = 'OperationDefinition'
9
9
  const FRAGMENT_DEFINITION = 'FragmentDefinition'
10
10
 
11
11
  class ApolloGatewayRequestPlugin extends ApolloBasePlugin {
12
- static get operation () { return 'request' }
13
- static get prefix () {
14
- return 'tracing:apm:apollo:gateway:request'
15
- }
12
+ static operation = 'request'
13
+ static prefix = 'tracing:apm:apollo:gateway:request'
16
14
 
17
15
  bindStart (ctx) {
18
16
  const store = storage('legacy').getStore()
@@ -3,10 +3,8 @@
3
3
  const ApolloBasePlugin = require('../../../dd-trace/src/plugins/apollo')
4
4
 
5
5
  class ApolloGatewayValidatePlugin extends ApolloBasePlugin {
6
- static get operation () { return 'validate' }
7
- static get prefix () {
8
- return 'tracing:apm:apollo:gateway:validate'
9
- }
6
+ static operation = 'validate'
7
+ static prefix = 'tracing:apm:apollo:gateway:validate'
10
8
 
11
9
  end (ctx) {
12
10
  const result = ctx.result
@@ -4,7 +4,7 @@ const CompositePlugin = require('../../dd-trace/src/plugins/composite')
4
4
  const ApolloGatewayPlugin = require('./gateway')
5
5
 
6
6
  class ApolloPlugin extends CompositePlugin {
7
- static get id () { return 'apollo' }
7
+ static id = 'apollo'
8
8
  static get plugins () {
9
9
  return {
10
10
  gateway: ApolloGatewayPlugin
@@ -4,8 +4,8 @@ const SchemaPlugin = require('../../dd-trace/src/plugins/schema')
4
4
  const SchemaExtractor = require('./schema_iterator')
5
5
 
6
6
  class AvscPlugin extends SchemaPlugin {
7
- static get id () { return 'avsc' }
8
- static get schemaExtractor () { return SchemaExtractor }
7
+ static id = 'avsc'
8
+ static schemaExtractor = SchemaExtractor
9
9
  }
10
10
 
11
11
  module.exports = AvscPlugin
@@ -9,8 +9,8 @@ const { tagsFromRequest, tagsFromResponse } = require('../../dd-trace/src/payloa
9
9
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
10
10
 
11
11
  class BaseAwsSdkPlugin extends ClientPlugin {
12
- static get id () { return 'aws' }
13
- static get isPayloadReporter () { return false }
12
+ static id = 'aws'
13
+ static isPayloadReporter = false
14
14
 
15
15
  get serviceIdentifier () {
16
16
  const id = this.constructor.id.toLowerCase()
@@ -34,17 +34,26 @@ class BaseAwsSdkPlugin extends ClientPlugin {
34
34
  constructor (...args) {
35
35
  super(...args)
36
36
 
37
- this.addSub(`apm:aws:request:start:${this.serviceIdentifier}`, ({
38
- request,
39
- operation,
40
- awsRegion,
41
- awsService
42
- }) => {
37
+ this._parentMap = new WeakMap()
38
+
39
+ this.addBind(`apm:aws:request:start:${this.serviceIdentifier}`, (ctx) => {
40
+ const {
41
+ request,
42
+ operation,
43
+ awsRegion,
44
+ awsService
45
+ } = ctx
46
+
47
+ const parentStore = ctx.parentStore = storage('legacy').getStore()
48
+ const childOf = parentStore?.span
49
+
50
+ this._parentMap.set(request, parentStore)
51
+
43
52
  if (!this.isEnabled(request)) {
44
- return
53
+ return parentStore
45
54
  }
46
- const childOf = this.tracer.scope().active()
47
- const tags = {
55
+
56
+ const meta = {
48
57
  'span.kind': 'client',
49
58
  'service.name': this.serviceName(),
50
59
  'aws.operation': operation,
@@ -54,18 +63,19 @@ class BaseAwsSdkPlugin extends ClientPlugin {
54
63
  'aws.service': awsService,
55
64
  component: 'aws-sdk'
56
65
  }
57
- if (this.requestTags) this.requestTags.set(request, tags)
66
+ if (this.requestTags) this.requestTags.set(request, meta)
58
67
 
59
- const span = this.tracer.startSpan(this.operationFromRequest(request),
60
- {
61
- childOf,
62
- tags,
63
- integrationName: 'aws-sdk'
64
- })
68
+ const span = this.startSpan(this.operationFromRequest(request), {
69
+ childOf,
70
+ meta,
71
+ integrationName: 'aws-sdk'
72
+ }, ctx)
65
73
 
66
74
  analyticsSampler.sample(span, this.config.measured)
67
75
 
68
- this.requestInject(span, request)
76
+ storage('legacy').run(ctx.currentStore, () => {
77
+ this.requestInject(span, request)
78
+ })
69
79
 
70
80
  if (this.constructor.isPayloadReporter && this.cloudTaggingConfig.requestsEnabled) {
71
81
  const maxDepth = this.cloudTaggingConfig.maxDepth
@@ -73,12 +83,15 @@ class BaseAwsSdkPlugin extends ClientPlugin {
73
83
  span.addTags(requestTags)
74
84
  }
75
85
 
76
- this.enter(span)
77
- const store = storage('legacy').getStore()
86
+ return ctx.currentStore
87
+ })
78
88
 
79
- const peerServerlessStorage = storage('peerServerless')
89
+ this.addSub(`apm:aws:request:start:${this.serviceIdentifier}`, (ctx) => {
80
90
  if (!this._tracerConfig?._isInServerlessEnvironment()) return
81
91
 
92
+ const { awsRegion, awsService, currentStore, request } = ctx
93
+ const peerServerlessStorage = storage('peerServerless')
94
+
82
95
  // Try to resolve the hostname immediately; if not possible, keep enough
83
96
  // information so the region callback can resolve it later.
84
97
  const hostname = getHostname({ awsParams: request.params, awsService }, awsRegion)
@@ -86,15 +99,15 @@ class BaseAwsSdkPlugin extends ClientPlugin {
86
99
  peerServerlessStorage.enterWith(peerServerlessStore)
87
100
 
88
101
  if (hostname) {
89
- span.setTag('peer.service', hostname)
102
+ currentStore.span.setTag('peer.service', hostname)
90
103
  peerServerlessStore.peerHostname = hostname
91
104
  } else {
92
- store.awsParams = request.params
93
- store.awsService = awsService
105
+ currentStore.awsParams = request.params
106
+ currentStore.awsService = awsService
94
107
  }
95
108
  })
96
109
 
97
- this.addSub(`apm:aws:request:region:${this.serviceIdentifier}`, region => {
110
+ this.addSub(`apm:aws:request:region:${this.serviceIdentifier}`, ({ region }) => {
98
111
  const store = storage('legacy').getStore()
99
112
  if (!store) return
100
113
  const { span } = store
@@ -114,24 +127,31 @@ class BaseAwsSdkPlugin extends ClientPlugin {
114
127
  }
115
128
  })
116
129
 
117
- this.addSub(`apm:aws:request:complete:${this.serviceIdentifier}`, ({ response, cbExists = false }) => {
118
- const store = storage('legacy').getStore()
119
- if (!store) return
120
- const { span } = store
130
+ this.addSub(`apm:aws:request:complete:${this.serviceIdentifier}`, ctx => {
131
+ const { response, cbExists = false, currentStore } = ctx
132
+ if (!currentStore) return
133
+ const { span } = currentStore
121
134
  if (!span) return
122
- // try to extract DSM context from response if no callback exists as extraction normally happens in CB
123
- if (!cbExists && this.serviceIdentifier === 'sqs') {
124
- const params = response.request.params
125
- const operation = response.request.operation
126
- this.responseExtractDSMContext(operation, params, response.data ?? response, span)
127
- }
128
- this.addResponseTags(span, response)
129
135
 
130
- if (this._tracerConfig?.trace?.aws?.addSpanPointers) {
131
- this.addSpanPointers(span, response)
132
- }
136
+ storage('legacy').run(currentStore, () => {
137
+ // try to extract DSM context from response if no callback exists as extraction normally happens in CB
138
+ if (!cbExists && this.serviceIdentifier === 'sqs') {
139
+ const params = response.request.params
140
+ const operation = response.request.operation
141
+ this.responseExtractDSMContext(operation, params, response.data ?? response, span)
142
+ }
143
+ this.addResponseTags(span, response)
144
+
145
+ if (this._tracerConfig?.trace?.aws?.addSpanPointers) {
146
+ this.addSpanPointers(span, response)
147
+ }
148
+ })
133
149
 
134
- this.finish(span, response, response.error)
150
+ this.finish(ctx)
151
+ })
152
+
153
+ this.addBind(`apm:aws:response:start:${this.serviceIdentifier}`, ctx => {
154
+ return this._parentMap.get(ctx.request)
135
155
  })
136
156
  }
137
157
 
@@ -205,11 +225,15 @@ class BaseAwsSdkPlugin extends ClientPlugin {
205
225
  // implemented by subclasses, or not
206
226
  }
207
227
 
208
- finish (span, response, err) {
209
- if (err) {
210
- span.setTag('error', err)
228
+ finish (ctx) {
229
+ const { currentStore, response } = ctx
230
+ const { span } = currentStore
231
+ const error = response?.error || ctx.error
232
+
233
+ if (error) {
234
+ span.setTag('error', error)
211
235
 
212
- const requestId = err.RequestId || err.requestId
236
+ const requestId = error.RequestId || error.requestId
213
237
  if (requestId) {
214
238
  span.addTags({ 'aws.response.request_id': requestId })
215
239
  }
@@ -219,7 +243,7 @@ class BaseAwsSdkPlugin extends ClientPlugin {
219
243
  this.config.hooks.request(span, response)
220
244
  }
221
245
 
222
- super.finish()
246
+ super.finish(ctx)
223
247
  }
224
248
 
225
249
  configure (config) {
@@ -5,9 +5,7 @@ const Plugin = require('../../dd-trace/src/plugins/plugin')
5
5
  const services = require('./services')
6
6
 
7
7
  class AwsSdkPlugin extends Plugin {
8
- static get id () {
9
- return 'aws-sdk'
10
- }
8
+ static id = 'aws-sdk'
11
9
 
12
10
  constructor (...args) {
13
11
  super(...args)
@@ -4,9 +4,7 @@ const CompositePlugin = require('../../../../dd-trace/src/plugins/composite')
4
4
  const BedrockRuntimeTracing = require('./tracing')
5
5
  const BedrockRuntimeLLMObsPlugin = require('../../../../dd-trace/src/llmobs/plugins/bedrockruntime')
6
6
  class BedrockRuntimePlugin extends CompositePlugin {
7
- static get id () {
8
- return 'bedrockruntime'
9
- }
7
+ static id = 'bedrockruntime'
10
8
 
11
9
  static get plugins () {
12
10
  return {
@@ -6,7 +6,7 @@ const { parseModelId } = require('./utils')
6
6
  const enabledOperations = new Set(['invokeModel'])
7
7
 
8
8
  class BedrockRuntime extends BaseAwsSdkPlugin {
9
- static get id () { return 'bedrockruntime' }
9
+ static id = 'bedrockruntime'
10
10
 
11
11
  isEnabled (request) {
12
12
  const operation = request.operation
@@ -3,7 +3,7 @@
3
3
  const BaseAwsSdkPlugin = require('../base')
4
4
 
5
5
  class CloudwatchLogs extends BaseAwsSdkPlugin {
6
- static get id () { return 'cloudwatchlogs' }
6
+ static id = 'cloudwatchlogs'
7
7
 
8
8
  generateTags (params, operation) {
9
9
  if (!params?.logGroupName) return {}
@@ -6,9 +6,9 @@ const { DYNAMODB_PTR_KIND, SPAN_POINTER_DIRECTION } = require('../../../dd-trace
6
6
  const { extractPrimaryKeys, generatePointerHash } = require('../util')
7
7
 
8
8
  class DynamoDb extends BaseAwsSdkPlugin {
9
- static get id () { return 'dynamodb' }
10
- static get peerServicePrecursors () { return ['tablename'] }
11
- static get isPayloadReporter () { return true }
9
+ static id = 'dynamodb'
10
+ static peerServicePrecursors = ['tablename']
11
+ static isPayloadReporter = true
12
12
 
13
13
  generateTags (params, operation, response) {
14
14
  const tags = {}
@@ -3,8 +3,8 @@ const log = require('../../../dd-trace/src/log')
3
3
  const BaseAwsSdkPlugin = require('../base')
4
4
 
5
5
  class EventBridge extends BaseAwsSdkPlugin {
6
- static get id () { return 'eventbridge' }
7
- static get isPayloadReporter () { return true }
6
+ static id = 'eventbridge'
7
+ static isPayloadReporter = true
8
8
 
9
9
  generateTags (params, operation, response) {
10
10
  if (!params?.source) return {}
@@ -2,12 +2,11 @@
2
2
  const { DsmPathwayCodec, getSizeOrZero } = require('../../../dd-trace/src/datastreams')
3
3
  const log = require('../../../dd-trace/src/log')
4
4
  const BaseAwsSdkPlugin = require('../base')
5
- const { storage } = require('../../../datadog-core')
6
5
 
7
6
  class Kinesis extends BaseAwsSdkPlugin {
8
- static get id () { return 'kinesis' }
9
- static get peerServicePrecursors () { return ['streamname'] }
10
- static get isPayloadReporter () { return true }
7
+ static id = 'kinesis'
8
+ static peerServicePrecursors = ['streamname']
9
+ static isPayloadReporter = true
11
10
 
12
11
  constructor (...args) {
13
12
  super(...args)
@@ -16,48 +15,50 @@ class Kinesis extends BaseAwsSdkPlugin {
16
15
  // in the base class
17
16
  this.requestTags = new WeakMap()
18
17
 
19
- this.addSub('apm:aws:response:start:kinesis', obj => {
20
- const { request, response } = obj
21
- const store = storage('legacy').getStore()
18
+ this.addBind('apm:aws:response:start:kinesis', ctx => {
19
+ const { request, response } = ctx
22
20
  const plugin = this
23
21
 
22
+ let store = this._parentMap.get(request)
23
+
24
24
  // if we have either of these operations, we want to store the streamName param
25
25
  // since it is not typically available during get/put records requests
26
26
  if (request.operation === 'getShardIterator' || request.operation === 'listShards') {
27
- this.storeStreamName(request.params, request.operation, store)
28
- return
27
+ return this.storeStreamName(request.params, request.operation, store)
29
28
  }
30
29
 
31
30
  if (request.operation === 'getRecords') {
32
31
  let span
33
32
  const responseExtraction = this.responseExtract(request.params, request.operation, response)
34
33
  if (responseExtraction && responseExtraction.maybeChildOf) {
35
- obj.needsFinish = true
34
+ ctx.needsFinish = true
36
35
  const options = {
37
36
  childOf: responseExtraction.maybeChildOf,
38
- tags: {
37
+ meta: {
39
38
  ...this.requestTags.get(request),
40
39
  'span.kind': 'server'
41
40
  },
42
41
  integrationName: 'aws-sdk'
43
42
  }
44
- span = plugin.tracer.startSpan('aws.response', options)
45
- this.enter(span, store)
43
+ span = plugin.startSpan('aws.response', options, ctx)
44
+ store = ctx.currentStore
46
45
  }
47
46
 
48
47
  // get the stream name that should have been stored previously
49
- const { streamName } = storage('legacy').getStore()
48
+ const { streamName } = store
50
49
 
51
50
  // extract DSM context after as we might not have a parent-child but may have a DSM context
52
51
  this.responseExtractDSMContext(
53
52
  request.operation, request.params, response, span || null, { streamName }
54
53
  )
55
54
  }
55
+
56
+ return store
56
57
  })
57
58
 
58
- this.addSub('apm:aws:response:finish:kinesis', err => {
59
- const { span } = storage('legacy').getStore()
60
- this.finish(span, null, err)
59
+ this.addSub('apm:aws:response:finish:kinesis', ctx => {
60
+ if (!ctx.needsFinish) return
61
+ this.finish(ctx)
61
62
  })
62
63
  }
63
64
 
@@ -72,11 +73,12 @@ class Kinesis extends BaseAwsSdkPlugin {
72
73
  }
73
74
 
74
75
  storeStreamName (params, operation, store) {
75
- if (!operation || (operation !== 'getShardIterator' && operation !== 'listShards')) return
76
- if (!params || !params.StreamName) return
76
+ if (!operation) return store
77
+ if (operation !== 'getShardIterator' && operation !== 'listShards') return store
78
+ if (!params || !params.StreamName) return store
77
79
 
78
80
  const streamName = params.StreamName
79
- storage('legacy').enterWith({ ...store, streamName })
81
+ return { ...store, streamName }
80
82
  }
81
83
 
82
84
  responseExtract (params, operation, response) {
@@ -4,7 +4,7 @@ const log = require('../../../dd-trace/src/log')
4
4
  const BaseAwsSdkPlugin = require('../base')
5
5
 
6
6
  class Lambda extends BaseAwsSdkPlugin {
7
- static get id () { return 'lambda' }
7
+ static id = 'lambda'
8
8
 
9
9
  generateTags (params, operation, response) {
10
10
  if (!params?.FunctionName) return {}
@@ -3,7 +3,7 @@
3
3
  const BaseAwsSdkPlugin = require('../base')
4
4
 
5
5
  class Redshift extends BaseAwsSdkPlugin {
6
- static get id () { return 'redshift' }
6
+ static id = 'redshift'
7
7
 
8
8
  generateTags (params, operation, response) {
9
9
  if (!params?.ClusterIdentifier) return {}
@@ -6,9 +6,9 @@ const { generatePointerHash } = require('../util')
6
6
  const { S3_PTR_KIND, SPAN_POINTER_DIRECTION } = require('../../../dd-trace/src/constants')
7
7
 
8
8
  class S3 extends BaseAwsSdkPlugin {
9
- static get id () { return 's3' }
10
- static get peerServicePrecursors () { return ['bucketname'] }
11
- static get isPayloadReporter () { return true }
9
+ static id = 's3'
10
+ static peerServicePrecursors = ['bucketname']
11
+ static isPayloadReporter = true
12
12
 
13
13
  generateTags (params, operation, response) {
14
14
  if (!params?.Bucket) return {}
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
  const Stepfunctions = require('./stepfunctions')
3
3
  class Sfn extends Stepfunctions {
4
- static get id () { return 'sfn' }
4
+ static id = 'sfn'
5
5
  }
6
6
 
7
7
  module.exports = Sfn
@@ -4,9 +4,9 @@ const log = require('../../../dd-trace/src/log')
4
4
  const BaseAwsSdkPlugin = require('../base')
5
5
 
6
6
  class Sns extends BaseAwsSdkPlugin {
7
- static get id () { return 'sns' }
8
- static get peerServicePrecursors () { return ['topicname'] }
9
- static get isPayloadReporter () { return true }
7
+ static id = 'sns'
8
+ static peerServicePrecursors = ['topicname']
9
+ static isPayloadReporter = true
10
10
 
11
11
  generateTags (params, operation, response) {
12
12
  if (!params) return {}