Skip to content

Conversation

@bm1549
Copy link
Contributor

@bm1549 bm1549 commented Feb 6, 2026

Motivation

Add comprehensive tests for tracer startup log behavior across supported languages. These tests verify that tracers correctly emit startup configuration logs with the appropriate default behavior and when explicitly configured via DD_TRACE_STARTUP_LOGS, ensuring proper observability and configuration visibility.

Changes

Adds tests/parametric/test_startup_logs.py with four test cases:

  1. test_startup_logs_default: Verifies default startup log behavior when DD_TRACE_STARTUP_LOGS is not set
  2. test_startup_logs_enabled: Verifies that startup logs are emitted when DD_TRACE_STARTUP_LOGS=true
  3. test_startup_logs_disabled: Verifies that startup logs are suppressed when DD_TRACE_STARTUP_LOGS=false
  4. test_startup_logs_diagnostic_agent_unreachable: Verifies diagnostic messages appear when the agent is unreachable

Language-Specific Handling

The tests handle language-specific differences:

  • Node.js Writes on first tracer flush, rather than on startup
  • Node.js and Ruby: Write to stdout (require trace triggering for Node.js)
  • .NET: Writes to a file (dotnet-tracer-managed*) instead of stdout/stderr
  • Other languages: Output to stderr

Recent Updates

  • Refactored test implementation to reduce duplication and improve maintainability (addresses code review feedback)

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

@bm1549 bm1549 added the ai-generated The pull request includes a significant amount of AI-generated code label Feb 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 6, 2026

CODEOWNERS have been resolved as:

tests/parametric/test_startup_logs.py                                   @DataDog/system-tests-core @DataDog/apm-sdk-capabilities
manifests/cpp.yml                                                       @DataDog/dd-trace-cpp
manifests/nodejs.yml                                                    @DataDog/dd-trace-js
manifests/php.yml                                                       @DataDog/apm-php @DataDog/asm-php
manifests/rust.yml                                                      @DataDog/apm-rust

@datadog-datadog-prod-us1
Copy link

datadog-datadog-prod-us1 bot commented Feb 6, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 98790a0 | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@bm1549 bm1549 force-pushed the brian.marks/startup-log branch from b90773c to 19694ec Compare February 10, 2026 00:18
@bm1549 bm1549 marked this pull request as ready for review February 10, 2026 00:18
@bm1549 bm1549 requested review from a team as code owners February 10, 2026 00:18
@bm1549 bm1549 requested review from BridgeAR and removed request for a team February 10, 2026 00:18
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19694ec8ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

else:
try:
# Node.js and Ruby log to stdout, other libraries only log stderr
if context.library in ("nodejs", "ruby"):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optional: Ideally a test should not have different execution paths for different languages. You should make multiple tests and use the manifests to activate the relevant one for each language. This let's the easy win process catch any evolution of the tracer behavior in the furture.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to keep the test as-is for now. I plan to update the other languages to fix them in the very short term via DataDog/dd-trace-rb#5342 and DataDog/dd-trace-js#7470 - one is merged and the other one is close to being merged

Once these are in, I can remove all of the language-conditional logic, with the exception of the .NET log file logic. However, I believe it is helpful to have in the same test to showcase the deviation of .NET, rather than appearing as two valid behaviors

@nccatoni
Copy link
Collaborator

I noticed that you put the AI generated label on this PR, would you mind telling me how much of the code was generated, with what tool and how much prompting you did (one prompt or multiple, and whether you needed to give the llm a lot of information or not). I'm asking to evaluate the effectiveness of the AI rules in the repo

@bm1549
Copy link
Contributor Author

bm1549 commented Feb 10, 2026

I noticed that you put the AI generated label on this PR, would you mind telling me how much of the code was generated, with what tool and how much prompting you did (one prompt or multiple, and whether you needed to give the llm a lot of information or not). I'm asking to evaluate the effectiveness of the AI rules in the repo

I started using Cursor, but moved to Claude Code afterwards since it tended to perform better in this repo. I'm a bit of a novice at them, so I'm just experimenting

Nearly all of the code was generated, but it took a ton of prompting to identify the different language-specific behaviors present and it couldn't figure out C++/PHP at all. After making the changes, it was a bit verbose/hard to follow so I prompted it to clean itself up

One piece that was a struggle was the runtime for format.sh and re-running parametric tests as it tried to fix the tests - this was the clear largest time spend in this task. As a result, I asked Claude to optimize both of them, resulting in #6256 and #6258, which I have as draft since I haven't fully wrapped my head around each line of code. If you're more comfortable in those parts of the codebase, I'd encourage you to check them out since it may take me some time to go through them and understand the potential consequences of the optimizations

Moved test skip declarations from inline decorators (@missing_feature, @incomplete_test_app) to manifest files for cpp, nodejs, php, and rust. Also added span trigger in test_startup_logs_diagnostic_agent_unreachable to ensure tracers attempt agent connection.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@bm1549 bm1549 requested review from a team as code owners February 10, 2026 16:19
@bm1549 bm1549 requested review from dubloom and removed request for a team February 10, 2026 16:19
@p-datadog
Copy link
Member

Sorry meant to update DataDog/dd-trace-rb#5342 instead of this PR.

@bm1549 bm1549 requested a review from nccatoni February 10, 2026 18:08
Copy link
Member

@genesor genesor left a comment

Choose a reason for hiding this comment

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

Looks ok overall, the readability could be improve to have most of the test follow a single path where possible.

test_library.dd_flush()

# For .NET, startup logs are written to a file instead of stdout/stderr
if context.library == "dotnet":
Copy link
Member

Choose a reason for hiding this comment

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

Could we get this condition reworked (and the similar ones in the other tests) to an simpler if / else if / else

I don't think it's useful to have dotnet in its own if and other language in another if in the else condition.

if match:
logger.error(logs)
pytest.fail(
# f"Startup log found when DD_TRACE_STARTUP_LOGS=false. "
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be uncommented so we understand what's going on ?

Comment on lines 127 to 133
if logs is not None:
startup_log_pattern = r"DATADOG (TRACER )?CONFIGURATION( - (CORE|TRACING|PROFILING|.*))?"
if re.search(startup_log_pattern, logs, re.IGNORECASE):
pytest.fail(
"Startup log found in .NET log file when DD_TRACE_STARTUP_LOGS=false. "
f"Content (first 1000 chars): {logs[:1000]}"
)
Copy link
Member

Choose a reason for hiding this comment

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

This could be factorized with the same check below

Copy link
Collaborator

@nccatoni nccatoni left a comment

Choose a reason for hiding this comment

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

Thank you for the changes and for the insides in your AI development workflow. Everything looks good to me now but you should also get an approval from someone familiar with the feature

Addresses code review feedback by consolidating duplicated log retrieval
logic and simplifying conditional structures. Changes include:
- Extract STARTUP_LOG_PATTERN to module-level constant
- Add unified _get_startup_logs() helper function
- Replace nested if/else with clearer if/elif/else pattern
- Improve error messages to include matched pattern information

This reduces code duplication (~60 lines to ~30 shared lines) and makes
the test logic easier to follow and maintain.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@bm1549
Copy link
Contributor Author

bm1549 commented Feb 12, 2026

Thanks for the review! I've addressed all the feedback:

Line 50 (nested if/else): Replaced with if/elif/else pattern in new _get_startup_logs() helper
Line 133 (duplication): Consolidated all log retrieval into single helper function
Line 150 (error message): Uncommented and fixed typo (10000→1000)

Changes:

  • Added STARTUP_LOG_PATTERN module constant (eliminates 4 duplicate regex definitions)
  • Created _get_startup_logs() helper with clearer conditional structure
  • All 4 test methods now use the helper (net -16 lines)
  • Error messages now include matched pattern for easier debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated The pull request includes a significant amount of AI-generated code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants