Skip to content

Skip reporting synthetic failures#11259

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 9 commits intomasterfrom
mo.atie/apmlp-1296-skip-synthetic-failures
May 6, 2026
Merged

Skip reporting synthetic failures#11259
gh-worker-dd-mergequeue-cf854d[bot] merged 9 commits intomasterfrom
mo.atie/apmlp-1296-skip-synthetic-failures

Conversation

@mhdatie
Copy link
Copy Markdown

@mhdatie mhdatie commented May 1, 2026

What Does This Do

Extends TagInitializationErrors.java to also tag executionError and test exception synthetic testcases
with dd_tags[test.final_status]=skip, unconditionally. Previously, only intermediate
initializationError retries were tagged.

The tagging logic is refactored into a shared tagSkip helper that uses direct child element lookups
(instead of getElementsByTagName, which searches all descendants) and is idempotent - testcases already
carrying the property are left unchanged.

This fix has been applied with Claude Code, and refactors have been made to optimize the code and enhance the comments with the help of the local code review Claude plugin. A follow up PR will be opened to rename the executor file to TagSyntheticFailures.java

Detected in CI:
Screenshot 2026-05-04 at 4 35 51 PM

Which should stop such tests from being labelled as failures (master)
Screenshot 2026-05-04 at 4 47 42 PM

Motivation

executionError and test exception are framework-level synthetic entries that never represent a real
test result. Without this change, Test Optimization treats them as genuine failures, producing noise in
the test results dashboard. Like initializationError intermediates, they should be skipped so only
real test outcomes are surfaced.

Additional Notes

  • Follow up PR - Rename from TagInitializationErrors.java to TagSyntheticFailures.java

Contributor Checklist

Jira ticket: APMLP-1296

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

@mhdatie mhdatie changed the title Mo.atie/apmlp 1296 skip synthetic failures Skip reporting synthetic failures May 1, 2026
@mhdatie mhdatie force-pushed the mo.atie/apmlp-1296-skip-synthetic-failures branch from 18e0884 to b93d638 Compare May 4, 2026 19:05
@mhdatie mhdatie marked this pull request as ready for review May 4, 2026 20:49
@mhdatie mhdatie requested a review from a team as a code owner May 4, 2026 20:49
@mhdatie mhdatie requested review from randomanderson and removed request for a team May 4, 2026 20:49
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Hi! 👋 Thanks for your pull request! 🎉

To help us review it, please make sure to:

  • Add at least one type, and one component or instrumentation label to the pull request

If you need help, please check our contributing guidelines.

@mhdatie mhdatie added type: enhancement Enhancements and improvements comp: ci visibility Continuous Integration Visibility labels May 4, 2026
var name = e.getAttribute("name");
if ("initializationError".equals(name)) {
byClassname.computeIfAbsent(e.getAttribute("classname"), k -> new ArrayList<>()).add(e);
} else if ("executionError".equals(name) || "test exception".equals(name)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had codex take a look, and it pointed out that we have a real test case with the name of "test exception": https://github.com/DataDog/dd-trace-java/blob/master/dd-java-agent/instrumentation-testing/src/main/groovy/datadog/trace/agent/test/base/HttpServerTest.groovy#L1251. The test is marked as Flaky, so the output is skipped anyway IIUC, but worth noting... We could consider changing the test case name to keep this logic simpler?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

good idea, will make an update here

Copy link
Copy Markdown
Author

@mhdatie mhdatie May 5, 2026

Choose a reason for hiding this comment

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

Comment thread .gitlab/TagInitializationErrors.java Outdated
return null;
}

static boolean tagSkip(org.w3c.dom.Document doc, Element testcase) {
Copy link
Copy Markdown
Contributor

@sarahchen6 sarahchen6 May 4, 2026

Choose a reason for hiding this comment

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

Can import org.w3c.dom.Document and set this to just Document

Copy link
Copy Markdown
Author

@mhdatie mhdatie May 5, 2026

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

@sarahchen6 sarahchen6 left a comment

Choose a reason for hiding this comment

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

A couple small comments, but otherwise looks good!

@PerfectSlayer PerfectSlayer added comp: tooling Build & Tooling and removed comp: ci visibility Continuous Integration Visibility labels May 5, 2026
Copy link
Copy Markdown
Contributor

@PerfectSlayer PerfectSlayer left a comment

Choose a reason for hiding this comment

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

Updating labels and minor comments

Comment thread .gitlab/TagInitializationErrors.java Outdated
var children = parent.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
var child = children.item(i);
if (child instanceof Element e && tagName.equals(e.getTagName())) return e;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 nitpick: Please avoid one-line for readability / uniformity (this is usually enforced using spotless on the project)‏

Suggested change
if (child instanceof Element e && tagName.equals(e.getTagName())) return e;
if (child instanceof Element e && tagName.equals(e.getTagName())) {
return e;
}

Copy link
Copy Markdown
Author

@mhdatie mhdatie May 5, 2026

Choose a reason for hiding this comment

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

I ran ./gradlew spotlessApply and it doesn't seem to apply to .gitlab/*. When I changed the spotless.gradle config file to consider them and ran it, it wasn't applying the check here but did in other places 🤔

Claude analyzed the following:

The issue is that google-java-format does not add missing bracesit only handles whitespace, indentation, and line  
  wrapping. Line 111:                                                                                                   
                                                                                                                        
  if (child instanceof Element e && tagName.equals(e.getTagName())) return e;                                           
                                                                                                                        
  is syntactically valid, fits within the 100-character column limit (81 chars), so the formatter has nothing to change.
   This is a known gap: the Google Java Style Guide §4.1.1 requires braces on all if/for/while bodies, but              
  google-java-format deliberately does not restructure code to enforce that.                                            
                  
  You need to add the braces manually:

  if (child instanceof Element e && tagName.equals(e.getTagName())) {
    return e;                                                                                                           
  }

The check to enable spotless checks on that directory was:

project.pluginManager.withPlugin('java') {
    java {
      toggleOffOn()
      // set explicit target to workaround https://github.com/diffplug/spotless/issues/1163
      target 'src/**/*.java'
      // ignore embedded test projects and everything in build dir, e.g. generated sources
      targetExclude('src/test/resources/**', buildDirectoryFiles)
      tableTestFormatter('1.1.1')
      googleJavaFormat('1.35.0')
    }
  }

  // Root project doesn't apply the java plugin, so withPlugin('java') never fires for it.
  // Configure a separate java block to cover .gitlab/*.java scripts.
  if (project == project.rootProject && !project.plugins.hasPlugin('java')) {
    java {
      toggleOffOn()
      target '.gitlab/*.java'
      targetExclude(buildDirectoryFiles)
      tableTestFormatter('1.1.1')
      googleJavaFormat('1.35.0')
    }
  }

I will fix them manually for now, but wonder what your thoughts are here

Copy link
Copy Markdown
Author

@mhdatie mhdatie May 5, 2026

Choose a reason for hiding this comment

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

Comment thread .gitlab/TagInitializationErrors.java Outdated
}
boolean modified = false;
for (var group : byClassname.values()) {
if (group.size() <= 1) continue;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💭 thought: ‏Not sure what this guard is for? 🤔 The next loop should not trigger in size <= 1

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

heh, took me multiple attempts to convince Claude that your comment made more sense. Great catch

Copy link
Copy Markdown
Author

@mhdatie mhdatie May 5, 2026

Choose a reason for hiding this comment

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

@mhdatie mhdatie requested a review from a team as a code owner May 5, 2026 20:53
@mhdatie mhdatie requested a review from ygree May 5, 2026 20:53
@mhdatie mhdatie force-pushed the mo.atie/apmlp-1296-skip-synthetic-failures branch from 49ef484 to 9cb3b43 Compare May 5, 2026 21:46
@mhdatie mhdatie added this pull request to the merge queue May 6, 2026
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 6, 2026

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 6, 2026

View all feedbacks in Devflow UI.

2026-05-06 13:39:30 UTC ℹ️ Start processing command /merge


2026-05-06 13:39:36 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-05-06 14:49:14 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 6, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 7fb9855 into master May 6, 2026
570 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the mo.atie/apmlp-1296-skip-synthetic-failures branch May 6, 2026 14:49
@github-actions github-actions Bot added this to the 1.63.0 milestone May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: tooling Build & Tooling type: enhancement Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants