-
Notifications
You must be signed in to change notification settings - Fork 312
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
debug warnings when init after instrumented packages #4307
Conversation
Overall package sizeSelf size: 6.49 MB Dependency sizes
🤖 This report was automatically generated by heaviest-objects-in-the-universe |
5928bc6
to
ae3c90f
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #4307 +/- ##
==========================================
- Coverage 69.19% 60.73% -8.46%
==========================================
Files 1 101 +100
Lines 198 3273 +3075
Branches 33 33
==========================================
+ Hits 137 1988 +1851
- Misses 61 1285 +1224 ☔ View full report in Codecov by Sentry. |
BenchmarksBenchmark execution time: 2024-05-16 22:44:41 Comparing candidate commit 1891681 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 262 metrics, 4 unstable metrics. |
cc813c4
to
3de98b7
Compare
3de98b7
to
65e0118
Compare
@@ -0,0 +1,33 @@ | |||
'use strict' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really belong in core as it's only needed for auto-instrumentation. Maybe it could go in datadog-instrumentations
?
if (naughties.has(pkg)) continue | ||
if (!(pkg in packages)) continue | ||
|
||
console.error(`Warning: Package '${pkg}' was loaded before dd-trace! This may break instrumentation.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if tens of thousands of packages were loaded before dd-trace?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what about frameworks that load the app from a CLI tool, for example micro
? These would likely have a lot of warnings that are not possible to fix. Same for CI Visibility probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if tens of thousands of packages were loaded before dd-trace?
It will print at most 1 message for each package name. E.g. if it finds 10 redis entries there will be one line printed.
Also, what about frameworks that load the app from a CLI tool, for example micro? These would likely have a lot of warnings that are not possible to fix. Same for CI Visibility probably.
These logs only appear when in debug mode wherein a user should be expecting lots of debug logs.
38135fa
to
9c6f6ac
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just one minor nit/question.
packages/dd-trace/src/proxy.js
Outdated
telemetry.start(config, this._pluginManager) | ||
|
||
if (config.debug) checkRequireCache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only matters that we're loaded before them, not that we init before them, right? So we should maybe just do this at the top-level.
cc @rochdev
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been moved to right before we start patching things
a696890
to
70bc9f4
Compare
@@ -27,6 +28,8 @@ if (!disabledInstrumentations.has('fetch')) { | |||
const HOOK_SYMBOL = Symbol('hookExportsMap') | |||
// TODO: make this more efficient | |||
|
|||
checkRequireCache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Need to wrap this in a debug check. I don't think config is ready at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, duh, of course, config can't possibly be ready before init, as init is used to configure the tracer.
I spoke with @bengl and I'll just check for the DD_TRACE_DEBUG env var and not the config object. Optionally I could make a new env var with no correlating config option. |
What does this PR do?
DD_TRACE_DEBUG=true
has been set and has no correlating init/config entryhttp
have been required before the tracerMotivation