fix(startup-log): emit immediately after init and send to stderr#7470
fix(startup-log): emit immediately after init and send to stderr#7470
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7470 +/- ##
==========================================
- Coverage 80.30% 80.29% -0.01%
==========================================
Files 731 731
Lines 31137 31140 +3
==========================================
+ Hits 25004 25005 +1
- Misses 6133 6135 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Overall package sizeSelf size: 4.58 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.6 | 81.92 kB | 813.08 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
This comment has been minimized.
This comment has been minimized.
BenchmarksBenchmark execution time: 2026-02-10 16:24:33 Comparing candidate commit cd4e0ea in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 230 metrics, 30 unstable metrics. |
BridgeAR
left a comment
There was a problem hiding this comment.
The stderr output seems good. I guess that should also be fine without it being a major. Activating it by default would make it major in my opinion.
I am just unsure if we really want to remove the agentError. I believe we had a spec for that.
| DynamicInstrumentation.configure(config) | ||
| setStartupLogPluginManager(this._pluginManager) | ||
| // Emit startup log immediately after tracer is fully initialized | ||
| startupLog() |
There was a problem hiding this comment.
This removes the error handling. I am fine with that, while it a) removes information that the customer might want and b) if we remove it, we also have to remove the agentError part. I believe that was actually spected somewhere.
There was a problem hiding this comment.
Can you elaborate? I had expected that this would just front-load information we were already providing, not remove information
Is there a different place you'd recommend that this go to accomplish both goals?
There was a problem hiding this comment.
agentError came from the information being passed through to the method when being called https://github.com/DataDog/dd-trace-js/pull/7470/changes#diff-a3fcd7c24d4ec8042528afc821a9e9541c66809f4f79d2371274bef28f955342L34
I would have considered this to be part of the initialization of the tracer (the first payload to the agent is during startup because it checks for the agent to be available or not and what the agent supports. Without that, the tracer might not know how to work).
Thus, I would have expected the former placement to be correct.
Are you certain the agent support is not checked in other tracers during startup for the startup log?
There was a problem hiding this comment.
This is something other tracers have, but it's de-coupled from the initialization. I'll re-work slightly to have two separate log lines as other tracers do
There was a problem hiding this comment.
If we decouple it, we should probably log to stdout, not err (due to not having an error anymore)
There was a problem hiding this comment.
I'll have it as warn instead since that also goes to stderr, but strongly believe it should not go to stdout. Reason being that going to stdout, especially by default, can mess with any tooling that may be processing the logs
For example, imagine someone uses SSI, which instruments everything running Node.js. If they were to run a small Node.js script and depend on the stdout of that script for further processing, this may break their tool
There was a problem hiding this comment.
Discussed offline with @BridgeAR
- stderr is the convention for diagnostic logs coming from outside of the primary application. We will follow it here
- agent error was re-introduced and will be logged separately, in the same conditions as before
There was a problem hiding this comment.
Isn't this too early? We weren't waiting just for the errors, we were also waiting to give time to the app to load any dependencies it's going to use, otherwise we lose the information about loaded integrations (which is one of the most important aspects of startup logs). Unless I'm misunderstanding the PR, I think this is broken now.
@BridgeAR understood - would your suggestion in this case be to de-couple the improvement from the default enablement? Main goal here is to provide a sort of "heartbeat" that the SDK started up as new customers install it so enabling it is a net-positive, but understood that rollout on a minor could be surprising |
|
I believe the current change would ideally be three:
I added the topic to the guild call to discuss the semverness |
ee9bc4b to
806f99c
Compare
Startup logs now emit immediately after tracer initialization instead of being delayed until the first payload is sent to the agent. They are also sent to stderr (via console.error) instead of stdout, following Unix conventions and aligning with other Datadog language tracers. Changes: - Added startupLog() call in proxy.js after initialization completes - Changed output from info() to error() to use stderr - Removed duplicate late call in writer.js that was firing on first payload - Updated tests to expect console.error instead of console.info Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
After merging master, the new data_streams_enabled tests were still using console.info instead of console.error. Updated all three tests in that describe block to use console.error to match the stderr output change. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
806f99c to
93b78df
Compare
* fix(startup-log): emit immediately after init and send to stderr Startup logs now emit immediately after tracer initialization instead of being delayed until the first payload is sent to the agent. They are also sent to stderr (via console.error) instead of stdout, following Unix conventions and aligning with other Datadog language tracers. Changes: - Added startupLog() call in proxy.js after initialization completes - Changed output from info() to error() to use stderr - Removed duplicate late call in writer.js that was firing on first payload - Updated tests to expect console.error instead of console.info Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix(tests): update data_streams_enabled tests to use console.error After merging master, the new data_streams_enabled tests were still using console.info instead of console.error. Updated all three tests in that describe block to use console.error to match the stderr output change. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix(startup-log): separate initialization and agent diagnostic logs Previously, the startup log and agent connection diagnostic were coupled together in a single call. This meant that if the startup log was emitted immediately (as intended), we would lose the agent connection diagnostic that happens on the first write attempt. Changes: - Split startupLog() into two separate functions: - startupLog(): Logs tracer configuration immediately after init - logAgentError(): Logs agent connection diagnostic on first write error - Each function maintains its own "already ran" flag to log only once - Updated writer.js to call logAgentError() when agent responds with error - Updated tests to verify both logs are emitted correctly and separately This ensures users get both the immediate startup configuration log AND the agent connection diagnostic if there's an issue reaching the agent. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix(startup-log): use warn for both startup log and agent diagnostic Changed startup log to use warn() instead of error() for consistency. Both the startup configuration log and agent diagnostic now use warn(), which outputs to stderr via console.warn(). Changes: - startup-log.js: Changed startupLog() to use warn() instead of error() - Removed unused error import from log/writer - Updated all tests to expect console.warn instead of console.error This is more semantically appropriate since both logs are diagnostic information rather than actual errors. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.5 <[email protected]>
|
Heads up: This got reverted in #7478 due to a bug. Consider opening a new PR to fix it properly 🙂 |
Changed startup logs to output to stderr (via console.warn) instead of stdout (via console.info), following Unix conventions and aligning with other Datadog language tracers. This change does NOT modify when the logs are emitted - they continue to be emitted on the first payload sent to the agent (same timing as before). Changes: - Separated startupLog() and logAgentError() into distinct functions - Changed both functions to use warn() for stderr output - Updated writer.js to call both functions separately - Updated all tests to expect console.warn instead of console.info Related to #7470 (which was reverted in #7478 due to regression from immediate emission timing change). This PR includes only the stderr output change without the timing modification. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Changed startup logs to output to stderr (via console.warn) instead of stdout (via console.info), following Unix conventions and aligning with other Datadog language tracers. This is a minimal change that only swaps the output stream - no changes to timing or function structure. Changes: - Changed startupLog() to use warn() instead of info() for stderr output - Updated all tests to expect console.warn instead of console.info Related to #7470 (which was reverted in #7478 due to regression from immediate emission timing change). This PR includes only the stderr output change without any timing modifications. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Changed startup logs to output to stderr (via console.warn) instead of stdout (via console.info), following Unix conventions and aligning with other Datadog language tracers. This is a minimal change that only swaps the output stream - no changes to timing or function structure. Changes: - Changed startupLog() to use warn() instead of info() for stderr output - Updated all tests to expect console.warn instead of console.info Related to #7470 (which was reverted in #7478 due to regression from immediate emission timing change). This PR includes only the stderr output change without any timing modifications. Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
* fix(startup-log): emit immediately after init and send to stderr Startup logs now emit immediately after tracer initialization instead of being delayed until the first payload is sent to the agent. They are also sent to stderr (via console.error) instead of stdout, following Unix conventions and aligning with other Datadog language tracers. Changes: - Added startupLog() call in proxy.js after initialization completes - Changed output from info() to error() to use stderr - Removed duplicate late call in writer.js that was firing on first payload - Updated tests to expect console.error instead of console.info Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix(tests): update data_streams_enabled tests to use console.error After merging master, the new data_streams_enabled tests were still using console.info instead of console.error. Updated all three tests in that describe block to use console.error to match the stderr output change. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix(startup-log): separate initialization and agent diagnostic logs Previously, the startup log and agent connection diagnostic were coupled together in a single call. This meant that if the startup log was emitted immediately (as intended), we would lose the agent connection diagnostic that happens on the first write attempt. Changes: - Split startupLog() into two separate functions: - startupLog(): Logs tracer configuration immediately after init - logAgentError(): Logs agent connection diagnostic on first write error - Each function maintains its own "already ran" flag to log only once - Updated writer.js to call logAgentError() when agent responds with error - Updated tests to verify both logs are emitted correctly and separately This ensures users get both the immediate startup configuration log AND the agent connection diagnostic if there's an issue reaching the agent. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix(startup-log): use warn for both startup log and agent diagnostic Changed startup log to use warn() instead of error() for consistency. Both the startup configuration log and agent diagnostic now use warn(), which outputs to stderr via console.warn(). Changes: - startup-log.js: Changed startupLog() to use warn() instead of error() - Removed unused error import from log/writer - Updated all tests to expect console.warn instead of console.error This is more semantically appropriate since both logs are diagnostic information rather than actual errors. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.5 <[email protected]>
Changed startup logs to output to stderr (via console.warn) instead of stdout (via console.info), following Unix conventions and aligning with other Datadog language tracers. This is a minimal change that only swaps the output stream - no changes to timing or function structure. Changes: - Changed startupLog() to use warn() instead of info() for stderr output - Updated all tests to expect console.warn instead of console.info Related to #7470 (which was reverted in #7478 due to regression from immediate emission timing change). This PR includes only the stderr output change without any timing modifications. Co-authored-by: Claude Sonnet 4.5 <[email protected]>
Changed startup logs to output to stderr (via console.warn) instead of stdout (via console.info), following Unix conventions and aligning with other Datadog language tracers. This is a minimal change that only swaps the output stream - no changes to timing or function structure. Changes: - Changed startupLog() to use warn() instead of info() for stderr output - Updated all tests to expect console.warn instead of console.info Related to #7470 (which was reverted in #7478 due to regression from immediate emission timing change). This PR includes only the stderr output change without any timing modifications. Co-authored-by: Claude Sonnet 4.5 <[email protected]>
Changed startup logs to output to stderr (via console.warn) instead of stdout (via console.info), following Unix conventions and aligning with other Datadog language tracers. This is a minimal change that only swaps the output stream - no changes to timing or function structure. Changes: - Changed startupLog() to use warn() instead of info() for stderr output - Updated all tests to expect console.warn instead of console.info Related to #7470 (which was reverted in #7478 due to regression from immediate emission timing change). This PR includes only the stderr output change without any timing modifications. Co-authored-by: Claude Sonnet 4.5 <[email protected]>
* fix(startup-log): emit immediately after init and send to stderr Startup logs now emit immediately after tracer initialization instead of being delayed until the first payload is sent to the agent. They are also sent to stderr (via console.error) instead of stdout, following Unix conventions and aligning with other Datadog language tracers. Changes: - Added startupLog() call in proxy.js after initialization completes - Changed output from info() to error() to use stderr - Removed duplicate late call in writer.js that was firing on first payload - Updated tests to expect console.error instead of console.info Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix(tests): update data_streams_enabled tests to use console.error After merging master, the new data_streams_enabled tests were still using console.info instead of console.error. Updated all three tests in that describe block to use console.error to match the stderr output change. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix(startup-log): separate initialization and agent diagnostic logs Previously, the startup log and agent connection diagnostic were coupled together in a single call. This meant that if the startup log was emitted immediately (as intended), we would lose the agent connection diagnostic that happens on the first write attempt. Changes: - Split startupLog() into two separate functions: - startupLog(): Logs tracer configuration immediately after init - logAgentError(): Logs agent connection diagnostic on first write error - Each function maintains its own "already ran" flag to log only once - Updated writer.js to call logAgentError() when agent responds with error - Updated tests to verify both logs are emitted correctly and separately This ensures users get both the immediate startup configuration log AND the agent connection diagnostic if there's an issue reaching the agent. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> * fix(startup-log): use warn for both startup log and agent diagnostic Changed startup log to use warn() instead of error() for consistency. Both the startup configuration log and agent diagnostic now use warn(), which outputs to stderr via console.warn(). Changes: - startup-log.js: Changed startupLog() to use warn() instead of error() - Removed unused error import from log/writer - Updated all tests to expect console.warn instead of console.error This is more semantically appropriate since both logs are diagnostic information rather than actual errors. Co-Authored-By: Claude Sonnet 4.5 <[email protected]> --------- Co-authored-by: Claude Sonnet 4.5 <[email protected]>
…ent payload Split startupLog into three independent functions so config is logged immediately at init (via proxy.js) while integrations are logged later on first agent payload (via writer.js). This gives users config info faster without losing the integrations_loaded field that was regressed in #7470. Also fixes broken agent error logging introduced in #7212 where `startupLog({ agentError: err })` didn't match the expected `{ status, message }` shape. Co-Authored-By: Claude Opus 4.6 <[email protected]>
#7643) * fix(startup-log): emit config early at init, integrations on first agent payload Split startupLog into three independent functions so config is logged immediately at init (via proxy.js) while integrations are logged later on first agent payload (via writer.js). This gives users config info faster without losing the integrations_loaded field that was regressed in #7470. Also fixes broken agent error logging introduced in #7212 where `startupLog({ agentError: err })` didn't match the expected `{ status, message }` shape. Co-Authored-By: Claude Opus 4.6 <[email protected]> * ci: re-run CI --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
#7643) * fix(startup-log): emit config early at init, integrations on first agent payload Split startupLog into three independent functions so config is logged immediately at init (via proxy.js) while integrations are logged later on first agent payload (via writer.js). This gives users config info faster without losing the integrations_loaded field that was regressed in #7470. Also fixes broken agent error logging introduced in #7212 where `startupLog({ agentError: err })` didn't match the expected `{ status, message }` shape. Co-Authored-By: Claude Opus 4.6 <[email protected]> * ci: re-run CI --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
#7643) * fix(startup-log): emit config early at init, integrations on first agent payload Split startupLog into three independent functions so config is logged immediately at init (via proxy.js) while integrations are logged later on first agent payload (via writer.js). This gives users config info faster without losing the integrations_loaded field that was regressed in #7470. Also fixes broken agent error logging introduced in #7212 where `startupLog({ agentError: err })` didn't match the expected `{ status, message }` shape. Co-Authored-By: Claude Opus 4.6 <[email protected]> * ci: re-run CI --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
Summary
Changes startup logs to emit immediately after tracer initialization and send output to stderr instead of stdout.
Motivation
Immediate emission: Previously, startup logs were only emitted on the first payload sent to the agent, which could be delayed or never happen if the agent is unreachable. Emitting immediately after init ensures users always see the logs.
stderr output: Following Unix conventions and aligning with other Datadog language tracers, diagnostic/log output should go to stderr rather than stdout. This allows proper separation of application output from diagnostic information.
Changes
startupLog()call inproxy.jsafter tracer initialization completesinfo()toerror()to use stderr instead of stdoutwriter.jsthat was firing on first payloadconsole.errorinstead ofconsole.infoTest plan
Related PR
This PR is part of a larger effort split into two PRs:
🤖 Generated with Claude Code