dd-trace 4.18.0 → 5.6.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 (209) hide show
  1. package/CONTRIBUTING.md +98 -0
  2. package/LICENSE-3rdparty.csv +4 -5
  3. package/MIGRATING.md +15 -0
  4. package/README.md +20 -140
  5. package/ci/cypress/after-run.js +1 -0
  6. package/ci/cypress/after-spec.js +1 -0
  7. package/ci/init.js +1 -4
  8. package/ext/kinds.d.ts +1 -0
  9. package/ext/kinds.js +2 -1
  10. package/ext/tags.d.ts +2 -1
  11. package/ext/tags.js +6 -1
  12. package/index.d.ts +1523 -1460
  13. package/package.json +19 -19
  14. package/packages/datadog-core/src/storage/async_resource.js +1 -1
  15. package/packages/datadog-core/src/utils/src/get.js +11 -0
  16. package/packages/datadog-core/src/utils/src/has.js +14 -0
  17. package/packages/datadog-core/src/utils/src/kebabcase.js +16 -0
  18. package/packages/datadog-core/src/utils/src/pick.js +11 -0
  19. package/packages/datadog-core/src/utils/src/set.js +16 -0
  20. package/packages/datadog-core/src/utils/src/uniq.js +5 -0
  21. package/packages/datadog-esbuild/index.js +1 -20
  22. package/packages/datadog-instrumentations/src/aerospike.js +47 -0
  23. package/packages/datadog-instrumentations/src/amqplib.js +2 -2
  24. package/packages/datadog-instrumentations/src/apollo-server-core.js +41 -0
  25. package/packages/datadog-instrumentations/src/apollo-server.js +83 -0
  26. package/packages/datadog-instrumentations/src/child_process.js +150 -0
  27. package/packages/datadog-instrumentations/src/couchbase.js +5 -4
  28. package/packages/datadog-instrumentations/src/crypto.js +2 -1
  29. package/packages/datadog-instrumentations/src/cucumber.js +163 -46
  30. package/packages/datadog-instrumentations/src/dns.js +2 -1
  31. package/packages/datadog-instrumentations/src/express.js +20 -0
  32. package/packages/datadog-instrumentations/src/graphql.js +18 -4
  33. package/packages/datadog-instrumentations/src/grpc/client.js +56 -36
  34. package/packages/datadog-instrumentations/src/grpc/server.js +3 -1
  35. package/packages/datadog-instrumentations/src/helpers/bundler-register.js +1 -2
  36. package/packages/datadog-instrumentations/src/helpers/hooks.js +12 -3
  37. package/packages/datadog-instrumentations/src/helpers/instrument.js +9 -4
  38. package/packages/datadog-instrumentations/src/helpers/register.js +19 -3
  39. package/packages/datadog-instrumentations/src/http/client.js +12 -2
  40. package/packages/datadog-instrumentations/src/http/server.js +7 -4
  41. package/packages/datadog-instrumentations/src/http2/client.js +3 -1
  42. package/packages/datadog-instrumentations/src/http2/server.js +3 -1
  43. package/packages/datadog-instrumentations/src/jest.js +239 -52
  44. package/packages/datadog-instrumentations/src/kafkajs.js +27 -0
  45. package/packages/datadog-instrumentations/src/mocha.js +154 -18
  46. package/packages/datadog-instrumentations/src/mongodb-core.js +34 -3
  47. package/packages/datadog-instrumentations/src/mongoose.js +23 -10
  48. package/packages/datadog-instrumentations/src/mquery.js +65 -0
  49. package/packages/datadog-instrumentations/src/net.js +10 -2
  50. package/packages/datadog-instrumentations/src/next.js +35 -9
  51. package/packages/datadog-instrumentations/src/playwright.js +110 -16
  52. package/packages/datadog-instrumentations/src/restify.js +14 -1
  53. package/packages/datadog-instrumentations/src/rhea.js +15 -9
  54. package/packages/datadog-plugin-aerospike/src/index.js +113 -0
  55. package/packages/datadog-plugin-amqplib/src/consumer.js +14 -1
  56. package/packages/datadog-plugin-amqplib/src/producer.js +13 -1
  57. package/packages/datadog-plugin-aws-sdk/src/base.js +3 -2
  58. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +163 -27
  59. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +46 -8
  60. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +129 -22
  61. package/packages/datadog-plugin-child_process/src/index.js +91 -0
  62. package/packages/datadog-plugin-child_process/src/scrub-cmd-params.js +125 -0
  63. package/packages/datadog-plugin-cucumber/src/index.js +70 -13
  64. package/packages/datadog-plugin-cypress/src/after-run.js +3 -0
  65. package/packages/datadog-plugin-cypress/src/after-spec.js +3 -0
  66. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +625 -0
  67. package/packages/datadog-plugin-cypress/src/plugin.js +6 -454
  68. package/packages/datadog-plugin-cypress/src/support.js +50 -3
  69. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +2 -0
  70. package/packages/datadog-plugin-graphql/src/index.js +1 -6
  71. package/packages/datadog-plugin-graphql/src/resolve.js +28 -18
  72. package/packages/datadog-plugin-grpc/src/client.js +16 -2
  73. package/packages/datadog-plugin-grpc/src/util.js +1 -1
  74. package/packages/datadog-plugin-http/src/client.js +19 -2
  75. package/packages/datadog-plugin-jest/src/index.js +118 -12
  76. package/packages/datadog-plugin-jest/src/util.js +38 -16
  77. package/packages/datadog-plugin-kafkajs/src/consumer.js +76 -6
  78. package/packages/datadog-plugin-kafkajs/src/producer.js +64 -8
  79. package/packages/datadog-plugin-mocha/src/index.js +87 -17
  80. package/packages/datadog-plugin-next/src/index.js +40 -14
  81. package/packages/datadog-plugin-playwright/src/index.js +71 -8
  82. package/packages/datadog-plugin-rhea/src/consumer.js +16 -1
  83. package/packages/datadog-plugin-rhea/src/producer.js +10 -0
  84. package/packages/dd-trace/src/appsec/activation.js +29 -0
  85. package/packages/dd-trace/src/appsec/addresses.js +5 -1
  86. package/packages/dd-trace/src/appsec/api_security_sampler.js +61 -0
  87. package/packages/dd-trace/src/appsec/blocked_templates.js +4 -1
  88. package/packages/dd-trace/src/appsec/blocking.js +95 -43
  89. package/packages/dd-trace/src/appsec/channels.js +7 -3
  90. package/packages/dd-trace/src/appsec/graphql.js +146 -0
  91. package/packages/dd-trace/src/appsec/iast/analyzers/analyzers.js +2 -0
  92. package/packages/dd-trace/src/appsec/iast/analyzers/command-injection-analyzer.js +1 -1
  93. package/packages/dd-trace/src/appsec/iast/analyzers/header-injection-analyzer.js +105 -0
  94. package/packages/dd-trace/src/appsec/iast/analyzers/nosql-injection-mongodb-analyzer.js +22 -17
  95. package/packages/dd-trace/src/appsec/iast/analyzers/sql-injection-analyzer.js +7 -28
  96. package/packages/dd-trace/src/appsec/iast/analyzers/vulnerability-analyzer.js +10 -6
  97. package/packages/dd-trace/src/appsec/iast/analyzers/weak-randomness-analyzer.js +19 -0
  98. package/packages/dd-trace/src/appsec/iast/context/context-plugin.js +90 -0
  99. package/packages/dd-trace/src/appsec/iast/context/kafka-ctx-plugin.js +14 -0
  100. package/packages/dd-trace/src/appsec/iast/iast-log.js +1 -1
  101. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +13 -2
  102. package/packages/dd-trace/src/appsec/iast/index.js +15 -5
  103. package/packages/dd-trace/src/appsec/iast/overhead-controller.js +1 -1
  104. package/packages/dd-trace/src/appsec/iast/path-line.js +1 -1
  105. package/packages/dd-trace/src/appsec/iast/taint-tracking/csi-methods.js +2 -0
  106. package/packages/dd-trace/src/appsec/iast/taint-tracking/index.js +10 -0
  107. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations-taint-object.js +53 -0
  108. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +10 -46
  109. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +13 -9
  110. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugins/kafka.js +47 -0
  111. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +19 -6
  112. package/packages/dd-trace/src/appsec/iast/taint-tracking/source-types.js +3 -1
  113. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +41 -3
  114. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/constants.js +7 -0
  115. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/command-sensitive-analyzer.js +12 -19
  116. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/header-sensitive-analyzer.js +20 -0
  117. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/json-sensitive-analyzer.js +6 -10
  118. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/ldap-sensitive-analyzer.js +18 -25
  119. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/sql-sensitive-analyzer.js +79 -85
  120. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-analyzers/url-sensitive-analyzer.js +27 -36
  121. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/evidence-redaction/sensitive-handler.js +14 -11
  122. package/packages/dd-trace/src/appsec/iast/vulnerabilities-formatter/utils.js +1 -1
  123. package/packages/dd-trace/src/appsec/iast/vulnerabilities.js +2 -0
  124. package/packages/dd-trace/src/appsec/index.js +49 -33
  125. package/packages/dd-trace/src/appsec/recommended.json +1763 -106
  126. package/packages/dd-trace/src/appsec/remote_config/capabilities.js +7 -1
  127. package/packages/dd-trace/src/appsec/remote_config/index.js +42 -16
  128. package/packages/dd-trace/src/appsec/remote_config/manager.js +9 -8
  129. package/packages/dd-trace/src/appsec/reporter.js +51 -34
  130. package/packages/dd-trace/src/appsec/rule_manager.js +11 -8
  131. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
  132. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +28 -13
  133. package/packages/dd-trace/src/appsec/waf/waf_manager.js +0 -1
  134. package/packages/dd-trace/src/ci-visibility/{intelligent-test-runner/get-itr-configuration.js → early-flake-detection/get-known-tests.js} +17 -22
  135. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +25 -6
  136. package/packages/dd-trace/src/ci-visibility/exporters/agentless/coverage-writer.js +30 -1
  137. package/packages/dd-trace/src/ci-visibility/exporters/agentless/index.js +2 -0
  138. package/packages/dd-trace/src/ci-visibility/exporters/agentless/writer.js +30 -1
  139. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +95 -37
  140. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +134 -61
  141. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +37 -4
  142. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +131 -0
  143. package/packages/dd-trace/src/ci-visibility/telemetry.js +130 -0
  144. package/packages/dd-trace/src/config.js +561 -470
  145. package/packages/dd-trace/src/data_streams_context.js +1 -1
  146. package/packages/dd-trace/src/datastreams/pathway.js +58 -1
  147. package/packages/dd-trace/src/datastreams/processor.js +196 -27
  148. package/packages/dd-trace/src/datastreams/writer.js +11 -5
  149. package/packages/dd-trace/src/dogstatsd.js +3 -5
  150. package/packages/dd-trace/src/encode/agentless-ci-visibility.js +44 -6
  151. package/packages/dd-trace/src/encode/coverage-ci-visibility.js +14 -0
  152. package/packages/dd-trace/src/exporters/common/agent-info-exporter.js +4 -0
  153. package/packages/dd-trace/src/exporters/common/form-data.js +4 -0
  154. package/packages/dd-trace/src/exporters/common/request.js +21 -3
  155. package/packages/dd-trace/src/format.js +30 -2
  156. package/packages/dd-trace/src/id.js +12 -0
  157. package/packages/dd-trace/src/iitm.js +1 -1
  158. package/packages/dd-trace/src/log/channels.js +1 -1
  159. package/packages/dd-trace/src/noop/proxy.js +4 -0
  160. package/packages/dd-trace/src/noop/span.js +1 -0
  161. package/packages/dd-trace/src/opentelemetry/span.js +104 -4
  162. package/packages/dd-trace/src/opentelemetry/tracer.js +9 -10
  163. package/packages/dd-trace/src/opentracing/propagation/text_map.js +16 -7
  164. package/packages/dd-trace/src/opentracing/span.js +48 -4
  165. package/packages/dd-trace/src/opentracing/span_context.js +15 -6
  166. package/packages/dd-trace/src/opentracing/tracer.js +4 -3
  167. package/packages/dd-trace/src/plugin_manager.js +1 -1
  168. package/packages/dd-trace/src/plugins/ci_plugin.js +78 -19
  169. package/packages/dd-trace/src/plugins/database.js +1 -1
  170. package/packages/dd-trace/src/plugins/index.js +7 -0
  171. package/packages/dd-trace/src/plugins/plugin.js +1 -1
  172. package/packages/dd-trace/src/plugins/util/ci.js +6 -19
  173. package/packages/dd-trace/src/plugins/util/git.js +104 -22
  174. package/packages/dd-trace/src/plugins/util/ip_extractor.js +7 -6
  175. package/packages/dd-trace/src/plugins/util/test.js +60 -10
  176. package/packages/dd-trace/src/plugins/util/url.js +26 -0
  177. package/packages/dd-trace/src/plugins/util/user-provided-git.js +4 -16
  178. package/packages/dd-trace/src/plugins/util/web.js +1 -1
  179. package/packages/dd-trace/src/priority_sampler.js +30 -38
  180. package/packages/dd-trace/src/profiler.js +5 -3
  181. package/packages/dd-trace/src/profiling/config.js +77 -24
  182. package/packages/dd-trace/src/profiling/exporters/agent.js +77 -31
  183. package/packages/dd-trace/src/profiling/exporters/file.js +2 -1
  184. package/packages/dd-trace/src/profiling/profiler.js +33 -22
  185. package/packages/dd-trace/src/profiling/profilers/events.js +270 -0
  186. package/packages/dd-trace/src/profiling/profilers/shared.js +45 -0
  187. package/packages/dd-trace/src/profiling/profilers/space.js +18 -2
  188. package/packages/dd-trace/src/profiling/profilers/wall.js +146 -70
  189. package/packages/dd-trace/src/proxy.js +56 -24
  190. package/packages/dd-trace/src/ritm.js +1 -1
  191. package/packages/dd-trace/src/sampling_rule.js +130 -0
  192. package/packages/dd-trace/src/service-naming/schemas/v0/storage.js +5 -0
  193. package/packages/dd-trace/src/service-naming/schemas/v1/storage.js +4 -0
  194. package/packages/dd-trace/src/span_processor.js +9 -1
  195. package/packages/dd-trace/src/span_sampler.js +6 -64
  196. package/packages/dd-trace/src/spanleak.js +98 -0
  197. package/packages/dd-trace/src/startup-log.js +7 -1
  198. package/packages/dd-trace/src/telemetry/dependencies.js +56 -10
  199. package/packages/dd-trace/src/telemetry/index.js +182 -53
  200. package/packages/dd-trace/src/telemetry/logs/index.js +2 -2
  201. package/packages/dd-trace/src/telemetry/send-data.js +65 -7
  202. package/packages/dd-trace/src/tracer.js +12 -5
  203. package/register.js +4 -0
  204. package/scripts/install_plugin_modules.js +11 -3
  205. package/scripts/st.js +105 -0
  206. package/packages/datadog-instrumentations/src/child-process.js +0 -30
  207. package/packages/dd-trace/src/plugins/util/exec.js +0 -13
  208. package/packages/diagnostics_channel/index.js +0 -3
  209. package/packages/diagnostics_channel/src/index.js +0 -121
package/CONTRIBUTING.md CHANGED
@@ -70,4 +70,102 @@ We follow an all-green policy which means that for any PR to be merged _all_ tes
70
70
 
71
71
  Eventually we plan to look into putting these permission-required tests behind a label which team members can add to their PRs at creation to run the full CI and can add to outside contributor PRs to trigger the CI from their own user credentials. If the label is not present there will be another action which checks the label is present. Rather than showing a bunch of confusing failures to new contributors it would just show a single job failure which indicates an additional label is required, and we can name it in a way that makes it clear that it's not the responsibility of the outside contributor to add it. Something like `approve-full-ci` is one possible choice there.
72
72
 
73
+ ## Development Requirements
74
+
75
+ Since this project supports multiple Node versions, using a version
76
+ manager such as [nvm](https://github.com/creationix/nvm) is recommended.
77
+
78
+ We use [yarn](https://yarnpkg.com/) for its workspace functionality, so make sure to install that as well.
79
+
80
+ To install dependencies once you have Node and yarn installed, run:
81
+
82
+ ```sh
83
+ $ yarn
84
+ ```
85
+
86
+
87
+ ## Testing
88
+
89
+ Before running _plugin_ tests, the data stores need to be running.
90
+ The easiest way to start all of them is to use the provided
91
+ docker-compose configuration:
92
+
93
+ ```sh
94
+ $ docker-compose up -d -V --remove-orphans --force-recreate
95
+ $ yarn services
96
+ ```
97
+
98
+ > **Note**
99
+ > The `couchbase`, `grpc` and `oracledb` instrumentations rely on native modules
100
+ > that do not compile on ARM64 devices (for example M1/M2 Mac) - their tests
101
+ > cannot be run locally on these devices.
102
+
103
+ ### Unit Tests
104
+
105
+ There are several types of unit tests, for various types of components. The
106
+ following commands may be useful:
107
+
108
+ ```sh
109
+ # Tracer core tests (i.e. testing `packages/dd-trace`)
110
+ $ yarn test:trace:core
111
+ # "Core" library tests (i.e. testing `packages/datadog-core`
112
+ $ yarn test:core
113
+ # Instrumentations tests (i.e. testing `packages/datadog-instrumentations`
114
+ $ yarn test:instrumentations
115
+ ```
116
+
117
+ Several other components have test commands as well. See `package.json` for
118
+ details.
119
+
120
+ To test _plugins_ (i.e. components in `packages/datadog-plugin-XXXX`
121
+ directories, set the `PLUGINS` environment variable to the plugin you're
122
+ interested in, and use `yarn test:plugins`. If you need to test multiple
123
+ plugins you may separate then with a pipe (`|`) delimiter. Here's an
124
+ example testing the `express` and `bluebird` plugins:
125
+
126
+ ```sh
127
+ PLUGINS="express|bluebird" yarn test:plugins
128
+ ```
129
+
130
+
131
+ ### Memory Leaks
132
+
133
+ To run the memory leak tests, use:
134
+
135
+ ```sh
136
+ $ yarn leak:core
137
+
138
+ # or
139
+
140
+ $ yarn leak:plugins
141
+ ```
142
+
143
+
144
+ ### Linting
145
+
146
+ We use [ESLint](https://eslint.org) to make sure that new code
147
+ conforms to our coding standards.
148
+
149
+ To run the linter, use:
150
+
151
+ ```sh
152
+ $ yarn lint
153
+ ```
154
+
155
+
156
+ ### Benchmarks
157
+
158
+ Our microbenchmarks live in `benchmark/sirun`. Each directory in there
159
+ corresponds to a specific benchmark test and its variants, which are used to
160
+ track regressions and improvements over time.
161
+
162
+ In addition to those, when two or more approaches must be compared, please write
163
+ a benchmark in the `benchmark/index.js` module so that we can keep track of the
164
+ most efficient algorithm. To run your benchmark, use:
165
+
166
+ ```sh
167
+ $ yarn bench
168
+ ```
169
+
170
+
73
171
  [1]: https://docs.datadoghq.com/help
@@ -8,7 +8,7 @@ require,@datadog/sketches-js,Apache license 2.0,Copyright 2020 Datadog Inc.
8
8
  require,@opentelemetry/api,Apache license 2.0,Copyright OpenTelemetry Authors
9
9
  require,@opentelemetry/core,Apache license 2.0,Copyright OpenTelemetry Authors
10
10
  require,crypto-randomuuid,MIT,Copyright 2021 Node.js Foundation and contributors
11
- require,diagnostics_channel,MIT,Copyright 2021 Simon D.
11
+ require,dc-polyfill,MIT,Copyright 2023 Datadog Inc.
12
12
  require,ignore,MIT,Copyright 2013 Kael Zhang and contributors
13
13
  require,import-in-the-middle,Apache license 2.0,Copyright 2021 Datadog Inc.
14
14
  require,int64-buffer,MIT,Copyright 2015-2016 Yusuke Kawasaki
@@ -17,10 +17,7 @@ require,istanbul-lib-coverage,BSD-3-Clause,Copyright 2012-2015 Yahoo! Inc.
17
17
  require,jest-docblock,MIT,Copyright Meta Platforms, Inc. and affiliates.
18
18
  require,koalas,MIT,Copyright 2013-2017 Brian Woodward
19
19
  require,limiter,MIT,Copyright 2011 John Hurliman
20
- require,lodash.kebabcase,MIT,Copyright JS Foundation and other contributors
21
- require,lodash.pick,MIT,Copyright JS Foundation and other contributors
22
20
  require,lodash.sortby,MIT,Copyright JS Foundation and other contributors
23
- require,lodash.uniq,MIT,Copyright JS Foundation and other contributors
24
21
  require,lru-cache,ISC,Copyright (c) 2010-2022 Isaac Z. Schlueter and Contributors
25
22
  require,methods,MIT,Copyright 2013-2014 TJ Holowaychuk
26
23
  require,module-details-from-path,MIT,Copyright 2016 Thomas Watson Steen
@@ -28,9 +25,12 @@ require,msgpack-lite,MIT,Copyright 2015 Yusuke Kawasaki
28
25
  require,node-abort-controller,MIT,Copyright (c) 2019 Steve Faulkner
29
26
  require,opentracing,MIT,Copyright 2016 Resonance Labs Inc
30
27
  require,path-to-regexp,MIT,Copyright 2014 Blake Embrey
28
+ require,pprof-format,MIT,Copyright 2022 Stephen Belanger
31
29
  require,protobufjs,BSD-3-Clause,Copyright 2016 Daniel Wirtz
30
+ require,tlhunter-sorted-set,MIT,Copyright (c) 2023 Datadog Inc.
32
31
  require,retry,MIT,Copyright 2011 Tim Koschützki Felix Geisendörfer
33
32
  require,semver,ISC,Copyright Isaac Z. Schlueter and Contributors
33
+ require,shell-quote,mit,Copyright (c) 2013 James Halliday
34
34
  dev,@types/node,MIT,Copyright Authors
35
35
  dev,autocannon,MIT,Copyright 2016 Matteo Collina
36
36
  dev,aws-sdk,Apache 2.0,Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
@@ -62,7 +62,6 @@ dev,mocha,MIT,Copyright 2011-2018 JS Foundation and contributors https://js.foun
62
62
  dev,multer,MIT,Copyright 2014 Hage Yaapa
63
63
  dev,nock,MIT,Copyright 2017 Pedro Teixeira and other contributors
64
64
  dev,nyc,ISC,Copyright 2015 Contributors
65
- dev,pprof-format,MIT,Copyright 2022 Stephen Belanger
66
65
  dev,proxyquire,MIT,Copyright 2013 Thorsten Lorenz
67
66
  dev,rimraf,ISC,Copyright Isaac Z. Schlueter and Contributors
68
67
  dev,sinon,BSD-3-Clause,Copyright 2010-2017 Christian Johansen
package/MIGRATING.md CHANGED
@@ -4,6 +4,21 @@ This guide describes the steps to upgrade dd-trace from a major version to the
4
4
  next. If you are having any issues related to migrating, please feel free to
5
5
  open an issue or contact our [support](https://www.datadoghq.com/support/) team.
6
6
 
7
+ ## 4.0 to 5.0
8
+
9
+ ### Node 16 is no longer supported
10
+
11
+ Node.js 16 has reached EOL in September 2023 and is no longer supported. Generally
12
+ speaking, we highly recommend always keeping Node.js up to date regardless of
13
+ our support policy.
14
+
15
+ ### Update `trace<T>` TypeScript declaration
16
+
17
+ The TypeScript declaration for `trace<T>` has been updated to enforce
18
+ that calls to `tracer.trace(name, fn)` must receive a function which takes at least
19
+ the span object. Previously the span was technically optional when it should not have
20
+ been as the span must be handled.
21
+
7
22
  ## 3.0 to 4.0
8
23
 
9
24
  ### Node 14 is no longer supported
package/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # `dd-trace`: Node.js APM Tracer Library
2
2
 
3
- [![npm v4](https://img.shields.io/npm/v/dd-trace/latest?color=blue&label=dd-trace%40v4&logo=npm)](https://www.npmjs.com/package/dd-trace)
4
- [![npm v3](https://img.shields.io/npm/v/dd-trace/latest-node14?color=blue&label=dd-trace%40v3&logo=npm)](https://www.npmjs.com/package/dd-trace/v/latest-node12)
3
+ [![npm v5](https://img.shields.io/npm/v/dd-trace/latest?color=blue&label=dd-trace%40v5&logo=npm)](https://www.npmjs.com/package/dd-trace)
4
+ [![npm v4](https://img.shields.io/npm/v/dd-trace/latest-node16?color=blue&label=dd-trace%40v4&logo=npm)](https://www.npmjs.com/package/dd-trace/v/latest-node16)
5
+ [![npm v3](https://img.shields.io/npm/v/dd-trace/latest-node14?color=blue&label=dd-trace%40v3&logo=npm)](https://www.npmjs.com/package/dd-trace/v/latest-node14)
5
6
  [![codecov](https://codecov.io/gh/DataDog/dd-trace-js/branch/master/graph/badge.svg)](https://codecov.io/gh/DataDog/dd-trace-js)
6
7
 
7
8
  <img align="right" src="https://user-images.githubusercontent.com/551402/208212084-1d0c07e2-4135-4c61-b2da-8f2fddbc66ed.png" alt="Bits the dog JavaScript" width="200px"/>
@@ -28,24 +29,25 @@ Most of the documentation for `dd-trace` is available on these webpages:
28
29
  | [`v1`](https://github.com/DataDog/dd-trace-js/tree/v1.x) | ![npm v1](https://img.shields.io/npm/v/dd-trace/legacy-v1?color=white&label=%20&style=flat-square) | `>= v12` | **End of Life** | 2021-07-13 | 2022-02-25 |
29
30
  | [`v2`](https://github.com/DataDog/dd-trace-js/tree/v2.x) | ![npm v2](https://img.shields.io/npm/v/dd-trace/latest-node12?color=white&label=%20&style=flat-square) | `>= v12` | **End of Life** | 2022-01-28 | 2023-08-15 |
30
31
  | [`v3`](https://github.com/DataDog/dd-trace-js/tree/v3.x) | ![npm v3](https://img.shields.io/npm/v/dd-trace/latest-node14?color=white&label=%20&style=flat-square) | `>= v14` | **Maintenance** | 2022-08-15 | 2024-05-15 |
31
- | [`v4`](https://github.com/DataDog/dd-trace-js/tree/v4.x) | ![npm v4](https://img.shields.io/npm/v/dd-trace/latest?color=white&label=%20&style=flat-square) | `>= v16` | **Current** | 2023-05-12 | Unknown |
32
+ | [`v4`](https://github.com/DataDog/dd-trace-js/tree/v4.x) | ![npm v4](https://img.shields.io/npm/v/dd-trace/latest-node16?color=white&label=%20&style=flat-square) | `>= v16` | **Maintenance** | 2023-05-12 | 2025-01-11 |
33
+ | [`v5`](https://github.com/DataDog/dd-trace-js/tree/v5.x) | ![npm v5](https://img.shields.io/npm/v/dd-trace/latest?color=white&label=%20&style=flat-square) | `>= v18` | **Current** | 2024-01-11 | Unknown |
32
34
 
33
- We currently maintain two release lines, namely `v3` and `v4`.
34
- Features and bug fixes that are merged are released to the `v4` line and, if appropriate, also the `v3` line.
35
+ We currently maintain three release lines, namely `v5`, `v4` and `v3`.
36
+ Features and bug fixes that are merged are released to the `v5` line and, if appropriate, also the `v4` & `v3` line.
35
37
 
36
- For any new projects it is recommended to use the `v4` release line:
38
+ For any new projects it is recommended to use the `v5` release line:
37
39
 
38
40
  ```sh
39
41
  $ npm install dd-trace
40
42
  $ yarn add dd-trace
41
43
  ```
42
44
 
43
- However, existing projects that already use the `v3` release line, or projects that need to support EOL versions of Node.js, may continue to use these release lines.
45
+ However, existing projects that already use the `v4` & `v3` release line, or projects that need to support EOL versions of Node.js, may continue to use these release lines.
44
46
  This is done by specifying the version when installing the package.
45
47
 
46
48
  ```sh
47
- $ npm install dd-trace@3
48
- $ yarn add dd-trace@3
49
+ $ npm install dd-trace@4
50
+ $ yarn add dd-trace@4
49
51
  ```
50
52
 
51
53
  Any backwards-breaking functionality that is introduced into the library will result in an increase of the major version of the library and therefore a new release line.
@@ -60,95 +62,12 @@ For more information about library versioning and compatibility, see the [NodeJS
60
62
  Changes associated with each individual release are documented on the [GitHub Releases](https://github.com/DataDog/dd-trace-js/releases) screen.
61
63
 
62
64
 
63
- ## Development
65
+ ## Development and Contribution
64
66
 
65
- Before contributing to this open source project, read our [CONTRIBUTING.md](https://github.com/DataDog/dd-trace-js/blob/master/CONTRIBUTING.md).
67
+ Please read the [CONTRIBUTING.md](https://github.com/DataDog/dd-trace-js/blob/master/CONTRIBUTING.md) document before contributing to this open source project.
66
68
 
67
69
 
68
- ## Requirements
69
-
70
- Since this project supports multiple Node versions, using a version
71
- manager such as [nvm](https://github.com/creationix/nvm) is recommended.
72
-
73
- We use [yarn](https://yarnpkg.com/) for its workspace functionality, so make sure to install that as well.
74
-
75
- To install dependencies once you have Node and yarn installed, run:
76
-
77
- ```sh
78
- $ yarn
79
- ```
80
-
81
-
82
- ## Testing
83
-
84
- Before running _plugin_ tests, the data stores need to be running.
85
- The easiest way to start all of them is to use the provided
86
- docker-compose configuration:
87
-
88
- ```sh
89
- $ docker-compose up -d -V --remove-orphans --force-recreate
90
- $ yarn services
91
- ```
92
-
93
- > **Note**
94
- > The `couchbase`, `grpc` and `oracledb` instrumentations rely on native modules
95
- > that do not compile on ARM64 devices (for example M1/M2 Mac) - their tests
96
- > cannot be run locally on these devices.
97
-
98
- ### Unit Tests
99
-
100
- There are several types of unit tests, for various types of components. The
101
- following commands may be useful:
102
-
103
- ```sh
104
- # Tracer core tests (i.e. testing `packages/dd-trace`)
105
- $ yarn test:trace:core
106
- # "Core" library tests (i.e. testing `packages/datadog-core`
107
- $ yarn test:core
108
- # Instrumentations tests (i.e. testing `packages/datadog-instrumentations`
109
- $ yarn test:instrumentations
110
- ```
111
-
112
- Several other components have test commands as well. See `package.json` for
113
- details.
114
-
115
- To test _plugins_ (i.e. components in `packages/datadog-plugin-XXXX`
116
- directories, set the `PLUGINS` environment variable to the plugin you're
117
- interested in, and use `yarn test:plugins`. If you need to test multiple
118
- plugins you may separate then with a pipe (`|`) delimiter. Here's an
119
- example testing the `express` and `bluebird` plugins:
120
-
121
- ```sh
122
- PLUGINS="express|bluebird" yarn test:plugins
123
- ```
124
-
125
-
126
- ### Memory Leaks
127
-
128
- To run the memory leak tests, use:
129
-
130
- ```sh
131
- $ yarn leak:core
132
-
133
- # or
134
-
135
- $ yarn leak:plugins
136
- ```
137
-
138
-
139
- ### Linting
140
-
141
- We use [ESLint](https://eslint.org) to make sure that new code
142
- conforms to our coding standards.
143
-
144
- To run the linter, use:
145
-
146
- ```sh
147
- $ yarn lint
148
- ```
149
-
150
-
151
- ### Experimental ESM Support
70
+ ## Experimental ESM Support
152
71
 
153
72
  > **Warning**
154
73
  >
@@ -161,26 +80,18 @@ but code loaded using `import` might not always work.
161
80
 
162
81
  Use the following command to enable experimental ESM support with your application:
163
82
 
83
+ Node.js < v20.6
84
+
164
85
  ```sh
165
86
  node --loader dd-trace/loader-hook.mjs entrypoint.js
166
87
  ```
167
88
 
168
-
169
- ### Benchmarks
170
-
171
- Our microbenchmarks live in `benchmark/sirun`. Each directory in there
172
- corresponds to a specific benchmark test and its variants, which are used to
173
- track regressions and improvements over time.
174
-
175
- In addition to those, when two or more approaches must be compared, please write
176
- a benchmark in the `benchmark/index.js` module so that we can keep track of the
177
- most efficient algorithm. To run your benchmark, use:
89
+ Node.js >= v20.6
178
90
 
179
91
  ```sh
180
- $ yarn bench
92
+ node --import dd-trace/register.js entrypoint.js
181
93
  ```
182
94
 
183
-
184
95
  ## Serverless / Lambda
185
96
 
186
97
  Note that there is a separate Lambda project, [datadog-lambda-js](https://github.com/DataDog/datadog-lambda-js), that is responsible for enabling metrics and distributed tracing when your application runs on Lambda.
@@ -192,40 +103,9 @@ Regardless of where you open the issue, someone at Datadog will try to help.
192
103
 
193
104
  ## Bundling
194
105
 
195
- Generally, `dd-trace` works by intercepting `require()` calls that a Node.js application makes when loading modules. This includes modules that are built-in to Node.js, like the `fs` module for accessing the filesystem, as well as modules installed from the npm registry, like the `pg` database module.
196
-
197
- Also generally, bundlers work by crawling all of the `require()` calls that an application makes to files on disk, replacing the `require()` calls with custom code, and then concatenating all of the resulting JavaScript into one "bundled" file. When a built-in module is loaded, like `require('fs')`, that call can then remain the same in the resulting bundle.
198
-
199
- Fundamentally APM tools like `dd-trace` stop working at this point. Perhaps they continue to intercept the calls for built-in modules but don't intercept calls to third party libraries. This means that by default when you bundle a `dd-trace` app with a bundler it is likely to capture information about disk access (via `fs`) and outbound HTTP requests (via `http`), but will otherwise omit calls to third party libraries (like extracting incoming request route information for the `express` framework or showing which query is run for the `mysql` database client).
200
-
201
- To get around this, one can treat all third party modules, or at least third party modules that the APM needs to instrument, as being "external" to the bundler. With this setting the instrumented modules remain on disk and continue to be loaded via `require()` while the non-instrumented modules are bundled. Sadly this results in a build with many extraneous files and starts to defeat the purpose of bundling.
202
-
203
- For these reasons it's necessary to have custom-built bundler plugins. Such plugins are able to instruct the bundler on how to behave, injecting intermediary code and otherwise intercepting the "translated" `require()` calls. The result is that many more packages are then included in the bundled JavaScript file. Some applications can have 100% of modules bundled, however native modules still need to remain external to the bundle.
204
-
205
- ### Esbuild Support
206
-
207
- This library provides experimental esbuild support in the form of an esbuild plugin, and currently requires at least Node.js v16.17 or v18.7. To use the plugin, make sure you have `dd-trace@3+` installed, and then require the `dd-trace/esbuild` module when building your bundle.
208
-
209
- Here's an example of how one might use `dd-trace` with esbuild:
210
-
211
- ```javascript
212
- const ddPlugin = require('dd-trace/esbuild')
213
- const esbuild = require('esbuild')
214
-
215
- esbuild.build({
216
- entryPoints: ['app.js'],
217
- bundle: true,
218
- outfile: 'out.js',
219
- plugins: [ddPlugin],
220
- platform: 'node', // allows built-in modules to be required
221
- target: ['node16']
222
- }).catch((err) => {
223
- console.error(err)
224
- process.exit(1)
225
- })
226
- ```
106
+ If you would like to trace your bundled application then please read this page on [bundling and dd-trace](https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#bundling). It includes information on how to use our ESBuild plugin and includes caveats for other bundlers.
227
107
 
228
108
 
229
109
  ## Security Vulnerabilities
230
110
 
231
- If you have found a security issue, please contact the security team directly at [security@datadoghq.com](mailto:security@datadoghq.com).
111
+ Please refer to the [SECURITY.md](https://github.com/DataDog/dd-trace-js/blob/master/SECURITY.md) document if you have found a security issue.
@@ -0,0 +1 @@
1
+ module.exports = require('../../packages/datadog-plugin-cypress/src/after-run')
@@ -0,0 +1 @@
1
+ module.exports = require('../../packages/datadog-plugin-cypress/src/after-spec')
package/ci/init.js CHANGED
@@ -1,15 +1,11 @@
1
1
  /* eslint-disable no-console */
2
2
  const tracer = require('../packages/dd-trace')
3
- const { ORIGIN_KEY } = require('../packages/dd-trace/src/constants')
4
3
  const { isTrue } = require('../packages/dd-trace/src/util')
5
4
 
6
5
  const isJestWorker = !!process.env.JEST_WORKER_ID
7
6
 
8
7
  const options = {
9
8
  startupLogs: false,
10
- tags: {
11
- [ORIGIN_KEY]: 'ciapp-test'
12
- },
13
9
  isCiVisibility: true,
14
10
  flushInterval: isJestWorker ? 0 : 5000
15
11
  }
@@ -44,6 +40,7 @@ if (isJestWorker) {
44
40
  if (shouldInit) {
45
41
  tracer.init(options)
46
42
  tracer.use('fs', false)
43
+ tracer.use('child_process', false)
47
44
  }
48
45
 
49
46
  module.exports = tracer
package/ext/kinds.d.ts CHANGED
@@ -3,6 +3,7 @@ declare const kinds: {
3
3
  CLIENT: 'client'
4
4
  PRODUCER: 'producer'
5
5
  CONSUMER: 'consumer'
6
+ INTERNAL: 'internal'
6
7
  }
7
8
 
8
9
  export = kinds
package/ext/kinds.js CHANGED
@@ -4,5 +4,6 @@ module.exports = {
4
4
  SERVER: 'server',
5
5
  CLIENT: 'client',
6
6
  PRODUCER: 'producer',
7
- CONSUMER: 'consumer'
7
+ CONSUMER: 'consumer',
8
+ INTERNAL: 'internal'
8
9
  }
package/ext/tags.d.ts CHANGED
@@ -17,7 +17,8 @@ declare const tags: {
17
17
  HTTP_REQUEST_HEADERS: 'http.request.headers'
18
18
  HTTP_RESPONSE_HEADERS: 'http.response.headers'
19
19
  HTTP_USERAGENT: 'http.useragent',
20
- HTTP_CLIENT_IP: 'http.client_ip'
20
+ HTTP_CLIENT_IP: 'http.client_ip',
21
+ PATHWAY_HASH: 'pathway.hash'
21
22
  }
22
23
 
23
24
  export = tags
package/ext/tags.js CHANGED
@@ -22,7 +22,12 @@ const tags = {
22
22
  HTTP_REQUEST_HEADERS: 'http.request.headers',
23
23
  HTTP_RESPONSE_HEADERS: 'http.response.headers',
24
24
  HTTP_USERAGENT: 'http.useragent',
25
- HTTP_CLIENT_IP: 'http.client_ip'
25
+ HTTP_CLIENT_IP: 'http.client_ip',
26
+
27
+ // Messaging
28
+
29
+ // DSM Specific
30
+ PATHWAY_HASH: 'pathway.hash'
26
31
  }
27
32
 
28
33
  // Deprecated