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
@@ -6,7 +6,7 @@ const PrismaClientPlugin = require('./client')
6
6
  const PrismaEnginePlugin = require('./engine')
7
7
 
8
8
  class PrismaPlugin extends CompositePlugin {
9
- static get id () { return 'prisma' }
9
+ static id = 'prisma'
10
10
  static get plugins () {
11
11
  return {
12
12
  client: PrismaClientPlugin,
@@ -4,13 +4,9 @@ const SchemaPlugin = require('../../dd-trace/src/plugins/schema')
4
4
  const SchemaExtractor = require('./schema_iterator')
5
5
 
6
6
  class ProtobufjsPlugin extends SchemaPlugin {
7
- static get id () {
8
- return 'protobufjs'
9
- }
7
+ static id = 'protobufjs'
10
8
 
11
- static get schemaExtractor () {
12
- return SchemaExtractor
13
- }
9
+ static schemaExtractor = SchemaExtractor
14
10
  }
15
11
 
16
12
  module.exports = ProtobufjsPlugin
@@ -5,8 +5,8 @@ const CachePlugin = require('../../dd-trace/src/plugins/cache')
5
5
  const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
6
6
 
7
7
  class RedisPlugin extends CachePlugin {
8
- static get id () { return 'redis' }
9
- static get system () { return 'redis' }
8
+ static id = 'redis'
9
+ static system = 'redis'
10
10
 
11
11
  constructor (...args) {
12
12
  super(...args)
@@ -4,9 +4,7 @@ const RouterPlugin = require('../../datadog-plugin-router/src')
4
4
  const web = require('../../dd-trace/src/plugins/util/web')
5
5
 
6
6
  class RestifyPlugin extends RouterPlugin {
7
- static get id () {
8
- return 'restify'
9
- }
7
+ static id = 'restify'
10
8
 
11
9
  constructor (...args) {
12
10
  super(...args)
@@ -4,7 +4,7 @@ const ConsumerPlugin = require('../../dd-trace/src/plugins/consumer')
4
4
  const { getAmqpMessageSize } = require('../../dd-trace/src/datastreams')
5
5
 
6
6
  class RheaConsumerPlugin extends ConsumerPlugin {
7
- static get id () { return 'rhea' }
7
+ static id = 'rhea'
8
8
 
9
9
  constructor (...args) {
10
10
  super(...args)
@@ -5,7 +5,7 @@ const ConsumerPlugin = require('./consumer')
5
5
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
6
6
 
7
7
  class RheaPlugin extends CompositePlugin {
8
- static get id () { return 'rhea' }
8
+ static id = 'rhea'
9
9
  static get plugins () {
10
10
  return {
11
11
  producer: ProducerPlugin,
@@ -5,8 +5,8 @@ const ProducerPlugin = require('../../dd-trace/src/plugins/producer')
5
5
  const { getAmqpMessageSize, DsmPathwayCodec } = require('../../dd-trace/src/datastreams')
6
6
 
7
7
  class RheaProducerPlugin extends ProducerPlugin {
8
- static get id () { return 'rhea' }
9
- static get operation () { return 'send' }
8
+ static id = 'rhea'
9
+ static operation = 'send'
10
10
 
11
11
  constructor (...args) {
12
12
  super(...args)
@@ -7,9 +7,7 @@ const { storage } = require('../../datadog-core')
7
7
  const { COMPONENT } = require('../../dd-trace/src/constants')
8
8
 
9
9
  class RouterPlugin extends WebPlugin {
10
- static get id () {
11
- return 'router'
12
- }
10
+ static id = 'router'
13
11
 
14
12
  constructor (...args) {
15
13
  super(...args)
@@ -27,9 +27,7 @@ function getTestSpanFromTrace (trace) {
27
27
  }
28
28
 
29
29
  class SeleniumPlugin extends CiPlugin {
30
- static get id () {
31
- return 'selenium'
32
- }
30
+ static id = 'selenium'
33
31
 
34
32
  constructor (...args) {
35
33
  super(...args)
@@ -3,7 +3,7 @@
3
3
  const ServerPlugin = require('../../dd-trace/src/plugins/server')
4
4
 
5
5
  class SharedbPlugin extends ServerPlugin {
6
- static get id () { return 'sharedb' }
6
+ static id = 'sharedb'
7
7
 
8
8
  bindStart (ctx) {
9
9
  const { actionName, request } = ctx
@@ -4,9 +4,9 @@ const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
4
4
  const DatabasePlugin = require('../../dd-trace/src/plugins/database')
5
5
 
6
6
  class TediousPlugin extends DatabasePlugin {
7
- static get id () { return 'tedious' }
8
- static get operation () { return 'request' } // TODO: change to match other database plugins
9
- static get system () { return 'mssql' }
7
+ static id = 'tedious'
8
+ static operation = 'request' // TODO: change to match other database plugins
9
+ static system = 'mssql'
10
10
 
11
11
  bindStart (ctx) {
12
12
  const service = this.serviceName({ pluginConfig: this.config, system: this.system })
@@ -3,10 +3,8 @@
3
3
  const FetchPlugin = require('../../datadog-plugin-fetch/src/index.js')
4
4
 
5
5
  class UndiciPlugin extends FetchPlugin {
6
- static get id () { return 'undici' }
7
- static get prefix () {
8
- return 'tracing:apm:undici:fetch'
9
- }
6
+ static id = 'undici'
7
+ static prefix = 'tracing:apm:undici:fetch'
10
8
  }
11
9
 
12
10
  module.exports = UndiciPlugin
@@ -47,9 +47,7 @@ const { DD_MAJOR } = require('../../../version')
47
47
  const MILLISECONDS_TO_SUBTRACT_FROM_FAILED_TEST_DURATION = 5
48
48
 
49
49
  class VitestPlugin extends CiPlugin {
50
- static get id () {
51
- return 'vitest'
52
- }
50
+ static id = 'vitest'
53
51
 
54
52
  constructor (...args) {
55
53
  super(...args)
@@ -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 WebPlugin extends Plugin {
7
- static get id () {
8
- return 'web'
9
- }
7
+ static id = 'web'
10
8
 
11
9
  configure (config) {
12
10
  return super.configure(web.normalizeConfig(config))
@@ -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 WinstonPlugin extends StructuredLogPlugin {
6
- static get id () {
7
- return 'winston'
8
- }
5
+ class WinstonPlugin extends LogPlugin {
6
+ static id = 'winston'
9
7
  }
10
8
  module.exports = WinstonPlugin
@@ -5,6 +5,7 @@ const dc = require('dc-polyfill')
5
5
  // TODO: use TBD naming convention
6
6
  module.exports = {
7
7
  apolloChannel: dc.tracingChannel('datadog:apollo:request'),
8
+ apolloHttpServerChannel: dc.tracingChannel('datadog:apollo:httpserver'),
8
9
  apolloServerCoreChannel: dc.tracingChannel('datadog:apollo-server-core:request'),
9
10
  bodyParser: dc.channel('datadog:body-parser:read:finish'),
10
11
  childProcessExecutionTracingChannel: dc.tracingChannel('datadog:child_process:execution'),
@@ -14,6 +14,7 @@ const web = require('../plugins/util/web')
14
14
  const {
15
15
  startGraphqlResolve,
16
16
  graphqlMiddlewareChannel,
17
+ apolloHttpServerChannel,
17
18
  apolloChannel,
18
19
  apolloServerCoreChannel
19
20
  } = require('./channels')
@@ -55,7 +56,6 @@ function enterInApolloMiddleware (data) {
55
56
  if (!req) return
56
57
 
57
58
  graphqlRequestData.set(req, {
58
- inApolloMiddleware: true,
59
59
  blocked: false
60
60
  })
61
61
  }
@@ -70,17 +70,13 @@ function enterInApolloServerCoreRequest () {
70
70
  })
71
71
  }
72
72
 
73
- function exitFromApolloMiddleware (data) {
74
- const req = data?.req || storage('legacy').getStore()?.req
75
- const requestData = graphqlRequestData.get(req)
76
- if (requestData) requestData.inApolloMiddleware = false
77
- }
78
-
79
73
  function enterInApolloRequest () {
80
74
  const req = storage('legacy').getStore()?.req
81
75
 
82
76
  const requestData = graphqlRequestData.get(req)
83
- if (requestData?.inApolloMiddleware) {
77
+ if (requestData) {
78
+ // Set isInGraphqlRequest=true since this function only runs for GraphQL requests
79
+ // This works for both Apollo v4 (middleware) and v5 (HTTP server) contexts
84
80
  requestData.isInGraphqlRequest = true
85
81
  addSpecificEndpoint(req.method, req.originalUrl || req.url, specificBlockingTypes.GRAPHQL)
86
82
  }
@@ -118,8 +114,7 @@ function beforeWriteApolloGraphqlResponse ({ abortController, abortData }) {
118
114
 
119
115
  function enableApollo () {
120
116
  graphqlMiddlewareChannel.subscribe({
121
- start: enterInApolloMiddleware,
122
- end: exitFromApolloMiddleware
117
+ start: enterInApolloMiddleware
123
118
  })
124
119
 
125
120
  apolloServerCoreChannel.subscribe({
@@ -131,12 +126,15 @@ function enableApollo () {
131
126
  start: enterInApolloRequest,
132
127
  asyncEnd: beforeWriteApolloGraphqlResponse
133
128
  })
129
+
130
+ apolloHttpServerChannel.subscribe({
131
+ start: enterInApolloMiddleware
132
+ })
134
133
  }
135
134
 
136
135
  function disableApollo () {
137
136
  graphqlMiddlewareChannel.unsubscribe({
138
- start: enterInApolloMiddleware,
139
- end: exitFromApolloMiddleware
137
+ start: enterInApolloMiddleware
140
138
  })
141
139
 
142
140
  apolloServerCoreChannel.unsubscribe({
@@ -148,6 +146,10 @@ function disableApollo () {
148
146
  start: enterInApolloRequest,
149
147
  asyncEnd: beforeWriteApolloGraphqlResponse
150
148
  })
149
+
150
+ apolloHttpServerChannel.unsubscribe({
151
+ start: enterInApolloMiddleware
152
+ })
151
153
  }
152
154
 
153
155
  function enableGraphql () {
@@ -180,7 +180,7 @@ class TaintTrackingPlugin extends SourceIastPlugin {
180
180
  { channelName: 'apm:graphql:resolve:start', tag: HTTP_REQUEST_BODY },
181
181
  (data) => {
182
182
  const iastContext = getIastContext(storage('legacy').getStore())
183
- const source = data.context?.source
183
+ const source = data.rootCtx?.source
184
184
  const ranges = source && getRanges(iastContext, source)
185
185
  if (ranges?.length) {
186
186
  this._taintTrackingHandler(ranges[0].iinfo.type, data.args, null, iastContext)
@@ -7,7 +7,7 @@ const WAFContextWrapper = require('./waf_context_wrapper')
7
7
  const contexts = new WeakMap()
8
8
 
9
9
  class WAFManager {
10
- static get defaultWafConfigPath () { return 'datadog/00/ASM_DD/default/config' }
10
+ static defaultWafConfigPath = 'datadog/00/ASM_DD/default/config'
11
11
 
12
12
  constructor (rules, config) {
13
13
  this.config = config
@@ -36,9 +36,7 @@ function getWinstonLogSubmissionParameters (config) {
36
36
  }
37
37
 
38
38
  class LogSubmissionPlugin extends Plugin {
39
- static get id () {
40
- return 'log-submission'
41
- }
39
+ static id = 'log-submission'
42
40
 
43
41
  constructor (...args) {
44
42
  super(...args)
@@ -9,9 +9,7 @@ const {
9
9
  const { storage } = require('../../../../datadog-core')
10
10
 
11
11
  class TestApiManualPlugin extends CiPlugin {
12
- static get id () {
13
- return 'test-api-manual'
14
- }
12
+ static id = 'test-api-manual'
15
13
 
16
14
  constructor (...args) {
17
15
  super(...args)
@@ -571,7 +571,7 @@ class Config {
571
571
  defaults.testManagementAttemptToFixRetries = 20
572
572
  defaults.isTestManagementEnabled = false
573
573
  defaults.isImpactedTestsEnabled = false
574
- defaults.logInjection = 'structured'
574
+ defaults.logInjection = true
575
575
  defaults.lookup = undefined
576
576
  defaults.inferredProxyServicesEnabled = false
577
577
  defaults.memcachedCommandEnabled = false
@@ -9,6 +9,12 @@ class DataStreamsCheckpointer {
9
9
  this.dsmProcessor = tracer._dataStreamsProcessor
10
10
  }
11
11
 
12
+ /**
13
+ * @param {string} type - The type of the checkpoint, usually the streaming technology being used.
14
+ * Examples include kafka, kinesis, sns etc.
15
+ * @param {string} target - The target of data. This can be a topic, exchange or stream name.
16
+ * @param {Object} carrier - The carrier object to inject context into.
17
+ */
12
18
  setProduceCheckpoint (type, target, carrier) {
13
19
  if (!this.config.dsmEnabled) return
14
20
 
@@ -23,14 +29,29 @@ class DataStreamsCheckpointer {
23
29
  this.tracer.inject(ctx, 'text_map_dsm', carrier)
24
30
  }
25
31
 
26
- setConsumeCheckpoint (type, source, carrier) {
32
+ /**
33
+ * @param {string} type - The type of the checkpoint, usually the streaming technology being used.
34
+ * Examples include kafka, kinesis, sns etc.
35
+ * @param {string} source - The source of data. This can be a topic, exchange or stream name.
36
+ * @param {Object} carrier - The carrier object to extract context from.
37
+ * @param {boolean} [manualCheckpoint=true] - Whether this checkpoint was manually set. Keep true if manually
38
+ * instrumenting. Manual instrumentation always overrides automatic
39
+ * instrumentation in the case a call is both manually and automatically
40
+ * instrumented.
41
+ */
42
+ setConsumeCheckpoint (type, source, carrier, manualCheckpoint = true) {
27
43
  if (!this.config.dsmEnabled) return
28
44
 
29
45
  const parentCtx = this.tracer.extract('text_map_dsm', carrier)
30
46
  DataStreamsContext.setDataStreamsContext(parentCtx)
31
47
 
48
+ const tags = ['type:' + type, 'topic:' + source, 'direction:in']
49
+ if (manualCheckpoint) {
50
+ tags.push('manual_checkpoint:true')
51
+ }
52
+
32
53
  const ctx = this.dsmProcessor.setCheckpoint(
33
- ['type:' + type, 'topic:' + source, 'direction:in', 'manual_checkpoint:true'],
54
+ tags,
34
55
  null,
35
56
  parentCtx,
36
57
  null
@@ -17,8 +17,9 @@ const ENTRY_PARENT_HASH = Buffer.from('0000000000000000', 'hex')
17
17
 
18
18
  class StatsPoint {
19
19
  constructor (hash, parentHash, edgeTags) {
20
- this.hash = hash.readBigUInt64BE()
21
- this.parentHash = parentHash.readBigUInt64BE()
20
+ this.hash = hash.readBigUInt64LE()
21
+ this.parentHash = parentHash.readBigUInt64LE()
22
+
22
23
  this.edgeTags = edgeTags
23
24
  this.edgeLatency = new LogCollapsingLowestDenseDDSketch()
24
25
  this.pathwayLatency = new LogCollapsingLowestDenseDDSketch()
@@ -191,7 +192,7 @@ class DataStreamsProcessor {
191
192
  .addLatencies(checkpoint)
192
193
  // set DSM pathway hash on span to enable related traces feature on DSM tab, convert from buffer to uint64
193
194
  if (span) {
194
- span.setTag(PATHWAY_HASH, checkpoint.hash.readBigUInt64BE(0).toString())
195
+ span.setTag(PATHWAY_HASH, checkpoint.hash.readBigUInt64LE(0).toString())
195
196
  }
196
197
  }
197
198
 
@@ -25,11 +25,9 @@ const ToolHandler = require('./handlers/tool')
25
25
  const VectorStoreHandler = require('./handlers/vectorstore')
26
26
 
27
27
  class BaseLangChainLLMObsPlugin extends LLMObsPlugin {
28
- static get integration () { return 'langchain' }
29
- static get id () { return 'langchain' }
30
- static get prefix () {
31
- return 'tracing:apm:langchain:invoke'
32
- }
28
+ static integration = 'langchain'
29
+ static id = 'langchain'
30
+ static prefix = 'tracing:apm:langchain:invoke'
33
31
 
34
32
  constructor () {
35
33
  super(...arguments)
@@ -150,75 +148,57 @@ class BaseLangChainLLMObsPlugin extends LLMObsPlugin {
150
148
  }
151
149
 
152
150
  class RunnableSequenceInvokePlugin extends BaseLangChainLLMObsPlugin {
153
- static get id () { return 'llmobs_langchain_rs_invoke' }
154
- static get lcType () { return 'chain' }
155
- static get prefix () {
156
- return 'tracing:orchestrion:@langchain/core:RunnableSequence_invoke'
157
- }
151
+ static id = 'llmobs_langchain_rs_invoke'
152
+ static lcType = 'chain'
153
+ static prefix = 'tracing:orchestrion:@langchain/core:RunnableSequence_invoke'
158
154
  }
159
155
 
160
156
  class RunnableSequenceBatchPlugin extends BaseLangChainLLMObsPlugin {
161
- static get id () { return 'llmobs_langchain_rs_batch' }
162
- static get lcType () { return 'chain' }
163
- static get prefix () {
164
- return 'tracing:orchestrion:@langchain/core:RunnableSequence_batch'
165
- }
157
+ static id = 'llmobs_langchain_rs_batch'
158
+ static lcType = 'chain'
159
+ static prefix = 'tracing:orchestrion:@langchain/core:RunnableSequence_batch'
166
160
  }
167
161
 
168
162
  class BaseChatModelGeneratePlugin extends BaseLangChainLLMObsPlugin {
169
- static get id () { return 'llmobs_langchain_chat_model_generate' }
170
- static get lcType () { return 'chat_model' }
171
- static get prefix () {
172
- return 'tracing:orchestrion:@langchain/core:BaseChatModel_generate'
173
- }
163
+ static id = 'llmobs_langchain_chat_model_generate'
164
+ static lcType = 'chat_model'
165
+ static prefix = 'tracing:orchestrion:@langchain/core:BaseChatModel_generate'
174
166
  }
175
167
 
176
168
  class BaseLLMGeneratePlugin extends BaseLangChainLLMObsPlugin {
177
- static get id () { return 'llmobs_langchain_llm_generate' }
178
- static get lcType () { return 'llm' }
179
- static get prefix () {
180
- return 'tracing:orchestrion:@langchain/core:BaseLLM_generate'
181
- }
169
+ static id = 'llmobs_langchain_llm_generate'
170
+ static lcType = 'llm'
171
+ static prefix = 'tracing:orchestrion:@langchain/core:BaseLLM_generate'
182
172
  }
183
173
 
184
174
  class EmbeddingsEmbedQueryPlugin extends BaseLangChainLLMObsPlugin {
185
- static get id () { return 'llmobs_langchain_embeddings_embed_query' }
186
- static get lcType () { return 'embedding' }
187
- static get prefix () {
188
- return 'tracing:apm:@langchain/core:Embeddings_embedQuery'
189
- }
175
+ static id = 'llmobs_langchain_embeddings_embed_query'
176
+ static lcType = 'embedding'
177
+ static prefix = 'tracing:apm:@langchain/core:Embeddings_embedQuery'
190
178
  }
191
179
 
192
180
  class EmbeddingsEmbedDocumentsPlugin extends BaseLangChainLLMObsPlugin {
193
- static get id () { return 'llmobs_langchain_embeddings_embed_documents' }
194
- static get lcType () { return 'embedding' }
195
- static get prefix () {
196
- return 'tracing:apm:@langchain/core:Embeddings_embedDocuments'
197
- }
181
+ static id = 'llmobs_langchain_embeddings_embed_documents'
182
+ static lcType = 'embedding'
183
+ static prefix = 'tracing:apm:@langchain/core:Embeddings_embedDocuments'
198
184
  }
199
185
 
200
186
  class ToolInvokePlugin extends BaseLangChainLLMObsPlugin {
201
- static get id () { return 'llmobs_langchain_tool_invoke' }
202
- static get lcType () { return 'tool' }
203
- static get prefix () {
204
- return 'tracing:orchestrion:@langchain/core:Tool_invoke'
205
- }
187
+ static id = 'llmobs_langchain_tool_invoke'
188
+ static lcType = 'tool'
189
+ static prefix = 'tracing:orchestrion:@langchain/core:Tool_invoke'
206
190
  }
207
191
 
208
192
  class VectorStoreSimilaritySearchPlugin extends BaseLangChainLLMObsPlugin {
209
- static get id () { return 'llmobs_langchain_vectorstore_similarity_search' }
210
- static get lcType () { return 'similarity_search' }
211
- static get prefix () {
212
- return 'tracing:orchestrion:@langchain/core:VectorStore_similaritySearch'
213
- }
193
+ static id = 'llmobs_langchain_vectorstore_similarity_search'
194
+ static lcType = 'similarity_search'
195
+ static prefix = 'tracing:orchestrion:@langchain/core:VectorStore_similaritySearch'
214
196
  }
215
197
 
216
198
  class VectorStoreSimilaritySearchWithScorePlugin extends BaseLangChainLLMObsPlugin {
217
- static get id () { return 'llmobs_langchain_vectorstore_similarity_search_with_score' }
218
- static get lcType () { return 'similarity_search' }
219
- static get prefix () {
220
- return 'tracing:orchestrion:@langchain/core:VectorStore_similaritySearchWithScore'
221
- }
199
+ static id = 'llmobs_langchain_vectorstore_similarity_search_with_score'
200
+ static lcType = 'similarity_search'
201
+ static prefix = 'tracing:orchestrion:@langchain/core:VectorStore_similaritySearchWithScore'
222
202
  }
223
203
 
224
204
  module.exports = [
@@ -10,11 +10,9 @@ function isIterable (obj) {
10
10
  }
11
11
 
12
12
  class OpenAiLLMObsPlugin extends LLMObsPlugin {
13
- static get id () { return 'openai' }
14
- static get integration () { return 'openai' }
15
- static get prefix () {
16
- return 'tracing:apm:openai:request'
17
- }
13
+ static id = 'openai'
14
+ static integration = 'openai'
15
+ static prefix = 'tracing:apm:openai:request'
18
16
 
19
17
  getLLMObsSpanRegisterOptions (ctx) {
20
18
  const resource = ctx.methodName
@@ -7,11 +7,9 @@ const {
7
7
  } = require('../../../../datadog-plugin-google-cloud-vertexai/src/utils')
8
8
 
9
9
  class VertexAILLMObsPlugin extends LLMObsPlugin {
10
- static get integration () { return 'vertexai' } // used for llmobs telemetry
11
- static get id () { return 'vertexai' }
12
- static get prefix () {
13
- return 'tracing:apm:vertexai:request'
14
- }
10
+ static integration = 'vertexai' // used for llmobs telemetry
11
+ static id = 'vertexai'
12
+ static prefix = 'tracing:apm:vertexai:request'
15
13
 
16
14
  getLLMObsSpanRegisterOptions (ctx) {
17
15
  const history = ctx.instance?.historyInternal || []
@@ -8,9 +8,12 @@ const TraceState = require('./tracestate')
8
8
  const tags = require('../../../../../ext/tags')
9
9
  const { channel } = require('dc-polyfill')
10
10
  const { setBaggageItem, getAllBaggageItems, removeAllBaggageItems } = require('../../baggage')
11
+ const telemetryMetrics = require('../../telemetry/metrics')
11
12
 
12
13
  const { AUTO_KEEP, AUTO_REJECT, USER_KEEP } = require('../../../../../ext/priority')
13
14
 
15
+ const tracerMetrics = telemetryMetrics.manager.namespace('tracers')
16
+
14
17
  const injectCh = channel('dd-trace:span:inject')
15
18
  const extractCh = channel('dd-trace:span:extract')
16
19
 
@@ -142,12 +145,27 @@ class TextMapPropagator {
142
145
  const item = `${this._encodeOtelBaggageKey(String(key).trim())}=${encodeURIComponent(String(value).trim())},`
143
146
  itemCounter += 1
144
147
  byteCounter += Buffer.byteLength(item)
145
- if (itemCounter > this._config.baggageMaxItems || byteCounter > this._config.baggageMaxBytes) break
148
+
149
+ // Check for item count limit exceeded
150
+ if (itemCounter > this._config.baggageMaxItems) {
151
+ tracerMetrics.count('context_header_style.truncated', ['truncation_reason:baggage_item_count_exceeded']).inc()
152
+ break
153
+ }
154
+
155
+ // Check for byte count limit exceeded
156
+ if (byteCounter > this._config.baggageMaxBytes) {
157
+ tracerMetrics.count('context_header_style.truncated', ['truncation_reason:baggage_byte_count_exceeded']).inc()
158
+ break
159
+ }
160
+
146
161
  baggage += item
147
162
  }
148
163
 
149
164
  baggage = baggage.slice(0, -1)
150
- if (baggage) carrier.baggage = baggage
165
+ if (baggage) {
166
+ carrier.baggage = baggage
167
+ tracerMetrics.count('context_header_style.injected', ['header_style:baggage']).inc()
168
+ }
151
169
  }
152
170
  }
153
171
 
@@ -635,6 +653,7 @@ class TextMapPropagator {
635
653
  : new Set(this._config.baggageTagKeys.split(','))
636
654
  for (const keyValue of baggages) {
637
655
  if (!keyValue.includes('=')) {
656
+ tracerMetrics.count('context_header_style.malformed', ['header_style:baggage']).inc()
638
657
  removeAllBaggageItems()
639
658
  return
640
659
  }
@@ -642,6 +661,7 @@ class TextMapPropagator {
642
661
  key = this._decodeOtelBaggageKey(key.trim())
643
662
  value = decodeURIComponent(value.trim())
644
663
  if (!key || !value) {
664
+ tracerMetrics.count('context_header_style.malformed', ['header_style:baggage']).inc()
645
665
  removeAllBaggageItems()
646
666
  return
647
667
  }
@@ -650,6 +670,9 @@ class TextMapPropagator {
650
670
  }
651
671
  setBaggageItem(key, value)
652
672
  }
673
+
674
+ // Successfully extracted baggage
675
+ tracerMetrics.count('context_header_style.extracted', ['header_style:baggage']).inc()
653
676
  }
654
677
 
655
678
  _extractSamplingPriority (carrier, spanContext) {
@@ -4,9 +4,9 @@ const TracingPlugin = require('./tracing')
4
4
  const { storage } = require('../../../datadog-core')
5
5
 
6
6
  class ApolloBasePlugin extends TracingPlugin {
7
- static get id () { return 'apollo.gateway' }
8
- static get type () { return 'web' }
9
- static get kind () { return 'server' }
7
+ static id = 'apollo.gateway'
8
+ static type = 'web'
9
+ static kind = 'server'
10
10
 
11
11
  bindStart (ctx) {
12
12
  const store = storage('legacy').getStore()
@@ -3,7 +3,7 @@
3
3
  const StoragePlugin = require('./storage')
4
4
 
5
5
  class CachePlugin extends StoragePlugin {
6
- static get operation () { return 'command' }
6
+ static operation = 'command'
7
7
 
8
8
  startSpan (options, ctx) {
9
9
  if (!options.kind) {
@@ -3,9 +3,9 @@
3
3
  const OutboundPlugin = require('./outbound')
4
4
 
5
5
  class ClientPlugin extends OutboundPlugin {
6
- static get operation () { return 'request' }
7
- static get kind () { return 'client' }
8
- static get type () { return 'web' } // overridden by storage and other client type plugins
6
+ static operation = 'request'
7
+ static kind = 'client'
8
+ static type = 'web' // overridden by storage and other client type plugins
9
9
  }
10
10
 
11
11
  module.exports = ClientPlugin