Skip to content

Conversation

@watson
Copy link
Collaborator

@watson watson commented Dec 16, 2025

What does this PR do?

  • Removes the leaky kPreUpdate hook from RemoteConfigManager and replaces it with a first-class batch handler API (setBatchHandler/removeBatchHandler) that receives an explicit transaction (ack/error/markHandled).
  • Introduces explicit RC product subscription via subscribeProducts(...products) / unsubscribeProducts(...products) and makes setProductHandler / removeProductHandler subscribe/unsubscribe for clarity.
  • Wires AppSec/WAF RC updates to the new batch transaction API and centralizes ASM/WAF RC product names in appsec/rc-products.js.

Motivation

kPreUpdate exposed internal mutable state and blurred responsibility between RC internals and consumers. WAF needs to reconcile multiple products in one logical update, so the new batch API provides a safer and clearer surface.

@watson watson self-assigned this Dec 16, 2025
Copy link
Collaborator Author

watson commented Dec 16, 2025

@pr-commenter
Copy link

pr-commenter bot commented Dec 16, 2025

Benchmarks

Benchmark execution time: 2025-12-19 19:13:12

Comparing candidate commit c18a9fe in PR branch watson/refactor-rc with baseline commit 244b082 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 290 metrics, 30 unstable metrics.

@watson watson force-pushed the watson/refactor-rc branch 3 times, most recently from b704693 to eec9001 Compare December 16, 2025 20:46
@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 94.62366% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.81%. Comparing base (244b082) to head (c18a9fe).

Files with missing lines Patch % Lines
packages/dd-trace/src/remote_config/manager.js 92.06% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7121      +/-   ##
==========================================
+ Coverage   84.78%   84.81%   +0.02%     
==========================================
  Files         521      522       +1     
  Lines       22155    22207      +52     
==========================================
+ Hits        18785    18834      +49     
- Misses       3370     3373       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Dec 16, 2025

Overall package size

Self size: 4.36 MB
Deduped: 5.19 MB
No deduping: 5.19 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.0 | 68.46 kB | 797.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@watson watson changed the title refactor(remote-config): replace kPreUpdate with batch handler API refactor(remote-config): replace kPreUpdate with batch handler API (DEBUG-4402) Dec 16, 2025
@watson watson marked this pull request as ready for review December 16, 2025 20:47
@watson watson requested review from a team as code owners December 16, 2025 20:47
@watson watson requested review from khanayan123 and simon-id and removed request for a team December 16, 2025 20:47
@watson watson force-pushed the watson/refactor-rc branch from eec9001 to 3efdc4c Compare December 18, 2025 08:36
@watson watson requested a review from BridgeAR December 18, 2025 18:36
@watson watson force-pushed the watson/refactor-rc branch from 3efdc4c to b49c683 Compare December 19, 2025 17:38
@datadog-datadog-prod-us1

This comment has been minimized.

- Remove the leaky kPreUpdate hook and introduce a first-class batch API:
  setBatchHandler()/removeBatchHandler()
- Introduce explicit product subscription via subscribeProducts()/
  unsubscribeProducts(), and have setProductHandler()/
  removeProductHandler() subscribe/unsubscribe for clarity
- Centralize ASM/WAF RC product names in appsec/rc-products.js
- Update AppSec WAF RC integration to use batched tx
  (ack/error/markHandled) instead of mutating configs
- Improve JSDoc/TS inference for batch transaction/descriptors and
  WAF manager typing
@watson watson force-pushed the watson/refactor-rc branch from b49c683 to c18a9fe Compare December 19, 2025 19:02
Copy link
Collaborator

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

It seems like a good improvement to separate things by product. Just left a few minor suggestions

let appliedActions = new Map()

/**
* @param {{ rules?: string, [key: string]: any }} config
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I see the improvement, while I would like to prohibit adding any any to the code base


item.apply_state = ACKNOWLEDGED
tx.ack(item.path)
tx.markHandled(item.path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we could just implicitly mark it as handled when there is an ack or an error. That way the code is simpler.

version: conf.version,
file: conf.file
}
return Object.freeze(desc)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to freeze the objects?


if (toUnapply.length || toApply.length || toModify.length) {
this.emit(RemoteConfigManager.kPreUpdate, { toUnapply, toApply, toModify })
const tx = createUpdateTransaction({ toUnapply, toApply, toModify }, txHandledPaths, txOutcomes)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would strongly favor writing transaction instead of tx.


this._handlers = new Map()
this._products = new Set()
this._batchHandlers = new Map()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use private properties instead

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants