PROD-88323 Preload dd-trace before orka startup - #527
Merged
Merged
Conversation
ChristosLabrou
requested review from
echetzakis,
klesgidis,
kzacharakis,
nikosd23 and
stavros-wb
as code owners
September 25, 2026 10:21
klesgidis
reviewed
Sep 25, 2026
| @@ -0,0 +1,5 @@ | |||
| import requireInjected from '../../require-injected'; | |||
|
|
|||
| if (process.env.DD_SERVICE && process.env.DD_ENV) { | |||
Contributor
There was a problem hiding this comment.
why we are creating a new pre-loader for this? why don't we use the existing initializer? there are some configuration options that should be used like
orka/src/initializers/datadog/index.ts
Lines 9 to 13 in e200165
Contributor
Author
There was a problem hiding this comment.
When this initializer runs, lodash has already been imported from other imports (eg getLogger also imports lodash).
Contributor
There was a problem hiding this comment.
so datadog should be the first module loaded after diamorphosis, no?
Contributor
Author
There was a problem hiding this comment.
Sadly this doesn't work. The initializer runs after all imports are resolved. The error is still present even if I moved dd import at the top
klesgidis
approved these changes
Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dd-trace initializes too late in orka. lodash is required at module load in builder.ts and orka.ts, while dd-trace.init() runs only later inside orka(). The tracer then reports that lodash was loaded before it, so the lodash hooks never attach.
The same warning shows up in every service that boots through orka. The fix calls dd-trace.init() in a preload imported before lodash, when DD_SERVICE and DD_ENV are set. The existing tracer.use('koa', …) setup still runs after the config loads. A second init() returns the tracer already created.