Skip to content

fix(startup-log): emit immediately after init and send to stderr#7470

Merged
bm1549 merged 4 commits intomasterfrom
brian.marks/startup-log
Feb 10, 2026
Merged

fix(startup-log): emit immediately after init and send to stderr#7470
bm1549 merged 4 commits intomasterfrom
brian.marks/startup-log

Conversation

@bm1549
Copy link
Copy Markdown
Contributor

@bm1549 bm1549 commented Feb 9, 2026

Summary

Changes startup logs to emit immediately after tracer initialization and send output to stderr instead of stdout.

Motivation

  1. 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.

  2. 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

  • Added startupLog() call in proxy.js after tracer initialization completes
  • Changed output from info() to error() to use stderr instead of stdout
  • Removed duplicate late call in writer.js that was firing on first payload
  • Updated all tests to expect console.error instead of console.info

Test plan

  • All startup log tests pass with updated expectations
  • Tests verify logs are emitted immediately, not delayed

Related PR

This PR is part of a larger effort split into two PRs:

🤖 Generated with Claude Code

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.29%. Comparing base (8e7b6ac) to head (cd4e0ea).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
packages/dd-trace/src/exporters/agent/writer.js 66.66% 1 Missing ⚠️
packages/dd-trace/src/startup-log.js 90.90% 1 Missing ⚠️
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     
Flag Coverage Δ
aiguard-macos 39.08% <50.00%> (-0.10%) ⬇️
aiguard-ubuntu 39.13% <50.00%> (-0.10%) ⬇️
aiguard-windows 38.98% <50.00%> (-0.10%) ⬇️
apm-capabilities-tracing-macos 48.82% <87.50%> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu 48.82% <87.50%> (-0.01%) ⬇️
apm-capabilities-tracing-windows 48.55% <87.50%> (-0.01%) ⬇️
apm-integrations-child-process 38.58% <50.00%> (-0.10%) ⬇️
apm-integrations-couchbase-18 37.48% <50.00%> (+0.05%) ⬆️
apm-integrations-couchbase-eol 37.82% <50.00%> (-0.25%) ⬇️
apm-integrations-oracledb 37.98% <50.00%> (-0.09%) ⬇️
appsec-express 55.41% <50.00%> (-0.07%) ⬇️
appsec-fastify 51.98% <50.00%> (-0.07%) ⬇️
appsec-graphql 52.36% <50.00%> (-0.07%) ⬇️
appsec-kafka 44.64% <50.00%> (-0.08%) ⬇️
appsec-ldapjs 44.34% <50.00%> (-0.08%) ⬇️
appsec-lodash 44.02% <50.00%> (-0.08%) ⬇️
appsec-macos 58.52% <50.00%> (-0.07%) ⬇️
appsec-mongodb-core 49.24% <50.00%> (-0.08%) ⬇️
appsec-mongoose 49.92% <50.00%> (-0.08%) ⬇️
appsec-mysql 51.31% <50.00%> (-0.11%) ⬇️
appsec-node-serialize 43.53% <50.00%> (-0.08%) ⬇️
appsec-passport 48.10% <50.00%> (-0.09%) ⬇️
appsec-postgres 51.10% <50.00%> (-0.05%) ⬇️
appsec-sourcing 42.87% <50.00%> (-0.08%) ⬇️
appsec-template 43.70% <50.00%> (-0.08%) ⬇️
appsec-ubuntu 58.54% <50.00%> (-0.07%) ⬇️
appsec-windows 58.40% <50.00%> (-0.07%) ⬇️
instrumentations-instrumentation-bluebird 32.28% <43.75%> (-0.08%) ⬇️
instrumentations-instrumentation-body-parser 40.80% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-child_process 37.89% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-cookie-parser 34.51% <43.75%> (-0.07%) ⬇️
instrumentations-instrumentation-express 34.85% <43.75%> (-0.07%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.64% <43.75%> (-0.07%) ⬇️
instrumentations-instrumentation-express-session 40.41% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-fs 31.88% <43.75%> (-0.08%) ⬇️
instrumentations-instrumentation-generic-pool 29.96% <ø> (ø)
instrumentations-instrumentation-http 39.60% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.28% <43.75%> (-0.08%) ⬇️
instrumentations-instrumentation-mongoose 33.62% <43.75%> (-0.07%) ⬇️
instrumentations-instrumentation-multer 40.53% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-mysql2 38.28% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-passport 44.40% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-passport-http 44.05% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-passport-local 44.62% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-pg 37.80% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-promise 32.21% <43.75%> (-0.08%) ⬇️
instrumentations-instrumentation-promise-js 32.21% <43.75%> (-0.08%) ⬇️
instrumentations-instrumentation-q 32.26% <43.75%> (-0.08%) ⬇️
instrumentations-instrumentation-url 32.18% <43.75%> (-0.08%) ⬇️
instrumentations-instrumentation-when 32.23% <43.75%> (-0.08%) ⬇️
llmobs-ai 41.42% <50.00%> (-0.09%) ⬇️
llmobs-anthropic 40.61% <50.00%> (-0.09%) ⬇️
llmobs-bedrock 39.50% <50.00%> (-0.08%) ⬇️
llmobs-google-genai 40.10% <50.00%> (-0.09%) ⬇️
llmobs-langchain 39.65% <50.00%> (-0.07%) ⬇️
llmobs-openai 44.46% <50.00%> (-0.09%) ⬇️
llmobs-vertex-ai 40.32% <50.00%> (-0.09%) ⬇️
platform-core 28.09% <ø> (ø)
platform-esbuild 31.49% <ø> (ø)
platform-instrumentations-misc 39.62% <ø> (ø)
platform-shimmer 34.83% <ø> (ø)
platform-unit-guardrails 30.37% <ø> (ø)
plugins-azure-event-hubs 22.64% <ø> (ø)
plugins-azure-service-bus 22.08% <ø> (ø)
plugins-bullmq 43.72% <50.00%> (-0.10%) ⬇️
plugins-cassandra 38.02% <50.00%> (-0.09%) ⬇️
plugins-cookie 23.69% <ø> (ø)
plugins-cookie-parser 23.50% <ø> (ø)
plugins-crypto 22.88% <ø> (ø)
plugins-dd-trace-api 38.43% <50.00%> (-0.10%) ⬇️
plugins-express-mongo-sanitize 23.67% <ø> (ø)
plugins-express-session 23.46% <ø> (ø)
plugins-fastify 42.53% <50.00%> (-0.09%) ⬇️
plugins-fetch 38.58% <50.00%> (-0.09%) ⬇️
plugins-fs 38.68% <50.00%> (-0.10%) ⬇️
plugins-generic-pool 22.68% <ø> (ø)
plugins-google-cloud-pubsub 45.73% <50.00%> (-0.11%) ⬇️
plugins-grpc 41.27% <50.00%> (-0.09%) ⬇️
plugins-handlebars 23.71% <ø> (ø)
plugins-hapi 40.43% <50.00%> (-0.09%) ⬇️
plugins-hono 40.69% <50.00%> (-0.09%) ⬇️
plugins-ioredis 38.48% <50.00%> (-0.10%) ⬇️
plugins-knex 23.51% <ø> (ø)
plugins-ldapjs 21.28% <ø> (ø)
plugins-light-my-request 23.15% <ø> (ø)
plugins-limitd-client 32.58% <43.75%> (-0.08%) ⬇️
plugins-lodash 22.74% <ø> (ø)
plugins-mariadb 39.61% <50.00%> (-0.10%) ⬇️
plugins-memcached 38.21% <50.00%> (-0.11%) ⬇️
plugins-microgateway-core 39.44% <50.00%> (-0.09%) ⬇️
plugins-moleculer 40.82% <50.00%> (-0.09%) ⬇️
plugins-mongodb 39.53% <50.00%> (-0.09%) ⬇️
plugins-mongodb-core 39.13% <50.00%> (-0.10%) ⬇️
plugins-mongoose 39.16% <50.00%> (-0.09%) ⬇️
plugins-multer 23.46% <ø> (ø)
plugins-mysql 39.27% <50.00%> (-0.10%) ⬇️
plugins-mysql2 39.31% <50.00%> (-0.10%) ⬇️
plugins-node-serialize 23.73% <ø> (ø)
plugins-opensearch 37.86% <50.00%> (-0.09%) ⬇️
plugins-passport-http 23.56% <ø> (ø)
plugins-postgres 35.77% <50.00%> (-0.08%) ⬇️
plugins-process 22.88% <ø> (ø)
plugins-pug 23.69% <ø> (ø)
plugins-redis 38.96% <50.00%> (-0.10%) ⬇️
plugins-router 43.30% <50.00%> (-0.09%) ⬇️
plugins-sequelize 22.27% <ø> (ø)
plugins-test-and-upstream-amqp10 38.40% <50.00%> (-0.10%) ⬇️
plugins-test-and-upstream-amqplib 43.91% <50.00%> (-0.10%) ⬇️
plugins-test-and-upstream-apollo 39.28% <50.00%> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 38.84% <43.75%> (-0.08%) ⬇️
plugins-test-and-upstream-bunyan 33.89% <43.75%> (-0.08%) ⬇️
plugins-test-and-upstream-connect 41.11% <50.00%> (-0.09%) ⬇️
plugins-test-and-upstream-graphql 40.23% <50.00%> (-0.09%) ⬇️
plugins-test-and-upstream-koa 40.70% <50.00%> (-0.09%) ⬇️
plugins-test-and-upstream-protobufjs 39.07% <43.75%> (-0.08%) ⬇️
plugins-test-and-upstream-rhea 44.16% <50.00%> (-0.13%) ⬇️
plugins-undici 39.38% <50.00%> (-0.09%) ⬇️
plugins-url 22.88% <ø> (ø)
plugins-valkey 38.13% <50.00%> (-0.10%) ⬇️
plugins-vm 22.88% <ø> (ø)
plugins-winston 34.27% <43.75%> (-0.07%) ⬇️
plugins-ws 42.18% <50.00%> (-0.09%) ⬇️
profiling-macos 40.09% <43.75%> (-0.08%) ⬇️
profiling-ubuntu 40.14% <43.75%> (-0.08%) ⬇️
profiling-windows 41.83% <50.00%> (+0.27%) ⬆️
serverless-azure-functions-client 22.38% <ø> (ø)
serverless-azure-functions-eventhubs 22.38% <ø> (ø)
serverless-azure-functions-servicebus 22.38% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 9, 2026

Overall package size

Self size: 4.58 MB
Deduped: 5.42 MB
No deduping: 5.42 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

@datadog-datadog-prod-us1

This comment has been minimized.

@bm1549 bm1549 changed the title fix(startup-log): emit immediately after init and send to stderr fix(startup-log): emit immediately and enable by default Feb 9, 2026
@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Feb 9, 2026

Benchmarks

Benchmark execution time: 2026-02-10 16:24:33

Comparing candidate commit cd4e0ea in PR branch brian.marks/startup-log with baseline commit 8e7b6ac in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 230 metrics, 30 unstable metrics.

@bm1549 bm1549 added semver-minor AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos labels Feb 9, 2026
@bm1549 bm1549 marked this pull request as ready for review February 9, 2026 23:51
@bm1549 bm1549 requested review from a team as code owners February 9, 2026 23:51
@bm1549 bm1549 requested review from BridgeAR and ida613 and removed request for a team February 9, 2026 23:51
Copy link
Copy Markdown
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

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()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Member

@BridgeAR BridgeAR Feb 10, 2026

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we decouple it, we should probably log to stdout, not err (due to not having an error anymore)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

@bm1549 bm1549 Feb 10, 2026

Choose a reason for hiding this comment

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

Discussed offline with @BridgeAR

  1. stderr is the convention for diagnostic logs coming from outside of the primary application. We will follow it here
  2. agent error was re-introduced and will be logged separately, in the same conditions as before

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@bm1549
Copy link
Copy Markdown
Contributor Author

bm1549 commented Feb 10, 2026

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.

@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

@BridgeAR
Copy link
Copy Markdown
Member

BridgeAR commented Feb 10, 2026

I believe the current change would ideally be three:

  1. Changing stdout to stderr (fine as a minor in my opinion for this particular case. Customers are likely not relying on this to happen)
  2. Enabling it by default (major)
  3. Removing the startup error (I think that should be discussed a bit more, since I am uncertain if we really want this)

I added the topic to the guild call to discuss the semverness

@bm1549 bm1549 force-pushed the brian.marks/startup-log branch from ee9bc4b to 806f99c Compare February 10, 2026 14:11
@bm1549 bm1549 requested review from a team as code owners February 10, 2026 14:11
bm1549 and others added 2 commits February 10, 2026 09:11
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]>
@bm1549 bm1549 force-pushed the brian.marks/startup-log branch from 806f99c to 93b78df Compare February 10, 2026 14:11
@bm1549 bm1549 removed request for a team February 10, 2026 14:50
@bm1549 bm1549 marked this pull request as draft February 10, 2026 15:42
@bm1549 bm1549 marked this pull request as ready for review February 10, 2026 16:29
@bm1549 bm1549 requested a review from BridgeAR February 10, 2026 17:24
@bm1549 bm1549 merged commit 6bef168 into master Feb 10, 2026
1072 of 1076 checks passed
@bm1549 bm1549 deleted the brian.marks/startup-log branch February 10, 2026 17:59
dd-octo-sts bot pushed a commit that referenced this pull request Feb 10, 2026
* 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]>
@dd-octo-sts dd-octo-sts bot mentioned this pull request Feb 10, 2026
rochdev added a commit that referenced this pull request Feb 10, 2026
@watson
Copy link
Copy Markdown
Collaborator

watson commented Feb 11, 2026

Heads up: This got reverted in #7478 due to a bug. Consider opening a new PR to fix it properly 🙂

bm1549 added a commit that referenced this pull request Feb 12, 2026
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]>
bm1549 added a commit that referenced this pull request Feb 12, 2026
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]>
bm1549 added a commit that referenced this pull request Feb 12, 2026
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]>
juan-fernandez pushed a commit that referenced this pull request Feb 12, 2026
* 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]>
bm1549 added a commit that referenced this pull request Feb 12, 2026
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]>
dd-octo-sts bot pushed a commit that referenced this pull request Feb 13, 2026
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]>
juan-fernandez pushed a commit that referenced this pull request Feb 18, 2026
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]>
BridgeAR pushed a commit that referenced this pull request Feb 22, 2026
* 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]>
bm1549 added a commit that referenced this pull request Mar 2, 2026
…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]>
bm1549 added a commit that referenced this pull request Mar 6, 2026
#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]>
dd-octo-sts bot pushed a commit that referenced this pull request Mar 7, 2026
#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]>
juan-fernandez pushed a commit that referenced this pull request Mar 10, 2026
#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos semver-minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants