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

switch to internal diagnostics channel with node bug patch #3002

Merged
merged 10 commits into from
Apr 13, 2023
Merged

Conversation

rochdev
Copy link
Member

@rochdev rochdev commented Apr 12, 2023

What does this PR do?

Switch to internal diagnostics channel with Node bug patch.

Motivation

Avoid issues mentioned in nodejs/node#47520

Additional Notes

We don't really have a good strategy to test issues that only happen in very specific version of Node, so not sure how to test this other than with 19.9.0 being the current version and also the version that is broken.

@github-actions
Copy link

github-actions bot commented Apr 12, 2023

Overall package size

Self size: 4.03 MB
Deduped: 59.67 MB
No deduping: 59.72 MB

Dependency sizes

name version self size total size
@datadog/native-iast-taint-tracking 1.3.1 13.47 MB 13.47 MB
@datadog/pprof 2.1.0 12.31 MB 13.2 MB
@datadog/native-appsec 2.0.0 12.33 MB 12.34 MB
@datadog/native-metrics 1.5.0 7.1 MB 7.11 MB
protobufjs 7.1.2 2.76 MB 6.55 MB
@datadog/native-iast-rewriter 2.0.1 2.09 MB 2.1 MB
opentracing 0.14.7 194.81 kB 194.81 kB
semver 7.3.8 88.2 kB 118.6 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
ipaddr.js 2.0.1 59.52 kB 59.52 kB
ignore 5.2.0 48.87 kB 48.87 kB
import-in-the-middle 1.3.4 32.7 kB 37.17 kB
istanbul-lib-coverage 3.2.0 29.34 kB 29.34 kB
retry 0.10.1 27.44 kB 27.44 kB
lodash.uniq 4.5.0 25.01 kB 25.01 kB
limiter 1.1.5 23.17 kB 23.17 kB
lodash.kebabcase 4.1.1 17.75 kB 17.75 kB
lodash.pick 4.4.0 16.33 kB 16.33 kB
node-abort-controller 3.0.1 14.33 kB 14.33 kB
crypto-randomuuid 1.0.0 11.18 kB 11.18 kB
diagnostics_channel 1.1.0 7.07 kB 7.07 kB
path-to-regexp 0.1.7 6.78 kB 6.78 kB
koalas 1.0.2 6.47 kB 6.47 kB
methods 1.1.2 5.29 kB 5.29 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

@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Merging #3002 (6fd28e0) into master (887651d) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #3002      +/-   ##
==========================================
- Coverage   87.65%   87.63%   -0.02%     
==========================================
  Files         329      329              
  Lines       11753    11762       +9     
  Branches       33       33              
==========================================
+ Hits        10302    10308       +6     
- Misses       1451     1454       +3     
Impacted Files Coverage Δ
packages/dd-trace/src/dcitm.js 94.11% <ø> (ø)
packages/dd-trace/src/appsec/gateway/channels.js 100.00% <100.00%> (ø)
packages/dd-trace/src/appsec/iast/index.js 100.00% <100.00%> (ø)
...ackages/dd-trace/src/appsec/iast/telemetry/logs.js 97.50% <100.00%> (ø)
packages/dd-trace/src/iitm.js 100.00% <100.00%> (ø)
packages/dd-trace/src/log/channels.js 100.00% <100.00%> (ø)
packages/dd-trace/src/plugin_manager.js 98.41% <100.00%> (ø)
packages/dd-trace/src/plugins/plugin.js 64.51% <100.00%> (ø)
packages/dd-trace/src/profiling/profilers/cpu.js 98.30% <100.00%> (ø)
packages/dd-trace/src/ritm.js 90.00% <100.00%> (ø)
... and 2 more

... and 2 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pr-commenter
Copy link

pr-commenter bot commented Apr 12, 2023

Benchmarks

Comparing candidate commit 6fd28e0 in PR branch internal-dc with baseline commit 887651d in branch master.

Found 0 performance improvements and 10 performance regressions! Performance is the same for 660 metrics, 38 unstable metrics.

scenario:startup-control-everything-14

  • 🟥 instructions [+238457475; +252138485] or [+7.244%; +7.660%]

scenario:startup-with-tracer-everything-14

  • 🟥 instructions [+292968626; +299898655] or [+7.542%; +7.721%]

scenario:startup-control-everything-16

  • 🟥 instructions [+249210732; +260259280] or [+7.472%; +7.803%]

scenario:startup-with-tracer-everything-16

  • 🟥 instructions [+289008382; +298607820] or [+7.460%; +7.708%]

scenario:startup-control-everything-18

  • 🟥 cpu_user_time [+0.103s; +0.126s] or [+7.962%; +9.730%]
  • 🟥 execution_time [+0.133s; +0.140s] or [+9.020%; +9.499%]
  • 🟥 instructions [+257653897; +269716288] or [+8.162%; +8.544%]

scenario:startup-with-tracer-everything-18

  • 🟥 cpu_user_time [+0.094s; +0.121s] or [+6.227%; +7.946%]
  • 🟥 execution_time [+0.111s; +0.127s] or [+6.309%; +7.221%]
  • 🟥 instructions [+284176953; +294913947] or [+7.556%; +7.841%]

@rochdev
Copy link
Member Author

rochdev commented Apr 12, 2023

For some reason it seems "everything" benchmarks include dev dependencies which is why they run slower.

@rochdev rochdev marked this pull request as ready for review April 12, 2023 22:13
@rochdev rochdev requested review from a team as code owners April 12, 2023 22:13

this.subscribe(() => {}) // Keep it active forever.
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's already active, we still need to be sure there's an extra subscriber forever.

Suggested change
}
} else {
maybeInactive.subscribe(() => {}) // Keep it active forever.
}

Copy link
Member Author

Choose a reason for hiding this comment

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

How could it be active? It would have to first be inactive before it's ever active.

Copy link
Member Author

Choose a reason for hiding this comment

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

All tests passing also prove that this is the case, and preventing usage of the built-in with eslint ensures that nothing subscribes with the built-in directly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If something else subscribes to that same named channel before we get to this point it will already be active. Unlikely given we're currently using our own custom channel names, but possible. And it will become more likely as we start pushing instrumentations upstream.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the approach to support active channels safely, let me know if that works.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you're going to use the WeakMap, why even patch the subscribe function? You could just immediate do this.subscribe(() => {}) on any channel not already seen. Also, the return value of the patched subscribe is wrong, it should return the result of the subscribe call.

Copy link
Member Author

@rochdev rochdev Apr 13, 2023

Choose a reason for hiding this comment

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

If you're going to use the WeakMap, why even patch the subscribe function?

Because otherwise a subscriber would be added on channel() and not on subscribe(), so publishers would cause a subscription as well.

Also, the return value of the patched subscribe is wrong, it should return the result of the subscribe call.

True, I didn't return anything because the method doesn't either, but it's best practice to return anyway in case that changes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, right, it's only unsubscribe that returns a value. Misremembering my own code. 😆

tlhunter
tlhunter previously approved these changes Apr 12, 2023
Qard
Qard previously approved these changes Apr 13, 2023
tlhunter
tlhunter previously approved these changes Apr 13, 2023
@rochdev rochdev dismissed stale reviews from tlhunter and Qard via 6fd28e0 April 13, 2023 20:31
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.

4 participants