dd-trace 3.50.0 → 3.52.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 (80) hide show
  1. package/README.md +7 -0
  2. package/ci/cypress/after-spec.js +1 -0
  3. package/index.d.ts +1502 -1485
  4. package/package.json +4 -4
  5. package/packages/datadog-core/src/utils/src/get.js +11 -0
  6. package/packages/datadog-core/src/utils/src/has.js +14 -0
  7. package/packages/datadog-core/src/utils/src/set.js +16 -0
  8. package/packages/datadog-instrumentations/src/amqplib.js +1 -1
  9. package/packages/datadog-instrumentations/src/cucumber.js +2 -1
  10. package/packages/datadog-instrumentations/src/grpc/server.js +3 -1
  11. package/packages/datadog-instrumentations/src/jest.js +11 -5
  12. package/packages/datadog-instrumentations/src/mocha.js +4 -1
  13. package/packages/datadog-instrumentations/src/mongodb-core.js +34 -3
  14. package/packages/datadog-instrumentations/src/playwright.js +78 -16
  15. package/packages/datadog-plugin-amqplib/src/consumer.js +5 -4
  16. package/packages/datadog-plugin-amqplib/src/producer.js +3 -4
  17. package/packages/datadog-plugin-aws-sdk/src/base.js +3 -2
  18. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +4 -11
  19. package/packages/datadog-plugin-aws-sdk/src/services/sns.js +3 -6
  20. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +5 -7
  21. package/packages/datadog-plugin-cucumber/src/index.js +2 -2
  22. package/packages/datadog-plugin-cypress/src/after-spec.js +3 -0
  23. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +123 -58
  24. package/packages/datadog-plugin-cypress/src/support.js +50 -3
  25. package/packages/datadog-plugin-graphql/src/index.js +1 -1
  26. package/packages/datadog-plugin-graphql/src/resolve.js +10 -8
  27. package/packages/datadog-plugin-grpc/src/util.js +1 -1
  28. package/packages/datadog-plugin-jest/src/index.js +13 -4
  29. package/packages/datadog-plugin-kafkajs/src/consumer.js +4 -3
  30. package/packages/datadog-plugin-kafkajs/src/producer.js +3 -5
  31. package/packages/datadog-plugin-mocha/src/index.js +2 -2
  32. package/packages/datadog-plugin-playwright/src/index.js +34 -3
  33. package/packages/datadog-plugin-rhea/src/consumer.js +5 -3
  34. package/packages/datadog-plugin-rhea/src/producer.js +3 -4
  35. package/packages/dd-trace/src/appsec/iast/iast-plugin.js +23 -12
  36. package/packages/dd-trace/src/appsec/iast/index.js +10 -0
  37. package/packages/dd-trace/src/appsec/iast/path-line.js +9 -6
  38. package/packages/dd-trace/src/appsec/iast/taint-tracking/operations.js +1 -1
  39. package/packages/dd-trace/src/appsec/iast/taint-tracking/plugin.js +6 -2
  40. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter-telemetry.js +1 -1
  41. package/packages/dd-trace/src/appsec/iast/taint-tracking/rewriter.js +14 -2
  42. package/packages/dd-trace/src/appsec/iast/taint-tracking/taint-tracking-impl.js +1 -1
  43. package/packages/dd-trace/src/appsec/iast/telemetry/iast-metric.js +34 -27
  44. package/packages/dd-trace/src/appsec/iast/telemetry/namespaces.js +39 -11
  45. package/packages/dd-trace/src/appsec/iast/telemetry/span-tags.js +7 -6
  46. package/packages/dd-trace/src/appsec/recommended.json +67 -27
  47. package/packages/dd-trace/src/appsec/remote_config/index.js +1 -1
  48. package/packages/dd-trace/src/appsec/reporter.js +24 -11
  49. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +1 -3
  50. package/packages/dd-trace/src/ci-visibility/exporters/agent-proxy/index.js +6 -1
  51. package/packages/dd-trace/src/config.js +451 -460
  52. package/packages/dd-trace/src/data_streams_context.js +1 -1
  53. package/packages/dd-trace/src/datastreams/pathway.js +58 -1
  54. package/packages/dd-trace/src/datastreams/processor.js +3 -5
  55. package/packages/dd-trace/src/format.js +0 -1
  56. package/packages/dd-trace/src/lambda/runtime/ritm.js +1 -1
  57. package/packages/dd-trace/src/opentracing/propagation/text_map.js +22 -3
  58. package/packages/dd-trace/src/opentracing/span.js +2 -0
  59. package/packages/dd-trace/src/opentracing/span_context.js +1 -0
  60. package/packages/dd-trace/src/plugins/util/test.js +4 -2
  61. package/packages/dd-trace/src/plugins/util/web.js +1 -1
  62. package/packages/dd-trace/src/priority_sampler.js +11 -6
  63. package/packages/dd-trace/src/profiling/exporters/agent.js +38 -2
  64. package/packages/dd-trace/src/telemetry/index.js +32 -33
  65. package/packages/dd-trace/src/tracer.js +3 -3
  66. package/register.js +4 -0
  67. package/CONTRIBUTING.md +0 -171
  68. package/MIGRATING.md +0 -224
  69. package/packages/dd-trace/src/external-logger/test/index.spec.js +0 -147
  70. package/scripts/check-proposal-labels.js +0 -71
  71. package/scripts/check_licenses.js +0 -69
  72. package/scripts/helpers/color.js +0 -8
  73. package/scripts/helpers/exec.js +0 -22
  74. package/scripts/helpers/title.js +0 -15
  75. package/scripts/install_plugin_modules.js +0 -248
  76. package/scripts/publish_docs.js +0 -21
  77. package/scripts/st.js +0 -105
  78. /package/packages/{utils → datadog-core/src/utils}/src/kebabcase.js +0 -0
  79. /package/packages/{utils → datadog-core/src/utils}/src/pick.js +0 -0
  80. /package/packages/{utils → datadog-core/src/utils}/src/uniq.js +0 -0
package/CONTRIBUTING.md DELETED
@@ -1,171 +0,0 @@
1
- # Contributing to dd-trace-js
2
-
3
- Please reach out before starting work on any major code changes.
4
- This will ensure we avoid duplicating work, or that your code can't be merged due to a rapidly changing
5
- base. If you would like support for a module that is not listed, [contact support][1] to share a request.
6
-
7
- ## Keep changes small and incremental
8
-
9
- Changes should be incremental and understandable. As much as possible, large-scale efforts should be broken up into many PRs over time for better reviewability. If a feature would require more changes to be "complete" it's fine to land partial changes if they are not wired up to anything yet, so long as tests are included which at least prove those parts work in isolation.
10
-
11
- There are great benefits to taking a measured and iterative approach to improvement. When working on code in fewer places there is far less risk of running into merge conflicts or incompatibilities with other systems. Keeping contributions small makes them easy to review which makes that much quicker to land. Additionally, keeping things small and iterative makes it easier for other teams to review and understand what the code does.
12
-
13
- ## Be descriptive
14
-
15
- Sometimes code can be self-documenting, but often it can't. That is especially true to someone reviewing code they haven't worked on. Be conscious of writing code in a self-describing way and leave comments anywhere that self-description fails. This goes a long way towards making even complex code coherent to one not already familiar with it.
16
-
17
- Try to write code in a way the describes the intent when read. For example, verbs can be used for function and method names to communicate that they are used to do some specific action. In doing so it becomes clear when referenced by name elsewhere that it is a function and what the function is meant to do. If a function can not be described with a simple verb it's probably too complex or does too many things.
18
-
19
- ## Give your code space
20
-
21
- Very dense code is hard to read. It helps to make use of empty lines to separate logical groupings of statements. Long lines should be split up into multiple lines to make them more readable. Complex objects or arrays should generally be split over several lines. Sometimes it's a good idea to assign a variable only to immediately use it in a call as it can be more descriptive than just using the expression in place. It's not always clear what an argument is for if it doesn't visibly have a name somehow. Remember, lines are free, our time is not.
22
-
23
- ## Avoid large refactors
24
-
25
- Large refactors should generally be avoided in favour of iterative approaches. For example, rather than rewriting how every plugin works, one might make a special-case plugin that works a bit different for their particular use-case. If several dozen files need to change to add a feature we've probably done something wrong.
26
-
27
- Sometimes new patterns or new ideas emerge which would be a substantial improvement over the existing state. It can be tempting to want to go all-in on a new way to do something, but the code churn can be hard to manage. It's best to introduce such new things incrementally and advocate for their adoption gradually through the rest of the codebase. As old systems are gradually phased out, the infrastructure which supports them can be deleted or relegated to lazy-loading only if and when that specific part of the system needs to be used.
28
-
29
- ## Test everything
30
-
31
- It's very difficult to know if a change is valid unless there are tests to prove it. As an extension of that, it's also difficult to know the _use_ of that code is valid if the way it is integrated is not propertly tested. For this reason we generally favour integration tests over unit tests. If an API is expected to be used in different places or in different ways then it should generally include unit tests too for each unique scenario, however great care should be taken to ensure unit tests are actually testing the _logic_ and not just testing the _mocks_. It's a very common mistake to write a unit test that abstracts away the actual use of the interface so much that it doesn't actually test how that interface works in real-world scenarios. Remember to test how it handles failures, how it operates under heavy load, and how it impacts usability of what its purpose is.
32
-
33
- ## Don't forget benchmarks
34
-
35
- Observability products tend to have quite a bit of their behaviour running in app code hot paths. It's important we extensively benchmark anything we expect to have heavy use to ensure it performs well and we don't cause any significant regressions through future changes. Measuring once at the time of writing is insufficient--a graph with just one data point is not going to tell you much of anything.
36
-
37
- ## Always consider backportability
38
-
39
- To reduce delta between release lines and make it easier for us to support older versions we try as much as possible to backport every change we can. We should be diligent about keeping breaking changes to a minimum and ensuring we don't use language or runtime features which are too new. This way we can generally be confident that a change can be backported.
40
-
41
- To reduce the surface area of a breaking change, the breaking aspects could be placed behind a flag which is disabled by default or isolated to a function. In the next major the change would then be just to change the default of the flag or to start or stop calling the isolated function. By isolating the breaking logic it also becomes easier to delete later when it's no longer relevant on any release line.
42
-
43
- Currently we do not have CI to test PRs for mergeability to past release lines, but we intend to expand our CI to include that in the future. For the time being, it's recommended when developing locally to try to cherry-pick your changes onto the previous vN.x branches to see if the tests pass there too.
44
-
45
- ## Respect semantic versioning
46
-
47
- This library follows the semantic versioning standard, but there are some subtleties left under-specified so this section is meant to clarify exactly how we interpret the meaning of semver. Additionally, it exists to communicate that we also use semver labels on all PRs to indicate which type of release the change should land in. Outside contributions should be evaluated and a semver label selected by the relevant team.
48
-
49
- ### semver-patch
50
-
51
- If the change is a bug or security fix, it should be labelled as semver-patch. These changes should generally not alter existing behaviour in any way other than to correct the specific issue.
52
-
53
- ### semver-minor
54
-
55
- Any addition of new functionality should be labelled as semver-minor and should not change any existing behaviour either in how any existing API works or in changing the contents or value of any existing data being reported except in purely additive cases where all existing data retains its prior state. Such changes may include new configuration options which when used will change behaviour, or may include the addition of new data being captured such as a new instrumentation, but should not impact the current operating design of any existing features.
56
-
57
- ### semver-major
58
-
59
- In the event that some existing functionality _does_ need to change, as much as possible the non-breaking aspects of that change should be made in a semver-minor PR and the actually breaking aspects should be done via a follow-up PR with only the specific aspects which are breaking. Remember to [always consider backportability](#always-consider-backportability).
60
-
61
- ## Indicate intended release targets
62
-
63
- When writing major changes we use a series of labels in the form of `dont-land-on-vN.x` where N is the major release line which a PR should not land in. Every PR marked as semver-major should include these tags. These tags allow our [branch-diff](https://github.com/bengl/branch-diff) tooling to work smoothly as we can exclude PRs not intended for the release line we're preparing a release proposal for. The `semver-major` labels on their own are not sufficient as they don't encode any indication of from _which_ releases they are a major change.
64
-
65
- For outside contributions we will have the relevant team add these labels when they review and determine when they plan to release it.
66
-
67
- ## Ensure all tests are green
68
-
69
- We follow an all-green policy which means that for any PR to be merged _all_ tests must be passing. If a test is flaky or failing consistently the owner of that test should make it a priority to fix that test and unblock other teams from landing changes. For outside contributors there are currently several tests which will always fail as full CI permission is required. For these PRs our current process is for the relevant team to copy the PR and resubmit it to run tests as a user with full CI permission.
70
-
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
-
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
-
171
- [1]: https://docs.datadoghq.com/help
package/MIGRATING.md DELETED
@@ -1,224 +0,0 @@
1
- # Migrating
2
-
3
- This guide describes the steps to upgrade dd-trace from a major version to the
4
- next. If you are having any issues related to migrating, please feel free to
5
- open an issue or contact our [support](https://www.datadoghq.com/support/) team.
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
-
22
- ## 3.0 to 4.0
23
-
24
- ### Node 14 is no longer supported
25
-
26
- Node.js 14 has reached EOL in April 2023 and is no longer supported. Generally
27
- speaking, we highly recommend always keeping Node.js up to date regardless of
28
- our support policy.
29
-
30
- ### The `orphanable` option was removed
31
-
32
- This option was only useful internally for a single integration that has since
33
- been removed. It was never useful for manual instrumentation since all that is
34
- needed to orphan a span on creation is to use
35
- `tracer.trace('web.request', { childOf: null })`.
36
-
37
- ### Support for `jest-jasmine2` has been removed
38
-
39
- The default test runner for Jest was changed to `jest-circus` around 2 years ago and
40
- is no longer supported by our Jest integration for CI Visibility. We recommend
41
- switching to `jest-circus` to anyone still using `jest-jasmine2`.
42
-
43
- ### Support for older Next.js versions was removed
44
-
45
- We now support only Next.js 10.2 and up.
46
-
47
- ## 2.0 to 3.0
48
-
49
- ### Node 12 is no longer supported
50
-
51
- Node.js 12 has been EOL since April 2022 and is no longer supported. Generally
52
- speaking, we highly recommend always keeping Node.js up to date regardless of our
53
- support policy.
54
-
55
- ### HTTP query string reported by default
56
-
57
- HTTP query strings are now reported by default as part of the `http.url` tag.
58
- This change is considered breaking only because there might be sensitive data
59
- in the query string. A default regular expression based obfuscator is provided
60
- for common use cases like API keys, but if your use case is not covered, the
61
- [DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP](https://datadoghq.dev/dd-trace-js/#tracer-settings)
62
- environment variable can be used to control what is obfuscated, and a value of
63
- `.*` would redact the query string entirely.
64
-
65
- ### HTTP operation name change
66
-
67
- The HTTP integration now uses `web.request` for incoming requests and continues
68
- to use `http.request` for outgoing requests. When using a supported web
69
- framework like Express, this change will have no effect because the root span
70
- would already have an operation name override like `express.request`.
71
- Any [monitor](https://docs.datadoghq.com/monitors/create/types/apm/?tab=apmmetrics)
72
- on `http.request` for incoming requests should be updated to `web.request`.
73
-
74
- With this change, both operation names also appear under the main service name
75
- and are no longer split between the server service name and a separate client
76
- service name suffixed with `-http-client`.
77
-
78
- ### gRPC operation name change
79
-
80
- The gRPC integration now uses `grpc.server` for incoming requests and
81
- `grpc.client` for outgoing requests. Any
82
- [monitor](https://docs.datadoghq.com/monitors/create/types/apm/?tab=apmmetrics)
83
- on `grpc.request` should be updated to one of these.
84
-
85
- With this change, both operation names also appear under the main service name
86
- and are no longer split between the server service name and a separate client
87
- service name suffixed with `-http-client`.
88
-
89
- ### Removal of `fs` integration
90
-
91
- The `fs` integration was removed as it was originally added without an actual
92
- use case, and it's been problematic ever since. It's noisy, the output is
93
- confusing when using streams, errors that are handled higher in the stack end up
94
- being captured, etc.
95
-
96
- If you had any use for file system instrumentation, please let us know so we can
97
- provide an alternative.
98
-
99
- ### Scope binding for promises and event emitters
100
-
101
- It's no longer possible to bind promises using `tracer.scope().bind(promise)` or
102
- event emitters using `tracer.scope().bind(emitter)`. These were historically
103
- added mostly for internal use, and changes to context propagation over the years
104
- made them unnecessary, both internally and externaly. If one of these is used
105
- anywhere, the call will simply be ignored and no binding will occur.
106
-
107
- To bind the `then` handler of a promise, bind the function directly directly:
108
-
109
- ```js
110
- promise.then(tracer.scope().bind(handler))
111
- ```
112
-
113
- To bind all listeners for an event, wrap the call to `emit` directly instead:
114
-
115
- ```js
116
- tracer.scope().activate(span, () => {
117
- emitter.emit('event')
118
- })
119
- ```
120
-
121
- To bind individual listeners, bind the listener function directly instead:
122
-
123
- ```js
124
- emitter.on('event', tracer.scope().bind(listener, span))
125
- ```
126
-
127
- ### Removed APIs
128
-
129
- The following APIs have been deprecated for a long time and have now been
130
- completely removed:
131
-
132
- - `tracer.currentSpan()`
133
- - `tracer.bindEmitter()`
134
-
135
- Since these have not been recommended nor publicly documented for years at this
136
- point, there should be no impact as no application is expected to be using them.
137
-
138
- ### CI Visibility new entrypoints
139
-
140
- #### Cypress
141
-
142
- `dd-trace/cypress/plugin` and `dd-trace/cypress/support` are removed, so you won't
143
- be able to use them for your `cypress` instrumentation. Use `dd-trace/ci/cypress/plugin`
144
- and `dd-trace/ci/cypress/support` instead for your plugin and support configuration
145
- respectively.
146
-
147
- #### Jest
148
-
149
- The use of `'dd-trace/ci/jest/env'` in [`testEnvironment`](https://jestjs.io/docs/configuration#testenvironment-string)
150
- is no longer supported.
151
- To instrument `jest` tests now, add `'-r dd-trace/ci/init'` to the `NODE_OPTIONS` environment
152
- variable passed to the process running the tests, for example, `NODE_OPTIONS='-r dd-trace/ci/init' yarn test`.
153
-
154
- #### Mocha
155
-
156
- The use of `--require dd-trace/ci/init` as a `mocha` flag is no longer supported.
157
- To instrument `mocha` tests now, add `'-r dd-trace/ci/init'` to the `NODE_OPTIONS` environment
158
- variable passed to the process running the tests, for example, `NODE_OPTIONS='-r dd-trace/ci/init' yarn test`.
159
-
160
- #### Cucumber
161
-
162
- The use of `--require-module dd-trace/ci/init` as a `cucumber-js` flag is no longer supported.
163
- To instrument `cucumber-js` tests now, add `'-r dd-trace/ci/init'` to the `NODE_OPTIONS` environment
164
- variable passed to the process running the tests, for example, `NODE_OPTIONS='-r dd-trace/ci/init' yarn test`.
165
-
166
- ## 1.0 to 2.0
167
-
168
- ### Configuration
169
-
170
- The following configuraton options are no longer available programmatically and
171
- must be configured using these environment variables:
172
-
173
- * `enabled` -> `DD_TRACE_ENABLED=true|false`
174
- * `debug` -> `DD_TRACE_DEBUG=true|false`
175
-
176
- If environment variables were already used for these options, no action is
177
- needed.
178
-
179
- The following configuration options were completely removed and will no longer
180
- have any effect:
181
-
182
- * `scope`
183
-
184
- Startup logs are now disabled by default and can be enabled if needed with
185
- `DD_TRACE_STARTUP_LOGS=true`.
186
-
187
- ### Removed APIs
188
-
189
- The original scope manager has been replaced several years ago and has now been
190
- removed. Any code referencing `tracer.scopeManager()` should be removed or
191
- replaced with `tracer.scope()` which is documented
192
- [here](https://datadoghq.dev/dd-trace-js/#scope-manager).
193
-
194
- ### Nested objects as tags
195
-
196
- Support for nested objects as tags as been removed. When adding an object as a
197
- tag value, only properties that exist on that object directly will be added as
198
- tags. If nested properties are also needed, these should be added by hand.
199
-
200
- For example:
201
-
202
- ```js
203
- const obj = {
204
- a: 'foo',
205
- b: {
206
- c: 'bar'
207
- }
208
- }
209
-
210
- // 1.0
211
- span.setTag('test', obj) // add test.a and test.b.c
212
-
213
- // 2.0
214
- span.setTag('test', obj) // add test.a
215
- span.setTag('test.b', obj.b) // add test.b.c
216
- ```
217
-
218
- Arrays are no longer supported and must be converted to string manually.
219
-
220
- ### Outgoing request filtering
221
-
222
- Outgoing request filtering is no longer supported and is now only available for
223
- incoming requests. This means that the `blocklist` and `allowlist` options on
224
- the `http` integration no longer have any effect.
@@ -1,147 +0,0 @@
1
- 'use strict'
2
-
3
- require('../../../../dd-trace/test/setup/tap')
4
- const proxyquire = require('proxyquire')
5
- const { expect } = require('chai')
6
- const nock = require('nock')
7
-
8
- const tracerLogger = require('../../log')
9
-
10
- describe('External Logger', () => {
11
- let externalLogger
12
- let interceptor
13
- let errorLog
14
-
15
- beforeEach(() => {
16
- errorLog = sinon.spy(tracerLogger, 'error')
17
-
18
- const { ExternalLogger } = proxyquire('../src', {
19
- '../../log': {
20
- error: errorLog
21
- }
22
- })
23
-
24
- externalLogger = new ExternalLogger({
25
- ddsource: 'logging_from_space',
26
- hostname: 'mac_desktop',
27
- apiKey: 'API_KEY_PLACEHOLDER',
28
- interval: 10000,
29
- timeout: 5000,
30
- limit: 10
31
- })
32
- })
33
-
34
- afterEach(() => {
35
- interceptor.done()
36
- errorLog.restore()
37
- })
38
-
39
- it('should properly encode the log message', (done) => {
40
- let request
41
- const currentTime = Date.now()
42
-
43
- interceptor = nock('https://http-intake.logs.datadoghq.com:443')
44
- .post('/api/v2/logs')
45
- .reply((_uri, req, cb) => {
46
- request = req
47
- cb(null, [202, '{}', { 'Content-Type': 'application/json' }])
48
- })
49
-
50
- const span = {
51
- service: 'openAi',
52
- trace_id: '000001000',
53
- span_id: '9999991999'
54
- }
55
- const tags = {
56
- env: 'external_logger',
57
- version: '1.2.3',
58
- service: 'external'
59
- }
60
- externalLogger.log({
61
- message: 'oh no, something is up',
62
- custom: 'field',
63
- attribute: 'funky',
64
- service: 'outer_space',
65
- level: 'info'
66
- }, span, tags)
67
-
68
- externalLogger.flush((err) => {
69
- try {
70
- expect(request[0]).to.have.property('message', 'oh no, something is up')
71
- expect(request[0]).to.have.property('custom', 'field')
72
- expect(request[0]).to.have.property('attribute', 'funky')
73
- expect(request[0]).to.have.property('service', 'outer_space')
74
- expect(request[0]).to.have.property('level', 'info')
75
- expect(request[0]).to.have.property('dd.trace_id', '000001000')
76
- expect(request[0]).to.have.property('dd.span_id', '9999991999')
77
- expect(request[0].timestamp).to.be.greaterThanOrEqual(currentTime)
78
- expect(request[0]).to.have.property('ddsource', 'logging_from_space')
79
- expect(request[0]).to.have.property('ddtags', 'env:external_logger,version:1.2.3,service:external')
80
- } catch (e) {
81
- done(e)
82
- return
83
- }
84
-
85
- done(err)
86
- })
87
- })
88
-
89
- it('should empty the log queue when calling flush', (done) => {
90
- interceptor = nock('https://http-intake.logs.datadoghq.com:443')
91
- .post('/api/v2/logs')
92
- .reply(202, {})
93
-
94
- externalLogger.enqueue({})
95
- expect(externalLogger.queue.length).to.equal(1)
96
-
97
- externalLogger.flush((err) => {
98
- expect(externalLogger.queue.length).to.equal(0)
99
- done(err)
100
- })
101
- })
102
-
103
- it('tracer logger should handle error response codes from Logs API', (done) => {
104
- interceptor = nock('https://http-intake.logs.datadoghq.com:443')
105
- .post('/api/v2/logs')
106
- .reply(400, {})
107
-
108
- externalLogger.enqueue({})
109
- externalLogger.flush((err) => {
110
- expect(err).to.be.an.instanceOf(Error)
111
- expect(errorLog.getCall(0).args[0]).to.be.equal(
112
- 'failed to send 1 logs, received response code 400'
113
- )
114
- done()
115
- })
116
- })
117
-
118
- it('tracer logger should handle simulated network error', (done) => {
119
- interceptor = nock('https://http-intake.logs.datadoghq.com:443')
120
- .post('/api/v2/logs')
121
- .replyWithError('missing API key')
122
-
123
- externalLogger.enqueue({})
124
- externalLogger.flush((err) => {
125
- expect(err).to.be.an.instanceOf(Error)
126
- expect(errorLog.getCall(0).args[0]).to.be.equal(
127
- 'failed to send 1 log(s), with error missing API key'
128
- )
129
- done()
130
- })
131
- })
132
-
133
- it('causes a flush when exceeding log queue limit', (done) => {
134
- const flusher = sinon.stub(externalLogger, 'flush')
135
-
136
- for (let i = 0; i < 10; i++) {
137
- externalLogger.enqueue({})
138
- }
139
- expect(flusher).to.not.have.been.called
140
-
141
- externalLogger.enqueue({})
142
- expect(flusher).to.have.been.called
143
-
144
- flusher.restore()
145
- done()
146
- })
147
- })
@@ -1,71 +0,0 @@
1
- /* eslint-disable no-console */
2
-
3
- const childProcess = require('child_process')
4
- const ORIGIN = 'origin/'
5
-
6
- let releaseBranch = process.env['GITHUB_BASE_REF'] // 'origin/v3.x'
7
- let releaseVersion = releaseBranch
8
- if (releaseBranch.startsWith(ORIGIN)) {
9
- releaseVersion = releaseBranch.substring(ORIGIN.length)
10
- } else {
11
- releaseBranch = ORIGIN + releaseBranch
12
- }
13
- let currentBranch = process.env['GITHUB_HEAD_REF'] // 'ugaitz/workflow-to-verify-dont-land-on-v3.x'
14
- if (!currentBranch.startsWith(ORIGIN)) {
15
- currentBranch = ORIGIN + currentBranch
16
- }
17
-
18
- const getHashesCommandWithExclusions = 'branch-diff --user DataDog --repo dd-trace-js --exclude-label=semver-major' +
19
- ` --exclude-label=dont-land-on-${releaseVersion} ${releaseBranch} ${currentBranch}`
20
- const getHashesCommandWithoutExclusions =
21
- `branch-diff --user DataDog --repo dd-trace-js ${releaseBranch} ${currentBranch}`
22
-
23
- childProcess.exec(getHashesCommandWithExclusions, { timeout: 30000 },
24
- (withExclusionError, withExclusionStdout, withExclusionStderr) => {
25
- if (withExclusionError) {
26
- console.error(`stdout:
27
- ${withExclusionStdout}
28
- stderr:
29
- ${withExclusionStderr}
30
- `, withExclusionError)
31
- process.exit(1)
32
- return
33
- }
34
- if (withExclusionStderr) {
35
- console.error(withExclusionStderr)
36
- process.exit(1)
37
- return
38
- }
39
- const commitsHashesWithExclusions = withExclusionStdout.split('\n')
40
-
41
- childProcess.exec(getHashesCommandWithoutExclusions,
42
- (withoutExclusionError, withoutExclusionStdout, withoutExclusionStderr) => {
43
- if (withoutExclusionError) {
44
- console.error(`stdout:
45
- ${withoutExclusionStdout}
46
- stderr:
47
- ${withoutExclusionStderr}
48
- `, withoutExclusionError)
49
- process.exit(1)
50
- return
51
- }
52
- if (withoutExclusionStderr) {
53
- console.error(withoutExclusionStderr)
54
- process.exit(1)
55
- return
56
- }
57
- const commitsHashesWithoutExclusions = withoutExclusionStdout.split('\n')
58
- if (commitsHashesWithExclusions.length !== commitsHashesWithoutExclusions.length) {
59
- const commitsWithInvalidLabels = []
60
- commitsHashesWithoutExclusions.filter(c1 => {
61
- if (!commitsHashesWithExclusions.some(c2 => c2 === c1)) {
62
- commitsWithInvalidLabels.push(c1)
63
- }
64
- })
65
- console.error('Some excluded label added in the release proposal', commitsWithInvalidLabels)
66
- process.exit(1)
67
- } else {
68
- console.log('Commit PRs label looks OK')
69
- }
70
- })
71
- })
@@ -1,69 +0,0 @@
1
- 'use strict'
2
-
3
- const fs = require('fs')
4
- const path = require('path')
5
- const readline = require('readline')
6
- const pkg = require(path.join(__dirname, '..', '/package.json'))
7
-
8
- const filePath = path.join(__dirname, '..', '/LICENSE-3rdparty.csv')
9
- const deps = new Set(Object.keys(pkg.dependencies || {}))
10
- const devDeps = new Set(Object.keys(pkg.devDependencies || {}))
11
-
12
- let index = 0
13
-
14
- const licenses = {
15
- require: new Set(),
16
- dev: new Set(),
17
- file: new Set()
18
- }
19
-
20
- const lineReader = readline.createInterface({
21
- input: fs.createReadStream(filePath)
22
- })
23
-
24
- lineReader.on('line', line => {
25
- if (index !== 0) {
26
- const columns = line.split(',')
27
- const type = columns[0]
28
- const license = columns[1]
29
-
30
- licenses[type].add(license)
31
- }
32
-
33
- index++
34
- })
35
-
36
- lineReader.on('close', () => {
37
- if (!checkLicenses(deps, 'require') || !checkLicenses(devDeps, 'dev')) {
38
- process.exit(1)
39
- }
40
- })
41
-
42
- function checkLicenses (typeDeps, type) {
43
- /* eslint-disable no-console */
44
-
45
- const missing = []
46
- const extraneous = []
47
-
48
- for (const dep of typeDeps) {
49
- if (!licenses[type].has(dep)) {
50
- missing.push(dep)
51
- }
52
- }
53
-
54
- for (const dep of licenses[type]) {
55
- if (!typeDeps.has(dep)) {
56
- extraneous.push(dep)
57
- }
58
- }
59
-
60
- if (missing.length) {
61
- console.log(`Missing 3rd-party license for ${missing.join(', ')}.`)
62
- }
63
-
64
- if (extraneous.length) {
65
- console.log(`Extraneous 3rd-party license for ${extraneous.join(', ')}.`)
66
- }
67
-
68
- return missing.length === 0 && extraneous.length === 0
69
- }