Skip to content

Add decoded span assert rules - #12088

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
bbujon/smoke-tests-decoded-span-assertions
Jul 31, 2026
Merged

Add decoded span assert rules#12088
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
bbujon/smoke-tests-decoded-span-assertions

Conversation

@PerfectSlayer

@PerfectSlayer PerfectSlayer commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

What Does This Do

This PR introduces decoded span assert rules.

EDIT: This PR unit tests need test agent JSON  span deserialization first. I’ll introduce an intermediate PR to the stack to add it. It is still good to review in the meantime.

Motivation

The goal is to provide capabilities for smoke tests to evaluate trace and span structures and values.

Additional Notes

This is mainly inspired from my prior work with instrumentation tests but decoded spans are not like DDSpan. They don’t hold the same values / types so new rules needed to be put in place for smoke tests.

Contributor Checklist

Jira ticket: APMLP-1247

@PerfectSlayer PerfectSlayer added the type: feature Enhancements and improvements label Jul 28, 2026
@PerfectSlayer
PerfectSlayer requested a review from a team as a code owner July 28, 2026 09:15
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

View session in Datadog

Bits Code status: ✅ Done

Comment @DataDog to request changes

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

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.

⚠️ Autotest was unable to complete this review. View session

Please try again by commenting @autotest review.

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

Copy link
Copy Markdown

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: 513469965b

ℹ️ 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".

Comment thread dd-smoke-tests/src/main/java/datadog/smoketest/trace/SmokeTraceAssertions.java Outdated
Comment thread dd-smoke-tests/src/main/java/datadog/smoketest/trace/SpanMatcher.java Outdated
@datadog-datadog-prod-us1-2

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.03 s 14.07 s [-1.1%; +0.6%] (no difference)
startup:insecure-bank:tracing:Agent 12.93 s 12.94 s [-0.9%; +0.7%] (no difference)
startup:petclinic:appsec:Agent 16.99 s 16.82 s [+0.1%; +1.9%] (maybe worse)
startup:petclinic:iast:Agent 16.91 s 16.47 s [-1.8%; +7.1%] (no difference)
startup:petclinic:profiling:Agent 16.77 s 16.89 s [-2.0%; +0.7%] (no difference)
startup:petclinic:sca:Agent 16.77 s 16.57 s [+0.3%; +2.2%] (maybe worse)
startup:petclinic:tracing:Agent 16.12 s 16.14 s [-1.1%; +0.9%] (no difference)

Commit: b2b41a71 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

@PerfectSlayer
PerfectSlayer marked this pull request as draft July 28, 2026 09:59
@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-decoded-span-assertions branch from 5134699 to d7f5363 Compare July 28, 2026 16:42
@PerfectSlayer

Copy link
Copy Markdown
Collaborator Author

@autotest review

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

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.

Datadog Autotest: FAIL

Unordered trace matching can reject a valid trace when a reusable childOfPrevious matcher first probes a non-matching candidate: assertSpan mutates the matcher to that candidate's parent ID, so later candidates are checked against stale state. Keep the resolved parent matcher local instead of mutating the configured matcher.

Open Bits AI session

🤖 Datadog Autotest · Commit d7f5363 · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Comment thread dd-smoke-tests/src/main/java/datadog/smoketest/trace/SpanMatcher.java Outdated
@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-decoded-span-assertions branch from d7f5363 to 798798a Compare July 28, 2026 17:31
@PerfectSlayer
PerfectSlayer marked this pull request as ready for review July 28, 2026 17:34

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

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.

Datadog Autotest: PASS

More details

The decoder and assertion paths do not show a confirmed behavioral regression or diff-only production hazard. Adversarial cases were reviewed for malformed JSON, unsigned IDs, missing fields, duplicate/unordered trace matching, ancestry ordering, partial trace chunks, and nested meta_struct values; execution was blocked before tests ran because the checkout requires JDK 25 and the sandbox has only JDK 8/11/17/21.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 798798a · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@PerfectSlayer

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 798798ab44

ℹ️ 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".

@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-decoded-span-assertions branch from 798798a to 1004c0a Compare July 29, 2026 10:00
@PerfectSlayer

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 1004c0a40d

ℹ️ 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".

Comment on lines +39 to +40
@Json(name = "meta_struct")
Map<String, Object> metaStruct;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Normalize numeric meta_struct values across decoders

When a meta_struct entry contains numeric leaves, Moshi's generic Object adapter materializes them as Double, while the existing msgpack decoder returns Long for integers and Float for floating-point values in SpanV04.convertValueToObject (SpanV04.java:204-207). Consequently, an exact metaStruct(..., is(expected)) matcher or a predicate casting a numeric leaf can pass with the in-process backend and fail with the dd-apm-test-agent JSON backend; decode these nested numbers into the same representation before exposing the shared DecodedSpan model.

Useful? React with 👍 / 👎.

@PerfectSlayer
PerfectSlayer changed the base branch from bbujon/smoke-tests-decoded-spans to bbujon/smoke-tests-test-agent-decoding July 29, 2026 12:04

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

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.

Datadog Autotest: PASS

More details

The decoded-span assertion layer matches the intended behavior for positional, sorted, ancestry-based, unordered, parent-link, default-constraint, and meta_struct checks. No diff-only regression was confirmed; focused Gradle execution was attempted but the sandbox lacks JDK 25 and cannot download it, so validation is limited to source analysis and existing test coverage.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Datadog Autotest · Commit 1004c0a · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-decoded-span-assertions branch from 1004c0a to 8583373 Compare July 29, 2026 12:40
@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-test-agent-decoding branch from fa90299 to 8ff8af2 Compare July 29, 2026 12:40
@PerfectSlayer

Copy link
Copy Markdown
Collaborator Author

@codex review

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

Copy link
Copy Markdown

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: 85833735e9

ℹ️ 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".

Comment thread dd-smoke-tests/src/main/java/datadog/smoketest/trace/SpanMatcher.java Outdated
@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-test-agent-decoding branch from 8ff8af2 to 3e09e7c Compare July 29, 2026 13:02
@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-decoded-span-assertions branch from 8583373 to d100b5a Compare July 29, 2026 13:03
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Bits found no code fix to apply

🟢 Investigated · ⚪ No code fix needed

muzzle: [6/8] fails because Freemarker 2.3.9 and 2.3.23 unexpectedly pass two configured negative muzzle validations. The identical failure occurs on base commit 3e09e7c, so it is unrelated to this pull request’s decoded-span assertion helpers and no code change was made.


View in Datadog | Reviewed commit d100b5a · Any feedback? Reach out in #deveng-pr-agent

@dougqh dougqh left a comment

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.

Nice - I've wanted something like for a long long time

@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-test-agent-decoding branch from 3e09e7c to 6cba0d6 Compare July 30, 2026 04:16
@PerfectSlayer
PerfectSlayer requested review from a team as code owners July 30, 2026 04:16
@PerfectSlayer
PerfectSlayer requested review from claponcet, erikayasuda and sarahchen6 and removed request for a team July 30, 2026 04:16
@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-decoded-span-assertions branch from d100b5a to 181f643 Compare July 30, 2026 04:17
@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-test-agent-decoding branch from 6cba0d6 to 98b712f Compare July 30, 2026 05:43
@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-decoded-span-assertions branch 2 times, most recently from d47055e to 62e8fce Compare July 30, 2026 05:45
@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-test-agent-decoding branch from 98b712f to 7a8b69b Compare July 30, 2026 07:00
Base automatically changed from bbujon/smoke-tests-test-agent-decoding to master July 30, 2026 08:54

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 Bot left a comment

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.

Datadog Autotest: FAIL

The new unordered/additional-trace matching path aborts instead of skipping an unrelated candidate when childOfPrevious() is evaluated on that candidate's first span. A realistic extra trace with the same span count can therefore fail the smoke test before the valid expected trace is examined; the matcher should report this candidate as a normal mismatch.

View proposed fix
Open Bits AI session

🤖 Datadog Autotest · Commit 62e8fce · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

return is(trace.get(this.parentSpanIndex).getSpanId());
} else if (this.parentIdMatcher == CHILD_OF_PREVIOUS_MATCHER) {
if (spanIndex == 0) {
throw new IllegalStateException("Cannot use childOfPrevious() matcher on the first span");

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.

P1 Candidate mismatch escapes unordered trace search

Smoke tests that intentionally ignore additional traces can fail or abort whenever an unrelated trace has the same span count and is examined before the expected trace.

Assertion details
  • Input: Call assertTraces with options -> options.unorder().ignoreAdditionalTraces(), where the first unrelated trace has at least two spans and the matcher includes childOfPrevious() at matcher index 0; place a valid matching trace after it.
  • Expected: The unrelated candidate should be treated as a non-match and the search should continue to the later valid trace.
  • Actual: SpanMatcher.parentIdMatcher throws IllegalStateException when childOfPrevious() is checked at span index 0. SmokeTraceAssertions only catches AssertionError while trying candidate traces, so the IllegalStateException escapes and the later valid trace is never examined.

Was this helpful? React 👍 or 👎
🤖 Datadog Autotest · What is Autotest? · @DataDog review to ask questions · Any feedback? Reach out in #autotest

Suggested change
throw new IllegalStateException("Cannot use childOfPrevious() matcher on the first span");
throw new AssertionError("Cannot use childOfPrevious() matcher on the first span");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is on purpose. childOfPrevious() can never be used on first span matcher.

@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-decoded-span-assertions branch from 62e8fce to fd5c521 Compare July 30, 2026 09:20
@PerfectSlayer

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 30, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-30 13:57:09 UTC ℹ️ Start processing command /merge


2026-07-30 13:57:14 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-30 14:02:25 UTCMergeQueue: This merge request was updated

This PR is rejected because it was updated

@PerfectSlayer
PerfectSlayer force-pushed the bbujon/smoke-tests-decoded-span-assertions branch from fd5c521 to b2b41a7 Compare July 30, 2026 14:02
@PerfectSlayer

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 30, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-30 14:09:01 UTC ℹ️ Start processing command /merge


2026-07-30 14:09:07 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-07-30 15:05:09 UTC ℹ️ MergeQueue: merge request added to the queue

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


2026-07-30 15:48:37 UTCMergeQueue: The build pipeline contains failing jobs for this merge request

Build pipeline has failing jobs for 0deb35d:

⚠️ Do NOT retry failed jobs directly (why?).

What to do next?

  • Investigate the failures and when ready, re-add your pull request to the queue!
  • If your PR checks are green, try to rebase/merge. It might be because the CI run is a bit old.
  • Any question, go check the FAQ.
Details

Since those jobs are not marked as being allowed to fail, the pipeline will most likely fail.
Therefore, and to allow other builds to be processed, this merge request has been rejected and the pipeline got canceled.

@PerfectSlayer

Copy link
Copy Markdown
Collaborator Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 31, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-31 05:13:49 UTC ℹ️ Start processing command /merge


2026-07-31 05:13:54 UTC ℹ️ MergeQueue: pull request added to the queue

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


2026-07-31 06:04:18 UTC ℹ️ MergeQueue: This merge request was merged

@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot merged commit b22cb26 into master Jul 31, 2026
604 of 606 checks passed
@gh-worker-dd-mergequeue-cf854d
gh-worker-dd-mergequeue-cf854d Bot deleted the bbujon/smoke-tests-decoded-span-assertions branch July 31, 2026 06:04
@github-actions github-actions Bot added this to the 1.65.0 milestone Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: testing Testing type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants