Skip to content

feat(mock-intake): add option to disable captures - #201

Open
lucaspimentel wants to merge 2 commits into
mainfrom
lpimentel/mock-intake-disable-captures
Open

lucaspimentel wants to merge 2 commits into
mainfrom
lpimentel/mock-intake-disable-captures

Conversation

@lucaspimentel

Copy link
Copy Markdown
Member

What does this PR do?

Adds MockIntakeOptions::disable_captures, off by default. When set, the mock intake keeps no captures in memory: stats_payloads(), trace_payloads(), pipeline_stats_payloads() and requests_for_path() return nothing, and no raw CapturedRequest is built or stored.

Everything else is unchanged: decoding, response status codes, request summaries, JSON dumps, request ids and stats failure injection all still happen.

Motivation

The standalone mock intake binary in datadog-lambda-extension (bottlecap/src/bin/mock-intake/main.rs) never reads the captures, so its memory grows without limit while it runs. This gives that binary a way to turn captures off.

Additional Notes

  • Building the capture is skipped entirely, so the body copy and header strings are not made and the captures lock is not taken.
  • This is a breaking change for any caller that lists every field of MockIntakeOptions in a struct literal. datadog-lambda-extension does this, so its pin bump must add disable_captures: true in the same change, otherwise it stops compiling.
  • Only the new test in this repo sets the flag, so the intended user is the Bottlecap binary.

Describe how to test/QA your changes

New test disable_captures_keeps_responses_and_dumps_but_stores_nothing covers the flag on: unchanged statuses (including failure injection), one JSON dump per decoded attempt, and empty results from all four query methods.

cargo test -p datadog-mock-intake passes, and cargo fmt --check and cargo clippy -p datadog-mock-intake --all-targets -- -D warnings are clean.

@lucaspimentel

Copy link
Copy Markdown
Member Author

@DataDog review

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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.

Bits Code Review: PASS

More details

The capture flag gates raw-request construction and capture storage while preserving decoding, failure injection, response handling, and JSON dumps. The static reviewer identified no actionable defects.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit fc89cb1

@lucaspimentel
lucaspimentel marked this pull request as ready for review November 5, 2026 15:56
@lucaspimentel
lucaspimentel requested review from a team as code owners November 5, 2026 15:56
@lucaspimentel
lucaspimentel requested review from apiarian-datadog and lym953 and a balanced review from Copilot and removed request for a team November 5, 2026 15:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-11-05T15:57:31.642060Z fc89cb1 Draft marked ready
🔒 Security Review ✅ Completed 2026-11-05T15:59:03.134298Z fc89cb1 Draft marked ready
ℹ️ 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.

Copilot AI 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.

🟢 Approval recommended

The opt-in capture-disable change has no active review issues.

No open issues 🎉

What changed in this PR

Adds an opt-in capture-disable mode to the shared mock intake, allowing long-running consumers to avoid accumulating captures in memory while preserving request processing and diagnostics.

Changes:

  • Adds MockIntakeOptions::disable_captures, defaulting to false.
  • Skips raw capture construction and capture storage when enabled.
  • Adds coverage for unchanged response statuses, failure injection, JSON dumps, and empty capture queries.

Size: 10 added and 7 removed core-code lines, excluding documentation; 75 added test lines.

File Description
crates/​datadog-mock-intake/​src/​lib.rs Adds and documents the option, gates capture creation and storage, and tests disabled-capture behavior.

Review effort: Balanced

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants