feat(value): add ObjectMap::extract_if #2072
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"a5d5f6e8241012bb91b27219af10f3efa5fa93fc","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->
<details>
<summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-19T09:45:08.512875Z">2026-11-19T09:45:08.512875Z</relative-time> | a5d5f6e | Draft marked ready |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
</details>
<details>
<summary>More details</summary>
The wrapper preserves BTreeMap’s extraction ordering, predicate mutation, and early-drop behavior through direct delegation. No actionable defect was identified; full test validation remains blocked by the pinned-toolchain download failure.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit a5d5f6e</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=422f8c6e-ccfe-40c9-aae8-d4d45f3d607b -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:b0c0c4f75135a93ca85dc47a5edc5baf3eaa510e967642c8818d6b2fd292d66e:bundle -->
Approved these changes.
Approved these changes.
clementd-dd
gwenaskell
Summary
Add
ObjectMap::extract_if, a thin wrapper aroundBTreeMap::extract_ifthat returns an opaqueObjectMapExtractIfiterator.Before #2005, callers could call
extract_ifon the underlyingBTreeMapto move matching entries out of an object without cloning keys.ObjectMapdoesn't expose that now. The workarounds areretainplus key/value clones, ormem::takeand a full rebuild of the map. Both cost more on hot paths that split an event's fields, such as moving non-reserved fields into a nested object.The predicate signature
FnMut(&KeyString, &mut Value) -> boolmatchesretainand std. As with std, entries the iterator does not reach stay in the map.How did you test this PR?
Unit tests in
object_map.rs: entries extracted in key order, early drop keeps unvisited entries, predicate can mutate kept values.Does this PR include user-facing changes?
our guidelines.
Checklist
run
dd-rust-license-tool writeand commit the changes. More details here.References