Skip to content

feat: implement remote configuration caching mechanism#4606

Open
gogusarov wants to merge 2 commits into
mainfrom
grigory.gusarov/RUM-15992
Open

feat: implement remote configuration caching mechanism#4606
gogusarov wants to merge 2 commits into
mainfrom
grigory.gusarov/RUM-15992

Conversation

@gogusarov
Copy link
Copy Markdown
Contributor

@gogusarov gogusarov commented May 11, 2026

Motivation

Support remote configuration caching mechanism according to the RFC

Changes

The remote configuration is no longer awaited during DD_RUM.init it is now read synchronously from a versioned localStorage cache (dd_rc_<remoteConfigurationId>) and applied on the same page load. A background fetch always 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.

Test instructions

  1. add remote-config.json file to sandbox directory
  2. update parameters, passed to DD_RUM.init adding remoteConfigurationId: '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

Fix all issues with BitsAI or with Cursor

⚠️ Warnings

🧪 1 Test failed

cookieAccess CookieStore API observable should notify when cookie is deleted externally from Chrome 145.0.0.0 (Android 10)   View in Datadog   (Fix with Cursor)
Error: Timeout - Async function did not complete within 5000ms (set by jasmine.DEFAULT_TIMEOUT_INTERVAL)
    at <Jasmine>

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 84.09%
Overall Coverage: 76.98% (+0.03%)

Useful? React with 👍 / 👎

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


const cacheResult = configurationCache.read()

metrics.increment('cache', CACHE_STATUS_TO_METRIC_MAP[cacheResult.status])
Copy link
Copy Markdown
Contributor Author

@gogusarov gogusarov May 11, 2026

Choose a reason for hiding this comment

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

@mormubis would it be ok to leave metrics keys the way they currently are (success / missing / failure) or should they be exactly the same as in your RFC (hit/miss/error)

@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.35 KiB +857 B +0.49%
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 128.67 KiB +841 B +0.64%
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.0031 0.0031 0.00%
RUM - add action 0.0164 0.0143 -12.80%
RUM - add error 0.0137 0.0138 +0.73%
RUM - add timing 0.0007 0.0007 0.00%
RUM - start view 0.0151 0.0121 -19.87%
RUM - start/stop session replay recording 0.0013 0.0009 -30.77%
Logs - log message 0.0234 0.021 -10.26%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 38.75 KiB 37.96 KiB -811 B
RUM - add action 64.74 KiB 69.80 KiB +5.07 KiB
RUM - add timing 36.82 KiB 37.28 KiB +464 B
RUM - add error 70.81 KiB 79.83 KiB +9.02 KiB
RUM - start/stop session replay recording 41.37 KiB 50.83 KiB +9.46 KiB
RUM - start view 486.34 KiB 477.06 KiB -9.28 KiB
Logs - log message 55.35 KiB 65.82 KiB +10.48 KiB

🔗 RealWorld

@gogusarov gogusarov force-pushed the grigory.gusarov/RUM-15992 branch from 8a5af9b to 5bef505 Compare May 12, 2026 17:04
},
})
.withBody(html`<span id="version">123</span>`)
.withHead(html`<span id="version">123</span>`)
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.

I updated these tests using withHead so that they pass, but there’s an issue here that we should definitely address later

Remote Configuration currently supports dynamic options, one of which is dom. If we use synchronous bundle setup and Remote Configuration is loaded from the cache immediately, this strategy will always fail because SDK initialization happens before the DOM is available

Copy link
Copy Markdown
Collaborator

@thomas-lebeau thomas-lebeau May 13, 2026

Choose a reason for hiding this comment

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

That's a good point, but it might break existing customer setup if we don't address this now, no?

We can change the test, but we can't change our customer setup

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.

It seems like it's not something we should solve immediately because currently remote config is only available for SSI clients and from what I know they have hardcoded v6 version and they can't update on their own until we update the injector

@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 on lines +207 to +208
/* The background fetch on the initial page load writes the remote configuration into localStorage;
* reloading lets the SDK pick it up synchronously on the next init().
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

💬 suggestion: I think with your change, all the test are now relying on the config being cached and we don't test that the remote config works properly even without cache.

I would rather keep waitForRemoteConfigurationToBeApplied as before and add a separate test specifically for the caching mechanism.

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