dd-trace 5.109.0 → 5.111.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 (208) hide show
  1. package/README.md +13 -8
  2. package/ci/init.js +25 -5
  3. package/ci/vitest-no-worker-init-setup.mjs +430 -0
  4. package/ext/tags.js +2 -0
  5. package/index.d.ts +79 -24
  6. package/initialize.mjs +5 -6
  7. package/loader-hook.mjs +154 -47
  8. package/package.json +20 -16
  9. package/packages/datadog-esbuild/index.js +26 -0
  10. package/packages/datadog-esbuild/src/utils.js +46 -3
  11. package/packages/datadog-instrumentations/src/connect.js +4 -3
  12. package/packages/datadog-instrumentations/src/fastify.js +4 -12
  13. package/packages/datadog-instrumentations/src/fs.js +8 -6
  14. package/packages/datadog-instrumentations/src/graphql.js +26 -484
  15. package/packages/datadog-instrumentations/src/helpers/check-require-cache.js +81 -8
  16. package/packages/datadog-instrumentations/src/helpers/instrument.js +27 -2
  17. package/packages/datadog-instrumentations/src/helpers/optional-peer-bundler.js +65 -0
  18. package/packages/datadog-instrumentations/src/helpers/register.js +6 -4
  19. package/packages/datadog-instrumentations/src/helpers/require-optional-peer.js +17 -0
  20. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +201 -0
  21. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/index.js +1 -0
  22. package/packages/datadog-instrumentations/src/helpers/rewriter/loader.mjs +18 -2
  23. package/packages/datadog-instrumentations/src/koa.js +3 -2
  24. package/packages/datadog-instrumentations/src/mariadb.js +4 -2
  25. package/packages/datadog-instrumentations/src/mocha/main.js +3 -3
  26. package/packages/datadog-instrumentations/src/mongoose.js +14 -2
  27. package/packages/datadog-instrumentations/src/next.js +10 -10
  28. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +7 -6
  29. package/packages/datadog-instrumentations/src/playwright.js +1 -1
  30. package/packages/datadog-instrumentations/src/restify.js +4 -3
  31. package/packages/datadog-instrumentations/src/router.js +18 -5
  32. package/packages/datadog-instrumentations/src/selenium.js +1 -2
  33. package/packages/datadog-instrumentations/src/tedious.js +28 -0
  34. package/packages/datadog-instrumentations/src/vitest-main-no-worker-init.js +1293 -0
  35. package/packages/datadog-instrumentations/src/vitest-main.js +1567 -0
  36. package/packages/datadog-instrumentations/src/vitest-util.js +249 -0
  37. package/packages/datadog-instrumentations/src/vitest-worker.js +753 -0
  38. package/packages/datadog-instrumentations/src/vitest.js +11 -1598
  39. package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -2
  40. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/client.js +2 -2
  41. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js +18 -10
  42. package/packages/datadog-plugin-aws-durable-execution-sdk-js/src/util.js +47 -11
  43. package/packages/datadog-plugin-aws-sdk/src/base.js +13 -9
  44. package/packages/datadog-plugin-aws-sdk/src/services/eventbridge.js +43 -6
  45. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +83 -91
  46. package/packages/datadog-plugin-cucumber/src/index.js +1 -1
  47. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +19 -5
  48. package/packages/datadog-plugin-cypress/src/support.js +45 -1
  49. package/packages/datadog-plugin-express/src/code_origin.js +1 -1
  50. package/packages/datadog-plugin-fastify/src/code_origin.js +1 -1
  51. package/packages/datadog-plugin-graphql/src/execute.js +627 -11
  52. package/packages/datadog-plugin-graphql/src/index.js +20 -8
  53. package/packages/datadog-plugin-graphql/src/parse.js +24 -4
  54. package/packages/datadog-plugin-graphql/src/validate.js +16 -5
  55. package/packages/datadog-plugin-http/src/client.js +8 -3
  56. package/packages/datadog-plugin-http/src/index.js +6 -8
  57. package/packages/datadog-plugin-http2/src/client.js +5 -2
  58. package/packages/datadog-plugin-jest/src/index.js +1 -1
  59. package/packages/datadog-plugin-mocha/src/index.js +1 -1
  60. package/packages/datadog-plugin-mysql/src/index.js +7 -2
  61. package/packages/datadog-plugin-openai/src/services.js +2 -2
  62. package/packages/datadog-plugin-playwright/src/index.js +1 -1
  63. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -2
  64. package/packages/datadog-plugin-undici/src/index.js +5 -2
  65. package/packages/datadog-plugin-vitest/src/index.js +76 -64
  66. package/packages/datadog-shimmer/src/shimmer.js +37 -16
  67. package/packages/datadog-webpack/index.js +17 -1
  68. package/packages/datadog-webpack/src/optional-peer-loader.js +17 -0
  69. package/packages/dd-trace/src/aiguard/sdk.js +15 -3
  70. package/packages/dd-trace/src/appsec/api_security/index.js +55 -0
  71. package/packages/dd-trace/src/appsec/api_security/sampler.js +147 -0
  72. package/packages/dd-trace/src/appsec/channels.js +3 -1
  73. package/packages/dd-trace/src/appsec/downstream_requests.js +4 -4
  74. package/packages/dd-trace/src/appsec/graphql.js +5 -5
  75. package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +26 -19
  76. package/packages/dd-trace/src/appsec/iast/security-controls/index.js +2 -2
  77. package/packages/dd-trace/src/appsec/iast/telemetry/index.js +2 -1
  78. package/packages/dd-trace/src/appsec/index.js +20 -7
  79. package/packages/dd-trace/src/appsec/lambda.js +135 -0
  80. package/packages/dd-trace/src/appsec/reporter.js +50 -10
  81. package/packages/dd-trace/src/appsec/telemetry/api_security.js +34 -0
  82. package/packages/dd-trace/src/appsec/telemetry/index.js +27 -1
  83. package/packages/dd-trace/src/appsec/waf/index.js +16 -4
  84. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +4 -4
  85. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +21 -6
  86. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +2 -2
  87. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +1 -1
  88. package/packages/dd-trace/src/ci-visibility/exporters/agentless/di-logs-writer.js +1 -1
  89. package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +3 -2
  90. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +1 -1
  91. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +55 -13
  92. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +2 -2
  93. package/packages/dd-trace/src/ci-visibility/exporters/test-worker/writer.js +17 -0
  94. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +47 -26
  95. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -2
  96. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +64 -53
  97. package/packages/dd-trace/src/ci-visibility/requests/request.js +1 -17
  98. package/packages/dd-trace/src/ci-visibility/requests/upload-coverage-report.js +3 -3
  99. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +23 -5
  100. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +128 -0
  101. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +287 -0
  102. package/packages/dd-trace/src/config/defaults.js +25 -5
  103. package/packages/dd-trace/src/config/generated-config-types.d.ts +596 -58
  104. package/packages/dd-trace/src/config/helper.js +134 -33
  105. package/packages/dd-trace/src/config/index.js +39 -23
  106. package/packages/dd-trace/src/config/major-overrides.js +4 -2
  107. package/packages/dd-trace/src/config/parsers.js +19 -1
  108. package/packages/dd-trace/src/config/remote_config.js +1 -1
  109. package/packages/dd-trace/src/config/supported-configurations.json +109 -57
  110. package/packages/dd-trace/src/constants.js +7 -0
  111. package/packages/dd-trace/src/datastreams/processor.js +11 -3
  112. package/packages/dd-trace/src/debugger/devtools_client/breakpoints.js +47 -35
  113. package/packages/dd-trace/src/debugger/devtools_client/index.js +31 -66
  114. package/packages/dd-trace/src/debugger/devtools_client/probe_sampler.js +83 -0
  115. package/packages/dd-trace/src/debugger/devtools_client/state.js +1 -0
  116. package/packages/dd-trace/src/debugger/index.js +5 -0
  117. package/packages/dd-trace/src/debugger/probe_sampler.js +112 -0
  118. package/packages/dd-trace/src/debugger/probe_sampler_constants.js +19 -0
  119. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +77 -26
  120. package/packages/dd-trace/src/exporters/agent/index.js +1 -1
  121. package/packages/dd-trace/src/exporters/agentless/writer.js +4 -4
  122. package/packages/dd-trace/src/exporters/common/request.js +1 -20
  123. package/packages/dd-trace/src/exporters/common/url.js +34 -0
  124. package/packages/dd-trace/src/exporters/span-stats/writer.js +1 -3
  125. package/packages/dd-trace/src/guardrails/index.js +8 -5
  126. package/packages/dd-trace/src/index.js +6 -4
  127. package/packages/dd-trace/src/llmobs/constants/tags.js +6 -0
  128. package/packages/dd-trace/src/llmobs/index.js +17 -6
  129. package/packages/dd-trace/src/llmobs/plugins/base.js +4 -4
  130. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +3 -3
  131. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +5 -1
  132. package/packages/dd-trace/src/llmobs/plugins/langgraph/index.js +1 -1
  133. package/packages/dd-trace/src/llmobs/sdk.js +8 -6
  134. package/packages/dd-trace/src/llmobs/span_processor.js +5 -1
  135. package/packages/dd-trace/src/llmobs/tagger.js +58 -3
  136. package/packages/dd-trace/src/llmobs/telemetry.js +1 -0
  137. package/packages/dd-trace/src/llmobs/writers/base.js +1 -1
  138. package/packages/dd-trace/src/log/index.js +18 -20
  139. package/packages/dd-trace/src/openfeature/flagging_provider.js +2 -7
  140. package/packages/dd-trace/src/opentelemetry/bridge-span-base.js +5 -4
  141. package/packages/dd-trace/src/opentelemetry/metrics/index.js +54 -5
  142. package/packages/dd-trace/src/opentelemetry/metrics/instruments.js +2 -1
  143. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +40 -0
  144. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_transformer.js +169 -0
  145. package/packages/dd-trace/src/opentelemetry/metrics/periodic_metric_reader.js +4 -3
  146. package/packages/dd-trace/src/opentelemetry/metrics/time.js +19 -0
  147. package/packages/dd-trace/src/opentelemetry/otlp/common.proto +2 -2
  148. package/packages/dd-trace/src/opentelemetry/otlp/logs.proto +1 -1
  149. package/packages/dd-trace/src/opentelemetry/otlp/logs_service.proto +1 -1
  150. package/packages/dd-trace/src/opentelemetry/otlp/metrics.proto +1 -1
  151. package/packages/dd-trace/src/opentelemetry/otlp/metrics_service.proto +1 -1
  152. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +44 -38
  153. package/packages/dd-trace/src/opentelemetry/span-helpers.js +29 -13
  154. package/packages/dd-trace/src/opentelemetry/span.js +14 -3
  155. package/packages/dd-trace/src/opentelemetry/span_context.js +1 -0
  156. package/packages/dd-trace/src/opentelemetry/trace/index.js +6 -1
  157. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +3 -2
  158. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +26 -13
  159. package/packages/dd-trace/src/opentelemetry/tracer_provider.js +1 -1
  160. package/packages/dd-trace/src/opentracing/propagation/text_map.js +3 -3
  161. package/packages/dd-trace/src/opentracing/span_context.js +17 -0
  162. package/packages/dd-trace/src/opentracing/tracer.js +6 -1
  163. package/packages/dd-trace/src/plugin_manager.js +14 -8
  164. package/packages/dd-trace/src/plugins/ci_plugin.js +21 -4
  165. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +276 -0
  166. package/packages/dd-trace/src/plugins/util/llm.js +6 -1
  167. package/packages/dd-trace/src/plugins/util/test.js +91 -9
  168. package/packages/dd-trace/src/plugins/util/url.js +68 -1
  169. package/packages/dd-trace/src/plugins/util/web.js +19 -36
  170. package/packages/dd-trace/src/priority_sampler.js +1 -13
  171. package/packages/dd-trace/src/profiling/config.js +129 -198
  172. package/packages/dd-trace/src/profiling/constants.js +4 -7
  173. package/packages/dd-trace/src/profiling/exporter_cli.js +10 -10
  174. package/packages/dd-trace/src/profiling/exporters/agent.js +23 -16
  175. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +45 -14
  176. package/packages/dd-trace/src/profiling/exporters/file.js +16 -5
  177. package/packages/dd-trace/src/profiling/oom.js +71 -0
  178. package/packages/dd-trace/src/profiling/profiler.js +35 -23
  179. package/packages/dd-trace/src/profiling/profilers/events.js +14 -7
  180. package/packages/dd-trace/src/profiling/profilers/space.js +27 -18
  181. package/packages/dd-trace/src/profiling/profilers/wall.js +35 -25
  182. package/packages/dd-trace/src/proxy.js +8 -8
  183. package/packages/dd-trace/src/ritm.js +4 -2
  184. package/packages/dd-trace/src/serverless.js +1 -2
  185. package/packages/dd-trace/src/service-naming/schemas/util.js +36 -5
  186. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +5 -3
  187. package/packages/dd-trace/src/span_format.js +2 -1
  188. package/packages/dd-trace/src/span_processor.js +11 -6
  189. package/packages/dd-trace/src/span_stats.js +96 -78
  190. package/packages/dd-trace/src/startup-log.js +2 -1
  191. package/packages/dd-trace/src/telemetry/dependencies.js +1 -1
  192. package/packages/dd-trace/src/telemetry/endpoints.js +6 -4
  193. package/packages/dd-trace/src/telemetry/index.js +2 -2
  194. package/packages/dd-trace/src/telemetry/logs/index.js +1 -1
  195. package/packages/dd-trace/src/telemetry/send-data.js +20 -18
  196. package/packages/dd-trace/src/telemetry/session-propagation.js +1 -1
  197. package/packages/dd-trace/src/telemetry/telemetry.js +9 -9
  198. package/packages/dd-trace/src/tracer.js +15 -1
  199. package/packages/dd-trace/src/util.js +14 -0
  200. package/register.js +58 -1
  201. package/vendor/dist/@apm-js-collab/code-transformer/index.js +1 -1
  202. package/vendor/dist/@datadog/sketches-js/index.js +1 -1
  203. package/vendor/dist/pprof-format/index.js +1 -1
  204. package/vendor/dist/protobufjs/index.js +1 -1
  205. package/vendor/dist/protobufjs/minimal/index.js +1 -1
  206. package/vendor/dist/shell-quote/index.js +1 -1
  207. package/packages/datadog-plugin-graphql/src/resolve.js +0 -170
  208. package/packages/dd-trace/src/appsec/api_security_sampler.js +0 -117
@@ -1,12 +1,12 @@
1
1
  'use strict'
2
2
 
3
3
  const pick = require('../../datadog-core/src/utils/src/pick')
4
+ const { DD_MAJOR } = require('../../../version')
4
5
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
5
6
  const log = require('../../dd-trace/src/log')
6
7
  const GraphQLExecutePlugin = require('./execute')
7
8
  const GraphQLParsePlugin = require('./parse')
8
9
  const GraphQLValidatePlugin = require('./validate')
9
- const GraphQLResolvePlugin = require('./resolve')
10
10
 
11
11
  class GraphQLPlugin extends CompositePlugin {
12
12
  static id = 'graphql'
@@ -15,7 +15,9 @@ class GraphQLPlugin extends CompositePlugin {
15
15
  execute: GraphQLExecutePlugin,
16
16
  parse: GraphQLParsePlugin,
17
17
  validate: GraphQLValidatePlugin,
18
- resolve: GraphQLResolvePlugin,
18
+ // resolve plugin is absorbed into execute: per-field data is recorded
19
+ // synchronously in wrapResolve, and all graphql.resolve spans are
20
+ // materialized at execute end.
19
21
  }
20
22
  }
21
23
 
@@ -30,11 +32,15 @@ class GraphQLPlugin extends CompositePlugin {
30
32
  // config validator helpers
31
33
 
32
34
  function validateConfig (config) {
35
+ const collapse = config.collapse === undefined || !!config.collapse
33
36
  return {
34
37
  ...config,
35
38
  depth: getDepth(config),
36
39
  variables: getVariablesFilter(config),
37
- collapse: config.collapse === undefined || !!config.collapse,
40
+ collapse,
41
+ // v5 counted collapsed list indices toward `depth`, so the same query reached a
42
+ // different depth depending on `collapse`. v6 counts selection-set depth only.
43
+ countListIndices: DD_MAJOR < 6 && collapse,
38
44
  hooks: getHooks(config),
39
45
  }
40
46
  }
@@ -60,13 +66,19 @@ function getVariablesFilter (config) {
60
66
  }
61
67
 
62
68
  const noop = () => {}
69
+ const noopHooks = { execute: noop, parse: noop, validate: noop, resolve: undefined }
63
70
 
64
71
  function getHooks ({ hooks }) {
65
- const execute = hooks?.execute ?? noop
66
- const parse = hooks?.parse ?? noop
67
- const validate = hooks?.validate ?? noop
68
-
69
- return { execute, parse, validate }
72
+ if (!hooks) return noopHooks
73
+ return {
74
+ execute: hooks.execute ?? noop,
75
+ parse: hooks.parse ?? noop,
76
+ validate: hooks.validate ?? noop,
77
+ // No noop fallback: `resolve` runs per-field (hot path); the plugin
78
+ // gates with `if (this.config.hooks.resolve)` so the absent-hook case
79
+ // skips both the call and the payload-object allocation.
80
+ resolve: hooks.resolve,
81
+ }
70
82
  }
71
83
 
72
84
  module.exports = GraphQLPlugin
@@ -2,34 +2,54 @@
2
2
 
3
3
  const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
4
 
5
+ const documentSources = new WeakMap()
6
+
5
7
  class GraphQLParsePlugin extends TracingPlugin {
6
8
  static id = 'graphql'
7
9
  static operation = 'parser'
10
+ static prefix = 'tracing:orchestrion:graphql:apm:graphql:parser'
8
11
 
9
12
  bindStart (ctx) {
13
+ const source = ctx.arguments?.[0]
14
+
10
15
  this.startSpan('graphql.parse', {
11
16
  service: this.config.service,
12
17
  type: 'graphql',
13
18
  meta: {},
14
19
  }, ctx)
15
20
 
21
+ ctx.ddSource = source
22
+
16
23
  return ctx.currentStore
17
24
  }
18
25
 
19
- finish (ctx) {
20
- const { source, document, docSource } = ctx
26
+ end (ctx) {
27
+ const source = ctx.ddSource
28
+ const document = ctx.result
21
29
  const span = ctx?.currentStore?.span || this.activeSpan
22
30
 
23
- if (this.config.source && document) {
31
+ let docSource
32
+ if (document) {
33
+ if (source) {
34
+ docSource = source.body || source
35
+ documentSources.set(document, docSource)
36
+ } else {
37
+ docSource = documentSources.get(document)
38
+ }
39
+ }
40
+
41
+ if (this.config.source && docSource) {
24
42
  span.setTag('graphql.source', docSource)
25
43
  }
26
44
 
27
45
  this.config.hooks.parse(span, source, document)
28
46
 
29
- super.finish(ctx)
47
+ span.finish()
30
48
 
31
49
  return ctx.parentStore
32
50
  }
33
51
  }
34
52
 
53
+ GraphQLParsePlugin.documentSources = documentSources
54
+
35
55
  module.exports = GraphQLParsePlugin
@@ -1,14 +1,18 @@
1
1
  'use strict'
2
2
 
3
3
  const TracingPlugin = require('../../dd-trace/src/plugins/tracing')
4
+ const GraphQLParsePlugin = require('./parse')
4
5
  const { extractErrorIntoSpanEvent } = require('./utils')
5
6
 
6
7
  class GraphQLValidatePlugin extends TracingPlugin {
7
8
  static id = 'graphql'
8
9
  static operation = 'validate'
10
+ static prefix = 'tracing:orchestrion:graphql:apm:graphql:validate'
9
11
 
10
12
  bindStart (ctx) {
11
- const { docSource, document } = ctx
13
+ // validate(schema, documentAST, rules, options, typeInfo)
14
+ const document = ctx.arguments?.[1]
15
+ const docSource = document ? GraphQLParsePlugin.documentSources.get(document) : undefined
12
16
  const source = this.config.source && document && docSource
13
17
 
14
18
  this.startSpan('graphql.validate', {
@@ -19,19 +23,26 @@ class GraphQLValidatePlugin extends TracingPlugin {
19
23
  },
20
24
  }, ctx)
21
25
 
26
+ ctx.ddDocument = document
27
+
22
28
  return ctx.currentStore
23
29
  }
24
30
 
25
- finish (ctx) {
26
- const { document, errors } = ctx
31
+ end (ctx) {
32
+ const document = ctx.ddDocument
33
+ const errors = ctx.result
27
34
  const span = ctx?.currentStore?.span || this.activeSpan
35
+
28
36
  this.config.hooks.validate(span, document, errors)
29
- if (errors) {
37
+
38
+ if (errors?.length) {
39
+ span.setTag('error', errors[0])
30
40
  for (const err of errors) {
31
41
  extractErrorIntoSpanEvent(this._tracerConfig, span, err)
32
42
  }
33
43
  }
34
- super.finish(ctx)
44
+
45
+ span.finish()
35
46
 
36
47
  return ctx.parentStore
37
48
  }
@@ -8,6 +8,7 @@ const tags = require('../../../ext/tags')
8
8
  const formats = require('../../../ext/formats')
9
9
  const HTTP_HEADERS = formats.HTTP_HEADERS
10
10
  const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
11
+ const { buildClientHttpUrl } = require('../../dd-trace/src/plugins/util/url')
11
12
  const log = require('../../dd-trace/src/log')
12
13
  const { CLIENT_PORT_KEY, COMPONENT, ERROR_MESSAGE, ERROR_TYPE, ERROR_STACK } = require('../../dd-trace/src/constants')
13
14
 
@@ -27,13 +28,17 @@ class HttpClientPlugin extends ClientPlugin {
27
28
  const protocol = options.protocol || agent.protocol || 'http:'
28
29
  const hostname = options.hostname || options.host || 'localhost'
29
30
  const host = options.port ? `${hostname}:${options.port}` : hostname
30
- const pathname = options.path || options.pathname
31
+ const base = `${protocol}//${host}`
32
+ // A URL object (e.g. from the fetch integration) carries the query in
33
+ // `options.search`, not `options.path`; keep it so url.full retains the query.
34
+ const pathname = options.path || `${options.pathname || ''}${options.search || ''}`
31
35
  const path = pathname ? pathname.split(/[?#]/)[0] : '/'
32
- const uri = `${protocol}//${host}${path}`
36
+ const uri = `${base}${path}`
33
37
 
34
38
  const allowed = this.config.filter(uri)
35
39
 
36
40
  const method = (options.method || 'GET').toUpperCase()
41
+ const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
37
42
  const childOf = store && allowed ? store.span : null
38
43
  // TODO delegate to super.startspan
39
44
  const span = this.startSpan(this.operationName(), {
@@ -46,7 +51,7 @@ class HttpClientPlugin extends ClientPlugin {
46
51
  'resource.name': method,
47
52
  'span.type': 'http',
48
53
  'http.method': method,
49
- 'http.url': uri,
54
+ 'http.url': otelSemantics ? buildClientHttpUrl(this.config, base, pathname, uri) : uri,
50
55
  'out.host': hostname,
51
56
  },
52
57
  metrics: {
@@ -1,6 +1,5 @@
1
1
  'use strict'
2
2
 
3
- const PushSubscriptionPlugin = require('../../datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription')
4
3
  const CompositePlugin = require('../../dd-trace/src/plugins/composite')
5
4
  const { enableGCPPubSubPushSubscription } = require('../../dd-trace/src/serverless')
6
5
  const log = require('../../dd-trace/src/log')
@@ -17,14 +16,13 @@ class HttpPlugin extends CompositePlugin {
17
16
  static get plugins () {
18
17
  const plugins = {}
19
18
 
20
- // Load push subscription plugin first (if enabled) for GCP Cloud Run
19
+ // Load the push subscription plugin first (if enabled) for GCP Cloud Run.
20
+ // The require stays inside the gate so the pubsub plugin graph is not pulled
21
+ // into every process that instruments http — only GCP Cloud Run reaches it.
21
22
  if (enableGCPPubSubPushSubscription()) {
22
- try {
23
- plugins['pubsub-push-subscription'] = PushSubscriptionPlugin
24
- log.debug('Loaded GCP Pub/Sub Push Subscription plugin for HTTP requests')
25
- } catch (e) {
26
- log.debug('Failed to load GCP Pub/Sub Push Subscription plugin:', e)
27
- }
23
+ plugins['pubsub-push-subscription'] =
24
+ require('../../datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription')
25
+ log.debug('Loaded GCP Pub/Sub Push Subscription plugin for HTTP requests')
28
26
  }
29
27
 
30
28
  plugins.server = HttpServerPlugin
@@ -10,6 +10,7 @@ const kinds = require('../../../ext/kinds')
10
10
  const formats = require('../../../ext/formats')
11
11
  const { COMPONENT, CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
12
12
  const urlFilter = require('../../dd-trace/src/plugins/util/urlfilter')
13
+ const { buildClientHttpUrl } = require('../../dd-trace/src/plugins/util/url')
13
14
 
14
15
  const HTTP_HEADERS = formats.HTTP_HEADERS
15
16
  const HTTP_STATUS_CODE = tags.HTTP_STATUS_CODE
@@ -33,8 +34,10 @@ class Http2ClientPlugin extends ClientPlugin {
33
34
  const path = headers[HTTP2_HEADER_PATH] || '/'
34
35
  const pathname = path.split(/[?#]/)[0]
35
36
  const method = headers[HTTP2_HEADER_METHOD] || HTTP2_METHOD_GET
36
- const uri = `${sessionDetails.protocol}//${sessionDetails.host}:${sessionDetails.port}${pathname}`
37
+ const base = `${sessionDetails.protocol}//${sessionDetails.host}:${sessionDetails.port}`
38
+ const uri = `${base}${pathname}`
37
39
  const allowed = this.config.filter(uri)
40
+ const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
38
41
 
39
42
  const store = storage('legacy').getStore()
40
43
  const childOf = store && allowed ? store.span : null
@@ -48,7 +51,7 @@ class Http2ClientPlugin extends ClientPlugin {
48
51
  'resource.name': method,
49
52
  'span.type': 'http',
50
53
  'http.method': method,
51
- 'http.url': uri,
54
+ 'http.url': otelSemantics ? buildClientHttpUrl(this.config, base, path, uri) : uri,
52
55
  'out.host': sessionDetails.host,
53
56
  },
54
57
  metrics: {
@@ -177,7 +177,7 @@ class JestPlugin extends CiPlugin {
177
177
 
178
178
  this.telemetry.count(TELEMETRY_TEST_SESSION, {
179
179
  provider: this.ciProviderName,
180
- autoInjected: !!this._tracerConfig.DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER,
180
+ autoInjected: !!this._tracerConfig.testOptimization.DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER,
181
181
  })
182
182
 
183
183
  appClosingTelemetry()
@@ -427,7 +427,7 @@ class MochaPlugin extends CiPlugin {
427
427
  finishAllTraceSpans(this.testSessionSpan)
428
428
  this.telemetry.count(TELEMETRY_TEST_SESSION, {
429
429
  provider: this.ciProviderName,
430
- autoInjected: !!this._tracerConfig.DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER,
430
+ autoInjected: !!this._tracerConfig.testOptimization.DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER,
431
431
  })
432
432
  }
433
433
  this.libraryConfig = null
@@ -11,11 +11,16 @@ class MySQLPlugin extends DatabasePlugin {
11
11
  constructor () {
12
12
  super(...arguments)
13
13
 
14
+ // Capture into `currentStore` (not `parentStore`) so connection:finish can
15
+ // restore the caller context even when the connection resolves inside an
16
+ // instrumentation skip (a noop store), as the mariadb pool does: the store
17
+ // binding only honors an explicit `currentStore` through a noop store.
18
+ // Without a skip (mysql/mysql2) this is unchanged.
14
19
  this.addSub(`apm:${this.component}:connection:start`, ctx => {
15
- ctx.parentStore = storage('legacy').getStore()
20
+ ctx.currentStore = storage('legacy').getStore()
16
21
  })
17
22
 
18
- this.addBind(`apm:${this.component}:connection:finish`, ctx => ctx.parentStore)
23
+ this.addBind(`apm:${this.component}:connection:finish`, ctx => ctx.currentStore)
19
24
  }
20
25
 
21
26
  bindStart (ctx) {
@@ -24,12 +24,12 @@ module.exports.init = function (tracerConfig) {
24
24
  })
25
25
  : new NoopDogStatsDClient()
26
26
 
27
- logger = tracerConfig && tracerConfig.apiKey
27
+ logger = tracerConfig && tracerConfig.DD_API_KEY
28
28
  ? new ExternalLogger({
29
29
  ddsource: 'openai',
30
30
  hostname: tracerConfig.hostname,
31
31
  service: tracerConfig.service,
32
- apiKey: tracerConfig.apiKey,
32
+ apiKey: tracerConfig.DD_API_KEY,
33
33
  interval: FLUSH_INTERVAL,
34
34
  })
35
35
  : new NoopExternalLogger()
@@ -108,7 +108,7 @@ class PlaywrightPlugin extends CiPlugin {
108
108
  finishAllTraceSpans(this.testSessionSpan)
109
109
  this.telemetry.count(TELEMETRY_TEST_SESSION, {
110
110
  provider: this.ciProviderName,
111
- autoInjected: !!this._tracerConfig.DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER,
111
+ autoInjected: !!this._tracerConfig.testOptimization.DD_CIVISIBILITY_AUTO_INSTRUMENTATION_PROVIDER,
112
112
  })
113
113
  appClosingTelemetry()
114
114
  this.tracer._exporter.flush(onDone)
@@ -47,10 +47,10 @@ class SchemaExtractor {
47
47
 
48
48
  static extractProperty (field, schemaName, fieldName, builder, depth) {
49
49
  let array = false
50
- let description
51
50
  let ref
52
51
  let enumValues
53
52
 
53
+ const description = field.comment
54
54
  const resolvedType = field.resolvedType ? field.resolvedType.constructor.name : field.type
55
55
 
56
56
  const isRepeatedField = field.rule === 'repeated'
@@ -124,7 +124,7 @@ class SchemaExtractor {
124
124
  }
125
125
 
126
126
  iterateOverSchema (builder) {
127
- this.constructor.extractSchema(this.schema, builder, 0)
127
+ SchemaExtractor.extractSchema(this.schema, builder, 0)
128
128
  }
129
129
 
130
130
  static attachSchemaOnSpan (args, span, operation, tracer) {
@@ -6,6 +6,7 @@ const tags = require('../../../ext/tags')
6
6
  const formats = require('../../../ext/formats')
7
7
  const HTTP_HEADERS = formats.HTTP_HEADERS
8
8
  const log = require('../../dd-trace/src/log')
9
+ const { buildClientHttpUrl } = require('../../dd-trace/src/plugins/util/url')
9
10
  const { CLIENT_PORT_KEY } = require('../../dd-trace/src/constants')
10
11
 
11
12
  const {
@@ -60,10 +61,12 @@ class UndiciPlugin extends HttpClientPlugin {
60
61
  }
61
62
 
62
63
  const host = port ? `${hostname}:${port}` : hostname
64
+ const base = `${protocol}//${host}`
63
65
  const pathname = path.split(/[?#]/)[0]
64
- const uri = `${protocol}//${host}${pathname}`
66
+ const uri = `${base}${pathname}`
65
67
 
66
68
  const allowed = this.config.filter(uri)
69
+ const otelSemantics = this.config.DD_TRACE_OTEL_SEMANTICS_ENABLED
67
70
  const childOf = store && allowed ? store.span : null
68
71
 
69
72
  const span = this.startSpan(this.operationName(), {
@@ -71,7 +74,7 @@ class UndiciPlugin extends HttpClientPlugin {
71
74
  meta: {
72
75
  'span.kind': 'client',
73
76
  'http.method': method,
74
- 'http.url': uri,
77
+ 'http.url': otelSemantics ? buildClientHttpUrl(this.config, base, path, uri) : uri,
75
78
  'out.host': hostname,
76
79
  },
77
80
  metrics: {