dd-trace 5.58.0 → 5.59.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 (165) hide show
  1. package/LICENSE-3rdparty.csv +1 -0
  2. package/ci/cypress/after-run.js +2 -0
  3. package/ci/cypress/after-spec.js +2 -0
  4. package/ci/cypress/plugin.js +2 -0
  5. package/ci/cypress/polyfills.js +2 -0
  6. package/ci/cypress/support.js +2 -0
  7. package/ci/init.js +2 -0
  8. package/index.d.ts +7 -0
  9. package/init.js +0 -2
  10. package/initialize.mjs +2 -0
  11. package/package.json +36 -7
  12. package/packages/datadog-code-origin/index.js +14 -9
  13. package/packages/datadog-instrumentations/src/apollo.js +7 -10
  14. package/packages/datadog-instrumentations/src/avsc.js +2 -0
  15. package/packages/datadog-instrumentations/src/child_process.js +21 -42
  16. package/packages/datadog-instrumentations/src/cucumber.js +10 -8
  17. package/packages/datadog-instrumentations/src/cypress.js +2 -0
  18. package/packages/datadog-instrumentations/src/fastify.js +19 -1
  19. package/packages/datadog-instrumentations/src/helpers/hooks.js +1 -0
  20. package/packages/datadog-instrumentations/src/helpers/register.js +1 -1
  21. package/packages/datadog-instrumentations/src/hono.js +102 -0
  22. package/packages/datadog-instrumentations/src/langchain.js +21 -0
  23. package/packages/datadog-instrumentations/src/mocha/common.js +2 -0
  24. package/packages/datadog-instrumentations/src/mocha.js +2 -0
  25. package/packages/datadog-instrumentations/src/nyc.js +2 -0
  26. package/packages/datadog-instrumentations/src/orchestrion-config/index.js +32 -0
  27. package/packages/datadog-instrumentations/src/playwright.js +5 -1
  28. package/packages/datadog-instrumentations/src/protobufjs.js +2 -0
  29. package/packages/datadog-instrumentations/src/selenium.js +2 -0
  30. package/packages/datadog-instrumentations/src/vitest.js +2 -0
  31. package/packages/datadog-plugin-avsc/src/index.js +2 -0
  32. package/packages/datadog-plugin-avsc/src/schema_iterator.js +2 -0
  33. package/packages/datadog-plugin-aws-sdk/src/services/bedrockruntime/index.js +2 -0
  34. package/packages/datadog-plugin-child_process/src/index.js +30 -10
  35. package/packages/datadog-plugin-cypress/src/after-run.js +2 -0
  36. package/packages/datadog-plugin-cypress/src/after-spec.js +2 -0
  37. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +8 -3
  38. package/packages/datadog-plugin-cypress/src/index.js +2 -0
  39. package/packages/datadog-plugin-cypress/src/plugin.js +2 -0
  40. package/packages/datadog-plugin-cypress/src/support.js +4 -2
  41. package/packages/datadog-plugin-google-cloud-vertexai/src/utils.js +2 -0
  42. package/packages/datadog-plugin-graphql/src/utils.js +2 -0
  43. package/packages/datadog-plugin-hono/src/index.js +28 -0
  44. package/packages/datadog-plugin-jest/src/index.js +2 -0
  45. package/packages/datadog-plugin-jest/src/util.js +2 -0
  46. package/packages/datadog-plugin-kafkajs/src/batch-consumer.js +2 -0
  47. package/packages/datadog-plugin-langchain/src/tracing.js +36 -4
  48. package/packages/datadog-plugin-nyc/src/index.js +2 -0
  49. package/packages/datadog-plugin-oracledb/src/connection-parser.js +2 -0
  50. package/packages/datadog-plugin-protobufjs/src/index.js +2 -0
  51. package/packages/datadog-plugin-protobufjs/src/schema_iterator.js +2 -0
  52. package/packages/datadog-plugin-selenium/src/index.js +2 -0
  53. package/packages/datadog-plugin-vitest/src/index.js +2 -0
  54. package/packages/dd-trace/src/appsec/iast/iast-context.js +5 -1
  55. package/packages/dd-trace/src/appsec/iast/index.js +2 -0
  56. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
  57. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-esm.mjs +0 -2
  58. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +2 -0
  59. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-regex.js +2 -0
  60. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
  61. package/packages/dd-trace/src/appsec/iast/vulnerability-reporter.js +3 -3
  62. package/packages/dd-trace/src/appsec/rasp/fs-plugin.js +18 -11
  63. package/packages/dd-trace/src/appsec/rasp/utils.js +1 -1
  64. package/packages/dd-trace/src/appsec/recommended.json +88 -2
  65. package/packages/dd-trace/src/appsec/reporter.js +7 -7
  66. package/packages/dd-trace/src/appsec/stack_trace.js +11 -11
  67. package/packages/dd-trace/src/appsec/telemetry/common.js +1 -1
  68. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +2 -2
  69. package/packages/dd-trace/src/ci-visibility/dynamic-instrumentation/index.js +3 -3
  70. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +2 -0
  71. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +3 -1
  72. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +2 -0
  73. package/packages/dd-trace/src/ci-visibility/log-submission/log-submission-plugin.js +2 -0
  74. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +2 -0
  75. package/packages/dd-trace/src/ci-visibility/telemetry.js +2 -0
  76. package/packages/dd-trace/src/ci-visibility/test-api-manual/test-api-manual-plugin.js +2 -0
  77. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +7 -3
  78. package/packages/dd-trace/src/config.js +4 -0
  79. package/packages/dd-trace/src/config_stable.js +2 -0
  80. package/packages/dd-trace/src/datastreams/checkpointer.js +2 -0
  81. package/packages/dd-trace/src/datastreams/context.js +2 -0
  82. package/packages/dd-trace/src/datastreams/encoding.js +2 -0
  83. package/packages/dd-trace/src/datastreams/fnv.js +2 -0
  84. package/packages/dd-trace/src/datastreams/pathway.js +11 -9
  85. package/packages/dd-trace/src/datastreams/processor.js +8 -7
  86. package/packages/dd-trace/src/datastreams/schemas/schema.js +2 -0
  87. package/packages/dd-trace/src/datastreams/schemas/schema_builder.js +45 -36
  88. package/packages/dd-trace/src/datastreams/schemas/schema_sampler.js +2 -0
  89. package/packages/dd-trace/src/datastreams/writer.js +2 -0
  90. package/packages/dd-trace/src/debugger/devtools_client/index.js +12 -4
  91. package/packages/dd-trace/src/debugger/devtools_client/inspector_promises_polyfill.js +2 -0
  92. package/packages/dd-trace/src/debugger/devtools_client/remote_config.js +8 -5
  93. package/packages/dd-trace/src/debugger/devtools_client/snapshot/symbols.js +1 -1
  94. package/packages/dd-trace/src/debugger/index.js +36 -9
  95. package/packages/dd-trace/src/encode/tags-processors.js +2 -0
  96. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +2 -0
  97. package/packages/dd-trace/src/exporters/common/util.js +2 -0
  98. package/packages/dd-trace/src/exporters/span-stats/index.js +2 -0
  99. package/packages/dd-trace/src/exporters/span-stats/writer.js +2 -0
  100. package/packages/dd-trace/src/external-logger/src/index.js +2 -0
  101. package/packages/dd-trace/src/git_metadata_tagger.js +2 -0
  102. package/packages/dd-trace/src/git_properties.js +2 -0
  103. package/packages/dd-trace/src/guardrails/index.js +3 -4
  104. package/packages/dd-trace/src/guardrails/log.js +2 -2
  105. package/packages/dd-trace/src/guardrails/telemetry.js +16 -14
  106. package/packages/dd-trace/src/guardrails/util.js +0 -2
  107. package/packages/dd-trace/src/llmobs/plugins/bedrockruntime.js +2 -0
  108. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/index.js +5 -0
  109. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/tool.js +15 -0
  110. package/packages/dd-trace/src/llmobs/plugins/langchain/handlers/vectorstore.js +36 -0
  111. package/packages/dd-trace/src/llmobs/plugins/langchain/index.js +47 -4
  112. package/packages/dd-trace/src/llmobs/tagger.js +10 -1
  113. package/packages/dd-trace/src/noop/dogstatsd.js +2 -0
  114. package/packages/dd-trace/src/opentracing/propagation/text_map_dsm.js +2 -0
  115. package/packages/dd-trace/src/payload-tagging/config/index.js +2 -0
  116. package/packages/dd-trace/src/payload-tagging/index.js +2 -0
  117. package/packages/dd-trace/src/payload-tagging/tagging.js +2 -0
  118. package/packages/dd-trace/src/plugins/apollo.js +2 -0
  119. package/packages/dd-trace/src/plugins/ci_plugin.js +8 -3
  120. package/packages/dd-trace/src/plugins/index.js +1 -0
  121. package/packages/dd-trace/src/plugins/util/ci.js +2 -0
  122. package/packages/dd-trace/src/plugins/util/env.js +2 -0
  123. package/packages/dd-trace/src/plugins/util/git.js +40 -5
  124. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +2 -0
  125. package/packages/dd-trace/src/plugins/util/llm.js +2 -0
  126. package/packages/dd-trace/src/plugins/util/serverless.js +2 -0
  127. package/packages/dd-trace/src/plugins/util/stacktrace.js +178 -50
  128. package/packages/dd-trace/src/plugins/util/tags.js +17 -1
  129. package/packages/dd-trace/src/plugins/util/test.js +9 -4
  130. package/packages/dd-trace/src/plugins/util/url.js +2 -0
  131. package/packages/dd-trace/src/plugins/util/user-provided-git.js +2 -0
  132. package/packages/dd-trace/src/profiling/exporters/event_serializer.js +4 -0
  133. package/packages/dd-trace/src/profiling/profiler.js +89 -70
  134. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns.js +2 -0
  135. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookup.js +2 -0
  136. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_lookupservice.js +2 -0
  137. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_resolve.js +2 -0
  138. package/packages/dd-trace/src/profiling/profilers/event_plugins/dns_reverse.js +2 -0
  139. package/packages/dd-trace/src/profiling/profilers/event_plugins/event.js +2 -0
  140. package/packages/dd-trace/src/profiling/profilers/event_plugins/fs.js +2 -0
  141. package/packages/dd-trace/src/profiling/profilers/event_plugins/net.js +2 -0
  142. package/packages/dd-trace/src/profiling/profilers/events.js +2 -0
  143. package/packages/dd-trace/src/profiling/webspan-utils.js +2 -0
  144. package/packages/dd-trace/src/remote_config/capabilities.js +3 -1
  145. package/packages/dd-trace/src/remote_config/index.js +4 -0
  146. package/packages/dd-trace/src/service-naming/index.js +2 -0
  147. package/packages/dd-trace/src/service-naming/schemas/definition.js +2 -0
  148. package/packages/dd-trace/src/service-naming/schemas/util.js +2 -0
  149. package/packages/dd-trace/src/service-naming/schemas/v0/graphql.js +2 -0
  150. package/packages/dd-trace/src/service-naming/schemas/v0/index.js +2 -0
  151. package/packages/dd-trace/src/service-naming/schemas/v0/messaging.js +2 -0
  152. package/packages/dd-trace/src/service-naming/schemas/v0/serverless.js +2 -0
  153. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +2 -0
  154. package/packages/dd-trace/src/service-naming/schemas/v0/web.js +2 -0
  155. package/packages/dd-trace/src/service-naming/schemas/v1/graphql.js +2 -0
  156. package/packages/dd-trace/src/service-naming/schemas/v1/index.js +2 -0
  157. package/packages/dd-trace/src/service-naming/schemas/v1/messaging.js +2 -0
  158. package/packages/dd-trace/src/service-naming/schemas/v1/serverless.js +2 -0
  159. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +2 -0
  160. package/packages/dd-trace/src/service-naming/schemas/v1/web.js +2 -0
  161. package/packages/dd-trace/src/span_stats.js +2 -0
  162. package/packages/dd-trace/src/supported-configurations.json +2 -0
  163. package/packages/dd-trace/src/telemetry/send-data.js +2 -0
  164. package/register.js +4 -0
  165. package/version.js +0 -3
@@ -68,6 +68,7 @@ dev,sinon,BSD-3-Clause,Copyright 2010-2017 Christian Johansen
68
68
  dev,sinon-chai,WTFPL and BSD-2-Clause,Copyright 2004 Sam Hocevar 2012–2017 Domenic Denicola
69
69
  dev,tap,ISC,Copyright 2011-2022 Isaac Z. Schlueter and Contributors
70
70
  dev,tiktoken,MIT,Copyright (c) 2022 OpenAI, Shantanu Jain
71
+ dev,workerpool,Apache license 2.0,Copyright (C) 2014-2024 Jos de Jong wjosdejong@gmail.com
71
72
  dev,yaml,ISC,Copyright Eemeli Aro <eemeli@gmail.com>
72
73
  dev,yarn-deduplicate,Apache license 2.0,Copyright [yyyy] [name of copyright owner]
73
74
  file,aws-lambda-nodejs-runtime-interface-client,Apache 2.0,Copyright 2019 Amazon.com Inc. or its affiliates. All Rights Reserved.
@@ -1 +1,3 @@
1
+ 'use strict'
2
+
1
3
  module.exports = require('../../packages/datadog-plugin-cypress/src/after-run')
@@ -1 +1,3 @@
1
+ 'use strict'
2
+
1
3
  module.exports = require('../../packages/datadog-plugin-cypress/src/after-spec')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { NODE_MAJOR } = require('../../version')
2
4
 
3
5
  // These polyfills are here because cypress@6.7.0, which we still support for v5, runs its plugin code
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  if (!Object.hasOwn) {
2
4
  Object.defineProperty(Object, 'hasOwn', {
3
5
  // eslint-disable-next-line prefer-object-has-own
@@ -1 +1,3 @@
1
+ 'use strict'
2
+
1
3
  require('../../packages/datadog-plugin-cypress/src/support')
package/ci/init.js CHANGED
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  /* eslint-disable no-console */
2
4
  const tracer = require('../packages/dd-trace')
3
5
  const { isTrue, isFalse } = require('../packages/dd-trace/src/util')
package/index.d.ts CHANGED
@@ -186,6 +186,7 @@ interface Plugins {
186
186
  "graphql": tracer.plugins.graphql;
187
187
  "grpc": tracer.plugins.grpc;
188
188
  "hapi": tracer.plugins.hapi;
189
+ "hono": tracer.plugins.hono;
189
190
  "http": tracer.plugins.http;
190
191
  "http2": tracer.plugins.http2;
191
192
  "ioredis": tracer.plugins.ioredis;
@@ -1603,6 +1604,12 @@ declare namespace tracer {
1603
1604
  */
1604
1605
  interface hapi extends HttpServer {}
1605
1606
 
1607
+ /**
1608
+ * This plugin automatically instruments the
1609
+ * [hono](https://hono.dev/) module.
1610
+ */
1611
+ interface hono extends HttpServer {}
1612
+
1606
1613
  /**
1607
1614
  * This plugin automatically instruments the
1608
1615
  * [http](https://nodejs.org/api/http.html) module.
package/init.js CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict'
2
2
 
3
- /* eslint-disable no-var */
4
-
5
3
  var guard = require('./packages/dd-trace/src/guardrails')
6
4
 
7
5
  module.exports = guard(function () {
package/initialize.mjs CHANGED
@@ -10,6 +10,8 @@
10
10
  * hook will always be active for ESM support.
11
11
  */
12
12
 
13
+ /* eslint n/no-unsupported-features/node-builtins: ['error', { ignores: ['module.register'] }] */
14
+
13
15
  import { isMainThread } from 'worker_threads'
14
16
 
15
17
  import * as Module from 'node:module'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dd-trace",
3
- "version": "5.58.0",
3
+ "version": "5.59.0",
4
4
  "description": "Datadog APM tracing client for JavaScript",
5
5
  "main": "index.js",
6
6
  "typings": "index.d.ts",
@@ -25,8 +25,10 @@
25
25
  "test:debugger": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/dd-trace/test/debugger/**/*.spec.js'",
26
26
  "test:debugger:ci": "nyc --no-clean --include 'packages/dd-trace/src/debugger/**/*.js' -- npm run test:debugger",
27
27
  "test:eslint-rules": "node eslint-rules/*.test.mjs",
28
- "test:trace:core": "tap packages/dd-trace/test/*.spec.js \"packages/dd-trace/test/{ci-visibility,datastreams,encode,exporters,opentelemetry,opentracing,plugins,service-naming,standalone,telemetry}/**/*.spec.js\"",
28
+ "test:trace:core": "tap packages/dd-trace/test/*.spec.js \"packages/dd-trace/test/{ci-visibility,datastreams,encode,exporters,opentelemetry,opentracing,plugins,remote_config,service-naming,standalone,telemetry}/**/*.spec.js\"",
29
29
  "test:trace:core:ci": "npm run test:trace:core -- --coverage --nyc-arg=--include=\"packages/dd-trace/src/**/*.js\"",
30
+ "test:trace:guardrails": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/dd-trace/test/guardrails/**/*.spec.js\"",
31
+ "test:trace:guardrails:ci": "nyc --no-clean --include \"packages/dd-trace/src/guardrails/**/*.js\" -- npm run test:trace:guardrails",
30
32
  "test:instrumentations": "mocha -r 'packages/dd-trace/test/setup/mocha.js' \"packages/datadog-instrumentations/test/@($(echo $PLUGINS)).spec.js\"",
31
33
  "test:instrumentations:ci": "yarn services && nyc --no-clean --include \"packages/datadog-instrumentations/src/@($(echo $PLUGINS)).js\" --include \"packages/datadog-instrumentations/src/@($(echo $PLUGINS))/**/*.js\" -- npm run test:instrumentations",
32
34
  "test:instrumentations:misc": "mocha -r 'packages/dd-trace/test/setup/mocha.js' 'packages/datadog-instrumentations/test/*/**/*.spec.js'",
@@ -55,6 +57,7 @@
55
57
  "test:integration:playwright": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/playwright/*.spec.js\"",
56
58
  "test:integration:selenium": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/selenium/*.spec.js\"",
57
59
  "test:integration:vitest": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/vitest/*.spec.js\"",
60
+ "test:integration:testopt": "mocha --timeout 60000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/ci-visibility/*.spec.js\"",
58
61
  "test:integration:profiler": "mocha --timeout 180000 -r \"packages/dd-trace/test/setup/core.js\" \"integration-tests/profiler/*.spec.js\"",
59
62
  "test:integration:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/integration-test/**/*.spec.js\"",
60
63
  "test:unit:plugins": "mocha -r \"packages/dd-trace/test/setup/mocha.js\" \"packages/datadog-instrumentations/test/@($(echo $PLUGINS)).spec.js\" \"packages/datadog-plugin-@($(echo $PLUGINS))/test/**/*.spec.js\" --exclude \"packages/datadog-plugin-@($(echo $PLUGINS))/test/integration-test/**/*.spec.js\"",
@@ -84,9 +87,34 @@
84
87
  "engines": {
85
88
  "node": ">=18"
86
89
  },
90
+ "files": [
91
+ "ci/**/*",
92
+ "cypress/**/*",
93
+ "esbuild.js",
94
+ "ext/**/*",
95
+ "index.d.ts",
96
+ "index.js",
97
+ "init.js",
98
+ "initialize.mjs",
99
+ "LICENSE-3rdparty.csv",
100
+ "LICENSE",
101
+ "LICENSE.Apache",
102
+ "LICENSE.BSD3",
103
+ "loader-hook.mjs",
104
+ "package.json",
105
+ "packages/*/index.js",
106
+ "packages/*/lib/**/*",
107
+ "packages/*/src/**/*",
108
+ "packages/datadog-instrumentations/orchestrion.yml",
109
+ "README.md",
110
+ "register.js",
111
+ "scripts/preinstall.js",
112
+ "vendor/**/*",
113
+ "version.js"
114
+ ],
87
115
  "dependencies": {
88
116
  "@datadog/libdatadog": "0.7.0",
89
- "@datadog/native-appsec": "9.0.0",
117
+ "@datadog/native-appsec": "10.0.0",
90
118
  "@datadog/native-iast-taint-tracking": "4.0.0",
91
119
  "@datadog/native-metrics": "3.1.1",
92
120
  "@datadog/pprof": "5.9.0",
@@ -97,7 +125,7 @@
97
125
  "@opentelemetry/core": "^1.14.0",
98
126
  "crypto-randomuuid": "^1.0.0",
99
127
  "dc-polyfill": "^0.1.9",
100
- "ignore": "^5.2.4",
128
+ "ignore": "^7.0.5",
101
129
  "import-in-the-middle": "^1.14.2",
102
130
  "istanbul-lib-coverage": "^3.2.2",
103
131
  "jest-docblock": "^29.7.0",
@@ -105,10 +133,10 @@
105
133
  "koalas": "^1.0.2",
106
134
  "limiter": "^1.1.5",
107
135
  "lodash.sortby": "^4.7.0",
108
- "lru-cache": "^7.18.3",
136
+ "lru-cache": "^10.4.3",
109
137
  "module-details-from-path": "^1.0.4",
110
138
  "mutexify": "^1.4.0",
111
- "opentracing": ">=0.12.1",
139
+ "opentracing": ">=0.14.7",
112
140
  "path-to-regexp": "^0.1.12",
113
141
  "pprof-format": "^2.1.0",
114
142
  "protobufjs": "^7.5.3",
@@ -138,7 +166,7 @@
138
166
  "eslint-plugin-n": "^17.20.0",
139
167
  "eslint-plugin-promise": "^7.2.1",
140
168
  "eslint-plugin-unicorn": "^59.0.1",
141
- "express": "^4.21.2",
169
+ "express": "^5.1.0",
142
170
  "get-port": "^5.1.1",
143
171
  "glob": "^7.2.3",
144
172
  "globals": "^15.15.0",
@@ -156,6 +184,7 @@
156
184
  "sinon-chai": "^3.7.0",
157
185
  "tap": "^16.3.10",
158
186
  "tiktoken": "^1.0.21",
187
+ "workerpool": "^9.2.0",
159
188
  "yaml": "^2.8.0",
160
189
  "yarn-deduplicate": "^6.0.2"
161
190
  }
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { getUserLandFrames } = require('../dd-trace/src/plugins/util/stacktrace')
3
+ const { parseUserLandFrames } = require('../dd-trace/src/plugins/util/stacktrace')
4
4
 
5
5
  const ENTRY_SPAN_STACK_FRAMES_LIMIT = 1
6
6
  const EXIT_SPAN_STACK_FRAMES_LIMIT = Number(process.env._DD_CODE_ORIGIN_FOR_SPANS_EXIT_SPAN_MAX_USER_FRAMES) || 8
@@ -36,20 +36,25 @@ function exitTags (topOfStackFunc) {
36
36
  * @returns {Record<string, string>}
37
37
  */
38
38
  function tag (type, topOfStackFunc, limit) {
39
- const frames = getUserLandFrames(topOfStackFunc, limit)
39
+ // The `Error.prepareStackTrace` API doesn't support resolving source maps.
40
+ // Fall back to manually parsing the stack trace.
41
+ const dummy = {}
42
+ Error.captureStackTrace(dummy, topOfStackFunc)
43
+ const frames = parseUserLandFrames(dummy.stack, limit)
44
+
40
45
  const tags = {
41
46
  '_dd.code_origin.type': type
42
47
  }
43
48
  for (let i = 0; i < frames.length; i++) {
44
49
  const frame = frames[i]
45
- tags[`_dd.code_origin.frames.${i}.file`] = frame.file
46
- tags[`_dd.code_origin.frames.${i}.line`] = String(frame.line)
47
- tags[`_dd.code_origin.frames.${i}.column`] = String(frame.column)
48
- if (frame.method) {
49
- tags[`_dd.code_origin.frames.${i}.method`] = frame.method
50
+ tags[`_dd.code_origin.frames.${i}.file`] = frame.fileName
51
+ tags[`_dd.code_origin.frames.${i}.line`] = frame.lineNumber
52
+ tags[`_dd.code_origin.frames.${i}.column`] = frame.columnNumber
53
+ if (frame.methodName || frame.functionName) {
54
+ tags[`_dd.code_origin.frames.${i}.method`] = frame.methodName || frame.functionName
50
55
  }
51
- if (frame.type) {
52
- tags[`_dd.code_origin.frames.${i}.type`] = frame.type
56
+ if (frame.typeName) {
57
+ tags[`_dd.code_origin.frames.${i}.type`] = frame.typeName
53
58
  }
54
59
  }
55
60
  return tags
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const {
2
4
  addHook,
3
5
  channel
@@ -16,20 +18,15 @@ const CHANNELS = {
16
18
 
17
19
  const generalErrorCh = channel('apm:apollo:gateway:general:error')
18
20
 
19
- function wrapExecutor (executor) {
20
- return function (...args) {
21
- const channel = CHANNELS['gateway.request']
22
- const ctx = { requestContext: args[0], gateway: this }
23
-
24
- return channel.tracePromise(executor, ctx, this, ...args)
25
- }
26
- }
27
-
28
21
  function wrapApolloGateway (ApolloGateway) {
29
22
  class ApolloGatewayWrapper extends ApolloGateway {
30
23
  constructor (...args) {
31
24
  super(...args)
32
- shimmer.wrap(this, 'executor', wrapExecutor)
25
+ shimmer.wrap(this, 'executor', (originalExecutor) => (...args) => {
26
+ const channel = CHANNELS['gateway.request']
27
+ const ctx = { requestContext: args[0], gateway: this }
28
+ return channel.tracePromise(originalExecutor, ctx, this, ...args)
29
+ })
33
30
  }
34
31
  }
35
32
  return ApolloGatewayWrapper
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const shimmer = require('../../datadog-shimmer')
2
4
  const { addHook } = require('./helpers/instrument')
3
5
 
@@ -4,8 +4,7 @@ const { errorMonitor } = require('events')
4
4
  const util = require('util')
5
5
 
6
6
  const {
7
- addHook,
8
- AsyncResource
7
+ addHook
9
8
  } = require('./helpers/instrument')
10
9
  const shimmer = require('../../datadog-shimmer')
11
10
  const dc = require('dc-polyfill')
@@ -80,7 +79,8 @@ function createContextFromChildProcessInfo (childProcessInfo) {
80
79
  const context = {
81
80
  command: childProcessInfo.command,
82
81
  file: childProcessInfo.file,
83
- shell: childProcessInfo.shell
82
+ shell: childProcessInfo.shell,
83
+ abortController: new AbortController()
84
84
  }
85
85
 
86
86
  if (childProcessInfo.fileArgs) {
@@ -98,17 +98,12 @@ function wrapChildProcessSyncMethod (returnError, shell = false) {
98
98
  }
99
99
 
100
100
  const childProcessInfo = normalizeArgs(arguments, shell)
101
+ const context = createContextFromChildProcessInfo(childProcessInfo)
101
102
 
102
- const innerResource = new AsyncResource('bound-anonymous-fn')
103
- return innerResource.runInAsyncScope(() => {
104
- const context = createContextFromChildProcessInfo(childProcessInfo)
105
- const abortController = new AbortController()
106
-
107
- childProcessChannel.start.publish({ ...context, abortController })
108
-
103
+ return childProcessChannel.start.runStores(context, () => {
109
104
  try {
110
- if (abortController.signal.aborted) {
111
- const error = abortController.signal.reason || new Error('Aborted')
105
+ if (context.abortController.signal.aborted) {
106
+ const error = context.abortController.signal.reason || new Error('Aborted')
112
107
  // expected behaviors on error are different
113
108
  return returnError(error, context)
114
109
  }
@@ -141,21 +136,17 @@ function wrapChildProcessCustomPromisifyMethod (customPromisifyMethod, shell) {
141
136
  const context = createContextFromChildProcessInfo(childProcessInfo)
142
137
 
143
138
  const { start, end, asyncStart, asyncEnd, error } = childProcessChannel
144
- const abortController = new AbortController()
145
-
146
- start.publish({
147
- ...context,
148
- abortController
149
- })
139
+ start.publish(context)
150
140
 
151
141
  let result
152
- if (abortController.signal.aborted) {
153
- result = Promise.reject(abortController.signal.reason || new Error('Aborted'))
142
+ if (context.abortController.signal.aborted) {
143
+ result = Promise.reject(context.abortController.signal.reason || new Error('Aborted'))
154
144
  } else {
155
145
  try {
156
146
  result = customPromisifyMethod.apply(this, arguments)
157
147
  } catch (error) {
158
- error.publish({ ...context, error })
148
+ context.error = error
149
+ error.publish(context)
159
150
  throw error
160
151
  } finally {
161
152
  end.publish(context)
@@ -192,26 +183,15 @@ function wrapChildProcessAsyncMethod (ChildProcess, shell = false) {
192
183
 
193
184
  const childProcessInfo = normalizeArgs(arguments, shell)
194
185
 
195
- const cb = arguments[arguments.length - 1]
196
- if (typeof cb === 'function') {
197
- const callbackResource = new AsyncResource('bound-anonymous-fn')
198
- arguments[arguments.length - 1] = callbackResource.bind(cb)
199
- }
200
-
201
- const innerResource = new AsyncResource('bound-anonymous-fn')
202
- return innerResource.runInAsyncScope(() => {
203
- const context = createContextFromChildProcessInfo(childProcessInfo)
204
- const abortController = new AbortController()
205
-
206
- childProcessChannel.start.publish({ ...context, abortController })
207
-
186
+ const context = createContextFromChildProcessInfo(childProcessInfo)
187
+ return childProcessChannel.start.runStores(context, () => {
208
188
  let childProcess
209
- if (abortController.signal.aborted) {
189
+ if (context.abortController.signal.aborted) {
210
190
  childProcess = new ChildProcess()
211
191
  childProcess.on('error', () => {}) // Original method does not crash when non subscribers
212
192
 
213
193
  process.nextTick(() => {
214
- const error = abortController.signal.reason || new Error('Aborted')
194
+ const error = context.abortController.signal.reason || new Error('Aborted')
215
195
  childProcess.emit('error', error)
216
196
 
217
197
  const cb = arguments[arguments.length - 1]
@@ -230,17 +210,16 @@ function wrapChildProcessAsyncMethod (ChildProcess, shell = false) {
230
210
 
231
211
  childProcess.on(errorMonitor, (e) => {
232
212
  errorExecuted = true
233
- childProcessChannel.error.publish(e)
213
+ context.error = e
214
+ childProcessChannel.error.publish(context)
234
215
  })
235
216
 
236
217
  childProcess.on('close', (code = 0) => {
237
218
  if (!errorExecuted && code !== 0) {
238
- childProcessChannel.error.publish()
219
+ childProcessChannel.error.publish(context)
239
220
  }
240
- childProcessChannel.asyncEnd.publish({
241
- ...context,
242
- result: code
243
- })
221
+ context.result = code
222
+ childProcessChannel.asyncEnd.publish(context)
244
223
  })
245
224
  }
246
225
 
@@ -43,6 +43,7 @@ const {
43
43
  CUCUMBER_WORKER_TRACE_PAYLOAD_CODE,
44
44
  getIsFaultyEarlyFlakeDetection
45
45
  } = require('../../dd-trace/src/plugins/util/test')
46
+ const satisfies = require('semifies')
46
47
 
47
48
  const isMarkedAsUnskippable = (pickle) => {
48
49
  return pickle.tags.some(tag => tag.name === '@datadog:unskippable')
@@ -224,7 +225,7 @@ function getPickleByFile (runtimeOrCoodinator) {
224
225
  }, {})
225
226
  }
226
227
 
227
- function wrapRun (pl, isLatestVersion) {
228
+ function wrapRun (pl, isLatestVersion, version) {
228
229
  if (patched.has(pl)) return
229
230
 
230
231
  patched.add(pl)
@@ -398,9 +399,10 @@ function wrapRun (pl, isLatestVersion) {
398
399
  const promise = runStep.apply(this, arguments)
399
400
 
400
401
  promise.then((result) => {
401
- const { status, skipReason, errorMessage } = isLatestVersion
402
- ? getStatusFromResultLatest(result)
403
- : getStatusFromResult(result)
402
+ const finalResult = satisfies(version, '>=12.0.0') ? result.result : result
403
+ const getStatus = satisfies(version, '>=7.3.0') ? getStatusFromResultLatest : getStatusFromResult
404
+
405
+ const { status, skipReason, errorMessage } = getStatus(finalResult)
404
406
 
405
407
  testFinishCh.publish({ isStep: true, status, skipReason, errorMessage, ...ctx.currentStore })
406
408
  })
@@ -415,18 +417,18 @@ function wrapRun (pl, isLatestVersion) {
415
417
  })
416
418
  }
417
419
 
418
- function pickleHook (PickleRunner) {
420
+ function pickleHook (PickleRunner, version) {
419
421
  const pl = PickleRunner.default
420
422
 
421
- wrapRun(pl, false)
423
+ wrapRun(pl, false, version)
422
424
 
423
425
  return PickleRunner
424
426
  }
425
427
 
426
- function testCaseHook (TestCaseRunner) {
428
+ function testCaseHook (TestCaseRunner, version) {
427
429
  const pl = TestCaseRunner.default
428
430
 
429
- wrapRun(pl, true)
431
+ wrapRun(pl, true, version)
430
432
 
431
433
  return TestCaseRunner
432
434
  }
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { addHook } = require('./helpers/instrument')
2
4
  const { DD_MAJOR } = require('../../../version')
3
5
 
@@ -14,6 +14,7 @@ const pathParamsReadCh = channel('datadog:fastify:path-params:finish')
14
14
 
15
15
  const parsingResources = new WeakMap()
16
16
  const cookiesPublished = new WeakSet()
17
+ const bodyPublished = new WeakSet()
17
18
 
18
19
  function wrapFastify (fastify, hasParsingEvents) {
19
20
  if (typeof fastify !== 'function') return fastify
@@ -124,6 +125,20 @@ function preHandler (request, reply, done) {
124
125
  if (!reply || typeof reply.send !== 'function') return done()
125
126
 
126
127
  const req = getReq(request)
128
+ const res = getRes(reply)
129
+
130
+ const hasBody = request.body && Object.keys(request.body).length > 0
131
+
132
+ // For multipart/form-data, the body is not available until after preValidation hook
133
+ if (bodyParserReadCh.hasSubscribers && hasBody && !bodyPublished.has(req)) {
134
+ const abortController = new AbortController()
135
+
136
+ bodyParserReadCh.publish({ req, res, body: request.body, abortController })
137
+
138
+ bodyPublished.add(req)
139
+
140
+ if (abortController.signal.aborted) return
141
+ }
127
142
 
128
143
  reply.send = wrapSend(reply.send, req)
129
144
 
@@ -151,11 +166,14 @@ function preValidation (request, reply, done) {
151
166
  if (abortController.signal.aborted) return
152
167
  }
153
168
 
154
- if (bodyParserReadCh.hasSubscribers && request.body) {
169
+ // Analyze body before schema validation
170
+ if (bodyParserReadCh.hasSubscribers && request.body && !bodyPublished.has(req)) {
155
171
  abortController ??= new AbortController()
156
172
 
157
173
  bodyParserReadCh.publish({ req, res, body: request.body, abortController })
158
174
 
175
+ bodyPublished.add(req)
176
+
159
177
  if (abortController.signal.aborted) return
160
178
  }
161
179
 
@@ -58,6 +58,7 @@ module.exports = {
58
58
  grpc: () => require('../grpc'),
59
59
  handlebars: () => require('../handlebars'),
60
60
  hapi: () => require('../hapi'),
61
+ hono: { esmFirst: true, fn: () => require('../hono') },
61
62
  http: () => require('../http'),
62
63
  http2: () => require('../http2'),
63
64
  https: () => require('../http'),
@@ -207,7 +207,7 @@ function filename (name, file) {
207
207
  // This function captures the instrumentation file name for a given package by parsing the hook require
208
208
  // function given the module name. It is used to ensure that instrumentations such as redis
209
209
  // that have several different modules being hooked, ie: 'redis' main package, and @redis/client submodule
210
- // return a consistent instrumentation name. This is used later to ensure that atleast some portion of
210
+ // return a consistent instrumentation name. This is used later to ensure that at least some portion of
211
211
  // the integration was successfully instrumented. Prevents incorrect `Found incompatible integration version: ` messages
212
212
  // Example:
213
213
  // redis -> "() => require('../redis')" -> redis
@@ -0,0 +1,102 @@
1
+ 'use strict'
2
+
3
+ const shimmer = require('../../datadog-shimmer')
4
+ const {
5
+ addHook,
6
+ channel
7
+ } = require('./helpers/instrument')
8
+
9
+ const routeChannel = channel('apm:hono:request:route')
10
+ const handleChannel = channel('apm:hono:request:handle')
11
+ const errorChannel = channel('apm:hono:request:error')
12
+
13
+ function wrapFetch (fetch) {
14
+ return function (request, env, executionCtx) {
15
+ handleChannel.publish({ req: env.incoming })
16
+ return fetch.apply(this, arguments)
17
+ }
18
+ }
19
+
20
+ function wrapCompose (compose) {
21
+ return function (middleware, onError, onNotFound) {
22
+ const instrumentedOnError = (...args) => {
23
+ const [error, context] = args
24
+ const req = context.env.incoming
25
+ errorChannel.publish({ req, error })
26
+ return onError(...args)
27
+ }
28
+
29
+ const instrumentedMiddlewares = middleware.map(h => {
30
+ const [[fn, meta], params] = h
31
+
32
+ // TODO: handle middleware instrumentation
33
+ const instrumentedFn = (...args) => {
34
+ const context = args[0]
35
+ const req = context.env.incoming
36
+ const route = meta.path
37
+ routeChannel.publish({
38
+ req,
39
+ route
40
+ })
41
+ return fn(...args)
42
+ }
43
+ return [[instrumentedFn, meta], params]
44
+ })
45
+ return compose.apply(this, [instrumentedMiddlewares, instrumentedOnError, onNotFound])
46
+ }
47
+ }
48
+
49
+ addHook({
50
+ name: 'hono',
51
+ versions: ['>=4'],
52
+ file: 'dist/hono.js'
53
+ }, hono => {
54
+ class Hono extends hono.Hono {
55
+ constructor (...args) {
56
+ super(...args)
57
+ shimmer.wrap(this, 'fetch', wrapFetch)
58
+ }
59
+ }
60
+
61
+ hono.Hono = Hono
62
+
63
+ return hono
64
+ })
65
+
66
+ addHook({
67
+ name: 'hono',
68
+ versions: ['>=4'],
69
+ file: 'dist/cjs/hono.js'
70
+ }, hono => {
71
+ class Hono extends hono.Hono {
72
+ constructor (...args) {
73
+ super(...args)
74
+ shimmer.wrap(this, 'fetch', wrapFetch)
75
+ }
76
+ }
77
+
78
+ return Object.create(hono, {
79
+ Hono: {
80
+ get () {
81
+ return Hono
82
+ },
83
+ enumerable: true,
84
+ }
85
+ })
86
+ })
87
+
88
+ addHook({
89
+ name: 'hono',
90
+ versions: ['>=4'],
91
+ file: 'dist/cjs/compose.js'
92
+ }, Compose => {
93
+ return shimmer.wrap(Compose, 'compose', wrapCompose, { replaceGetter: true })
94
+ })
95
+
96
+ addHook({
97
+ name: 'hono',
98
+ versions: ['>=4'],
99
+ file: 'dist/compose.js'
100
+ }, Compose => {
101
+ return shimmer.wrap(Compose, 'compose', wrapCompose)
102
+ })
@@ -53,6 +53,27 @@ for (const extension of extensions) {
53
53
  return exports
54
54
  })
55
55
 
56
+ addHook({ name: '@langchain/core', file: `dist/tools/index.${extension}`, versions: ['>=0.1'] }, exports => {
57
+ if (extension === 'cjs') {
58
+ wrap(exports.StructuredTool.prototype, 'invoke', 'orchestrion:@langchain/core:Tool_invoke')
59
+ }
60
+ return exports
61
+ })
62
+
63
+ addHook({ name: '@langchain/core', file: `dist/vectorstores.${extension}`, versions: ['>=0.1'] }, exports => {
64
+ if (extension === 'cjs') {
65
+ wrap(
66
+ exports.VectorStore.prototype, 'similaritySearch', 'orchestrion:@langchain/core:VectorStore_similaritySearch'
67
+ )
68
+ wrap(
69
+ exports.VectorStore.prototype, 'similaritySearchWithScore',
70
+ 'orchestrion:@langchain/core:VectorStore_similaritySearchWithScore'
71
+ )
72
+ }
73
+
74
+ return exports
75
+ })
76
+
56
77
  addHook({ name: '@langchain/core', file: `dist/embeddings.${extension}`, versions: ['>=0.1'] }, exports => {
57
78
  if (extension === 'cjs') {
58
79
  shimmer.wrap(exports, 'Embeddings', Embeddings => {
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { addHook, channel } = require('../helpers/instrument')
2
4
  const shimmer = require('../../../datadog-shimmer')
3
5
  const { getCallSites } = require('../../../dd-trace/src/plugins/util/stacktrace')
@@ -1,3 +1,5 @@
1
+ 'use strict'
2
+
1
3
  const { getEnvironmentVariable } = require('../../dd-trace/src/config-helper')
2
4
 
3
5
  if (getEnvironmentVariable('MOCHA_WORKER_ID')) {