Skip to content

feat: decouple startup logs from DD_TRACE_DEBUG#3749

Draft
bm1549 wants to merge 2 commits intomasterfrom
brian.marks/startup-logs-without-debug
Draft

feat: decouple startup logs from DD_TRACE_DEBUG#3749
bm1549 wants to merge 2 commits intomasterfrom
brian.marks/startup-logs-without-debug

Conversation

@bm1549
Copy link
Copy Markdown
Contributor

@bm1549 bm1549 commented Mar 27, 2026

Description

Decouples DD_TRACE_STARTUP_LOGS from DD_TRACE_DEBUG so that setting DD_TRACE_STARTUP_LOGS=true emits startup configuration logs directly to stderr, regardless of whether debug mode is enabled or how PHP's error_log is configured.

Changes:

  • When DD_TRACE_STARTUP_LOGS=true, startup logs (DATADOG TRACER CONFIGURATION JSON + diagnostics) are written directly to stderr via fprintf
  • The existing LOGEV(STARTUP, ...) path through the tracing log system is preserved for when DD_TRACE_DEBUG enables it
  • Removes the CLI SAPI check that previously suppressed startup logs in CLI mode
  • Changes the default of DD_TRACE_STARTUP_LOGS from true to false

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

🤖 Generated with Claude Code

…ACE_DEBUG

Previously, startup logs were only emitted when DD_TRACE_DEBUG was
enabled. This decouples DD_TRACE_STARTUP_LOGS from DD_TRACE_DEBUG so
that setting DD_TRACE_STARTUP_LOGS=true emits startup configuration
logs regardless of the debug flag or SAPI type.

Also changes the default of DD_TRACE_STARTUP_LOGS from true to false.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bm1549 bm1549 added the AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos label Mar 27, 2026
…S=true

Instead of routing startup logs through the tracing log system (which
goes to PHP's error_log), write them directly to stderr when
DD_TRACE_STARTUP_LOGS is enabled. This ensures startup configuration
is always visible regardless of PHP's error_log setting.

The LOGEV(STARTUP, ...) path is preserved for when DD_TRACE_DEBUG
enables it through the log level system.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@datadog-datadog-prod-us1
Copy link
Copy Markdown

datadog-datadog-prod-us1 bot commented Mar 27, 2026

⚠️ Tests

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 14 Tests failed

testInstrumentation from custom-framework-autoloading-test.DDTrace\Tests\Integrations\Custom\Autoloaded\InstrumentationTest   View in Datadog   (Fix with Cursor)
DDTrace\Tests\Integrations\Custom\Autoloaded\InstrumentationTest::testInstrumentation
Failed asserting that an array has the key 'logs_created'.

tests/Integrations/Custom/Autoloaded/InstrumentationTest.php:79
tests/Common/RetryTraitVersionGeneric.php:28
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:97
testDiagnosticChecksLoggedWhenDebugModeEnabled from custom-framework-autoloading-test.DDTrace\Tests\Integrations\Custom\Autoloaded\StartupLoggingDiagnosticsTest   View in Datadog   (Fix with Cursor)
DDTrace\Tests\Integrations\Custom\Autoloaded\StartupLoggingDiagnosticsTest::testDiagnosticChecksLoggedWhenDebugModeEnabled
Failed asserting that '' contains "DATADOG TRACER DIAGNOSTICS - agent_error:".

tests/Common/BaseTestCase.php:117
tests/Integrations/Custom/Autoloaded/StartupLoggingDiagnosticsTest.php:55
tests/Common/RetryTraitVersionGeneric.php:28
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:97
testLogsGeneratedOnFirstRequest from custom-framework-autoloading-test.DDTrace\Tests\Integrations\Custom\Autoloaded\StartupLoggingTest   View in Datadog   (Fix with Cursor)
DDTrace\Tests\Integrations\Custom\Autoloaded\StartupLoggingTest::testLogsGeneratedOnFirstRequest
Exception: No JSON found in startup log

tests/Integrations/Custom/Autoloaded/StartupLoggingTest.php:105
tests/Integrations/Custom/Autoloaded/StartupLoggingTest.php:59
tests/Common/RetryTraitVersionGeneric.php:28
phpvfscomposer://tests/vendor/phpunit/phpunit/phpunit:97
View all

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.64% (-0.04%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 493a634 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.77%. Comparing base (fd1ba67) to head (493a634).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #3749       +/-   ##
===========================================
+ Coverage   68.78%   86.77%   +17.98%     
===========================================
  Files         166       24      -142     
  Lines       19015     5269    -13746     
  Branches     1792        0     -1792     
===========================================
- Hits        13079     4572     -8507     
+ Misses       5124      697     -4427     
+ Partials      812        0      -812     
Flag Coverage Δ
helper-rust-integration 78.79% <ø> (-0.03%) ⬇️
helper-rust-unit 49.17% <ø> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 145 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fd1ba67...493a634. Read the comment docs.

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

@pr-commenter
Copy link
Copy Markdown

pr-commenter bot commented Mar 27, 2026

Benchmarks [ tracer ]

Benchmark execution time: 2026-03-27 23:45:59

Comparing candidate commit 493a634 in PR branch brian.marks/startup-logs-without-debug with baseline commit fd1ba67 in branch master.

Found 1 performance improvements and 2 performance regressions! Performance is the same for 190 metrics, 1 unstable metrics.

scenario:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟥 execution_time [+5.398µs; +6.322µs] or [+5.458%; +6.391%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟥 execution_time [+6.846µs; +8.374µs] or [+6.661%; +8.148%]

scenario:TraceSerializationBench/benchSerializeTrace

  • 🟩 execution_time [-20.563µs; -8.837µs] or [-4.730%; -2.033%]

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants