Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Unidici support #4293

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open

Adding Unidici support #4293

wants to merge 43 commits into from

Conversation

crysmags
Copy link
Collaborator

@crysmags crysmags commented May 9, 2024

What does this PR do?

This will add support for Undici for current versions of Undici that support fetch (versions '^4.4.1', '5', '^6.0.0'). It will also support diagnostics channel when it is supported by Undici.

Plugin Checklist

Additional Notes

@crysmags crysmags requested review from a team as code owners May 9, 2024 17:18
Copy link

github-actions bot commented May 9, 2024

Overall package size

Self size: 6.55 MB
Deduped: 60.61 MB
No deduping: 60.89 MB

Dependency sizes

name version self size total size
@datadog/native-iast-taint-tracking 2.1.0 14.91 MB 14.92 MB
@datadog/native-appsec 7.1.1 14.39 MB 14.4 MB
@datadog/pprof 5.3.0 9.85 MB 10.22 MB
protobufjs 7.2.5 2.77 MB 6.56 MB
@datadog/native-iast-rewriter 2.3.1 2.15 MB 2.24 MB
@opentelemetry/core 1.14.0 872.87 kB 1.47 MB
@datadog/native-metrics 2.0.0 898.77 kB 1.3 MB
@opentelemetry/api 1.8.0 1.21 MB 1.21 MB
import-in-the-middle 1.7.4 70.19 kB 739.86 kB
msgpack-lite 0.1.26 201.16 kB 281.59 kB
opentracing 0.14.7 194.81 kB 194.81 kB
semver 7.5.4 93.4 kB 123.8 kB
pprof-format 2.1.0 111.69 kB 111.69 kB
@datadog/sketches-js 2.1.0 109.9 kB 109.9 kB
lodash.sortby 4.7.0 75.76 kB 75.76 kB
lru-cache 7.14.0 74.95 kB 74.95 kB
ignore 5.2.4 51.22 kB 51.22 kB
int64-buffer 0.1.10 49.18 kB 49.18 kB
shell-quote 1.8.1 44.96 kB 44.96 kB
istanbul-lib-coverage 3.2.0 29.34 kB 29.34 kB
tlhunter-sorted-set 0.1.0 24.94 kB 24.94 kB
limiter 1.1.5 23.17 kB 23.17 kB
dc-polyfill 0.1.4 23.1 kB 23.1 kB
retry 0.13.1 18.85 kB 18.85 kB
jest-docblock 29.7.0 8.99 kB 12.76 kB
crypto-randomuuid 1.0.0 11.18 kB 11.18 kB
path-to-regexp 0.1.7 6.78 kB 6.78 kB
koalas 1.0.2 6.47 kB 6.47 kB
module-details-from-path 1.0.3 4.47 kB 4.47 kB

🤖 This report was automatically generated by heaviest-objects-in-the-universe

Copy link

codecov bot commented May 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.42%. Comparing base (e77f059) to head (ac424fd).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4293      +/-   ##
==========================================
- Coverage   87.35%   80.42%   -6.93%     
==========================================
  Files         106        3     -103     
  Lines        3676      373    -3303     
  Branches       33       33              
==========================================
- Hits         3211      300    -2911     
+ Misses        465       73     -392     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pr-commenter
Copy link

pr-commenter bot commented May 9, 2024

Benchmarks

Benchmark execution time: 2024-05-24 23:54:05

Comparing candidate commit ac424fd in PR branch undici_pr with baseline commit e77f059 in branch master.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 261 metrics, 4 unstable metrics.

scenario:plugin-graphql-with-depth-on-max-18

  • 🟩 max_rss_usage [-144.050MB; -141.090MB] or [-14.839%; -14.534%]

@tlhunter tlhunter force-pushed the undici_pr branch 5 times, most recently from 7387a6e to 8dd1be7 Compare May 10, 2024 22:02
Comment on lines 49 to 46
express = require('express')
fetch = require('undici')
Copy link
Collaborator

@Qard Qard May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably change these to use withVersions(...) so we get version checking and don't need to add undici as a dev dependency.

You use it like this: https://github.com/DataDog/dd-trace-js/blob/master/packages/datadog-plugin-mysql/test/index.spec.js#L16

Then you can require or proxyquire it out of the versions folder. https://github.com/DataDog/dd-trace-js/blob/master/packages/datadog-plugin-mysql/test/index.spec.js#L31

It's a bit unintuitive, but that gets us multi-version checking.

If you want to see the withVersions(...) source to understand how it works, you can find it here: https://github.com/DataDog/dd-trace-js/blob/master/packages/dd-trace/test/setup/mocha.js#L169

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done.


addHook({
name: 'undici',
versions: ['^4.4.1', '5', '^6.0.0']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last range should be >=6 so that tracing will continue to work if a user upgrades to 7.0 when it's released.

@@ -30,6 +30,7 @@ loadChannel.subscribe(({ name }) => {

// Globals
maybeEnable(require('../../datadog-plugin-fetch/src'))
maybeEnable(require('../../datadog-plugin-undici/src'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be needed since Undici is not global like fetch is.

Copy link
Collaborator

@Qard Qard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there's a small bit probably leftover from debugging tests, but otherwise LGTM.

Comment on lines +71 to +72
it('FIRST TEST FAILS BECAUSE.', () => {
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from test debugging? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Qard actually, it's not. There is an issue where whatever test that is first will always fail, hence this empty test. I am hoping that through review we could find a reason why/ or a more acceptable workaround.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange. 🤔

What's the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants