Skip to content

Handle servlet response lifecycle boundaries during RUM injection - #12497

Open
amarziali wants to merge 4 commits into
masterfrom
andrea.marziali/rum-response-lifecycle
Open

amarziali wants to merge 4 commits into
masterfrom
andrea.marziali/rum-response-lifecycle

Conversation

@amarziali

Copy link
Copy Markdown
Contributor

What Does This Do

Preserves servlet response semantics when RUM injection encounters flush, reset, error, or redirect boundaries.

The injecting streams retain a small look-behind buffer while searching for </head>. Previously, that buffered state could survive lifecycle operations, causing delayed output, matching across committed
boundaries, or content from a reset response to be written later.

This PR:

  • Drains buffered content and resets partial marker matching on flush() and commit().
  • Adds a discard operation for content removed by the servlet container.
  • Handles flushBuffer(), resetBuffer(), reset(), sendError(), and sendRedirect().
  • Re-arms injection after resetBuffer().
  • Retires old wrappers and restores fresh injection state after reset().
  • Applies equivalent behavior to javax Servlet 3 and Jakarta Servlet 5.

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@amarziali amarziali added type: feature Enhancements and improvements tag: ai generated Largely based on code generated by an AI or LLM comp: rum Realtime User Monitoring labels Sep 15, 2026
@datadog-official

This comment has been minimized.

@amarziali
amarziali marked this pull request as ready for review September 15, 2026 11:07
@amarziali
amarziali requested review from a team as code owners September 15, 2026 11:07
@amarziali
amarziali requested review from ValentinZakharov and bric3 and removed request for a team September 15, 2026 11:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-15T14:03:50.702130Z c07186b Manual request
🔒 Security Review Completed 2026-09-15T14:02:22.761885Z c07186b Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-official datadog-official 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

An asynchronous reset can start old response wrappers again. Each wrapper can then add the RUM script, so one response can contain the script more than once.

Open Bits AI session

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

@dd-octo-sts

dd-octo-sts Bot commented Sep 15, 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 13.93 s 13.96 s [-0.9%; +0.5%] (no difference)
startup:insecure-bank:tracing:Agent 12.92 s 13.00 s [-1.2%; +0.0%] (no difference)
startup:petclinic:appsec:Agent 17.05 s 16.93 s [-0.1%; +1.6%] (no difference)
startup:petclinic:iast:Agent 16.92 s 16.43 s [-1.5%; +7.4%] (no difference)
startup:petclinic:profiling:Agent 16.60 s 16.84 s [-2.6%; -0.3%] (maybe better)
startup:petclinic:sca:Agent 16.95 s 16.67 s [+0.6%; +2.8%] (maybe worse)
startup:petclinic:tracing:Agent 16.18 s 16.10 s [-0.3%; +1.3%] (no difference)

Commit: c07186bf · 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.

@amarziali
amarziali force-pushed the andrea.marziali/rum-response-lifecycle branch from bda424e to 1b514ff Compare September 15, 2026 12:08
@amarziali

Copy link
Copy Markdown
Contributor Author

@DataDog review

@datadog-official datadog-official 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 change drains buffered output at flush boundaries. It discards buffered output at reset, error, and redirect boundaries, and it keeps injection state aligned in both servlet versions.

Was this helpful? React 👍 or 👎

Open Bits AI session

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

@amarziali

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 1b514ff0de

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: 1b514ff0de

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

@amarziali

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 52946eff9e

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@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: 52946eff9e

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

@amarziali

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: c07186bfc7

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: c07186bfc7

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

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

Labels

comp: rum Realtime User Monitoring tag: ai generated Largely based on code generated by an AI or LLM type: feature Enhancements and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant