Skip to content

✨ implement remote configuration async loading & caching#4606

Merged
gogusarov merged 5 commits into
mainfrom
grigory.gusarov/RUM-15992
May 19, 2026
Merged

✨ implement remote configuration async loading & caching#4606
gogusarov merged 5 commits into
mainfrom
grigory.gusarov/RUM-15992

Conversation

@gogusarov
Copy link
Copy Markdown
Contributor

@gogusarov gogusarov commented May 11, 2026

Motivation

Support remote configuration asynchronous loading & caching mechanism according to the RFC

Changes

Added async remote configuration fetching flow where config isn't awaited during DD_RUM.init but read synchronously from a versioned localStorage cache (dd_rc_<remoteConfigurationId>) and applied on the same page load. A background fetch runs in parallel and refreshes the cache for the next page load, so updates roll out one load late but startup is unblocked. Cache outcomes (hit/miss/error) and fetch outcomes (success/failure) are reported via the existing telemetry metrics. Unit tests cover the new cache module and the read/apply/fetch flow; the e2e scenarios were rewritten to wait for the cache to be populated and reload the page before asserting.

Blocking fetch flow was kept for backward compatibility with existing customer setup

New init configuration API

  • remoteConfiguration: { id: string; sync?: boolean } — new top-level field.
    Default behavior is async (cache-and-reload). Pass sync: true to opt into the
    legacy blocking fetch through the new API.
  • remoteConfigurationId: string — legacy field preserved for backward
    compatibility with existing customer setups. Always triggers the blocking fetch
    flow.

Test instructions

  1. add remote-config.json file to sandbox directory
  2. update parameters, passed to DD_RUM.init adding remoteConfiguration: { id: 'remote-config-test' }, remoteConfigurationProxy: '/remote-config.json'
  3. check that remote config from file is requested and written to localStorage on the first page load (localStorage.getItem('dd_rc_remote-config-test')
  4. check that DD_RUM.getInitConfiguration() returns initial configuration on the first page load
  5. check that DD_RUM.getInitConfiguration() returns remote configuration on the second page load

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@datadog-prod-us1-6
Copy link
Copy Markdown

datadog-prod-us1-6 Bot commented May 11, 2026

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 79.63%
Overall Coverage: 76.97% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 084cd20 | Docs | Datadog PR Page | Give us feedback!

Comment thread packages/rum-core/src/domain/configuration/remoteConfiguration.ts
@cit-pr-commenter-54b7da
Copy link
Copy Markdown

cit-pr-commenter-54b7da Bot commented May 12, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 169.51 KiB 170.72 KiB +1.20 KiB +0.71%
Rum Profiler 5.97 KiB 5.97 KiB -1 B -0.02%
Rum Recorder 21.23 KiB 21.23 KiB -1 B -0.00%
Logs 54.70 KiB 54.70 KiB 0 B 0.00%
Rum Slim 127.85 KiB 129.03 KiB +1.19 KiB +0.93%
Worker 22.99 KiB 22.99 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0019 0.003 +57.89%
RUM - add action 0.0104 0.0156 +50.00%
RUM - add error 0.0126 0.0143 +13.49%
RUM - add timing 0.0007 0.0006 -14.29%
RUM - start view 0.0109 0.0149 +36.70%
RUM - start/stop session replay recording 0.0008 0.0013 +62.50%
Logs - log message 0.0176 0.0253 +43.75%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 42.69 KiB 42.32 KiB -378 B
RUM - add action 67.95 KiB 62.92 KiB -5.03 KiB
RUM - add timing 37.49 KiB 36.50 KiB -1016 B
RUM - add error 73.15 KiB 72.47 KiB -702 B
RUM - start/stop session replay recording 41.06 KiB 41.94 KiB +903 B
RUM - start view 492.59 KiB 484.05 KiB -8.54 KiB
Logs - log message 55.59 KiB 56.01 KiB +427 B

🔗 RealWorld

@gogusarov gogusarov force-pushed the grigory.gusarov/RUM-15992 branch from 8a5af9b to 5bef505 Compare May 12, 2026 17:04
Comment thread test/e2e/scenario/rum/remoteConfiguration.scenario.ts Outdated
@gogusarov gogusarov marked this pull request as ready for review May 13, 2026 12:22
@gogusarov gogusarov requested a review from a team as a code owner May 13, 2026 12:22
Comment thread test/e2e/scenario/rum/remoteConfiguration.scenario.ts Outdated
@thomas-lebeau
Copy link
Copy Markdown
Collaborator

can you edit the PR title to follow our convention please!

@gogusarov gogusarov changed the title feat: implement remote configuration caching mechanism ✨ implement remote configuration caching mechanism May 14, 2026
@gogusarov gogusarov force-pushed the grigory.gusarov/RUM-15992 branch from 2a0d867 to 3c37331 Compare May 14, 2026 17:41
@gogusarov gogusarov force-pushed the grigory.gusarov/RUM-15992 branch from 3c37331 to df72f91 Compare May 14, 2026 17:48
@gogusarov gogusarov changed the title ✨ implement remote configuration caching mechanism ✨ implement remote configuration async loading & caching May 14, 2026
})),
track_feature_flags_for_events: configuration.trackFeatureFlagsForEvents,
remote_configuration_id: configuration.remoteConfigurationId,
remote_configuration_id: configuration.remoteConfigurationId ?? configuration.remoteConfiguration?.id,
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.

remote_configuration_id resolves the ID in the opposite order from getRemoteConfigurationId. I'd use the helper here too:

remote_configuration_id: getRemoteConfigurationId(configuration),

Nobody would pass both options, but this way there's a single source of truth for the resolution. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

agree, will fix

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@DataDog fix this

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I can only run on private repositories.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

bruh

@gogusarov gogusarov merged commit c1b5954 into main May 19, 2026
23 checks passed
@gogusarov gogusarov deleted the grigory.gusarov/RUM-15992 branch May 19, 2026 12:39
@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants