Skip to content

🔊 Report remote configuration sync metadata on configuration telemetry - #5001

Open
mormubis wants to merge 4 commits into
mainfrom
adlrb/remote-config-telemetry
Open

🔊 Report remote configuration sync metadata on configuration telemetry#5001
mormubis wants to merge 4 commits into
mainfrom
adlrb/remote-config-telemetry

Conversation

@mormubis

Copy link
Copy Markdown
Contributor

Motivation

The remote configuration telemetry RFC wants to measure how long a published config takes to take effect on a device. Two segments: last_synced - last_modified for CDN to fetch, and first_applied - last_synced for fetch to apply. We have no visibility on either today.

The schema already merged in the events format repo and is synced here. This is the browser side.

Changes

The metadata goes in the existing dd_rc_<id> localStorage entry instead of a separate key, so a version and its metadata can't drift apart on a partial write. CACHE_VERSION is bumped to 3 and fetchedAt becomes a metadata object with lastModified, lastSynced, firstApplied and syncId.

sync_id doesn't follow the RFC. The RFC regenerates it on non-304 fetches, but we send no If-None-Match and never see a 304. Instead write() compares the fetched payload with the cached one and skips the write when they match. It keys on the config changing instead of the transport, and it's also what keeps firstApplied from being wiped by a background refetch.

The metadata is threaded through doInit into serializeRumConfiguration instead of module state. RUM and Logs read the same cache entry once #4884 lands, so a singleton would report the wrong product's numbers.

config_id is not included, we already send remote_configuration_id. version_id is not included either, x-amz-version-id is not readable from JS.

Nothing is reported on the sync path (sync: true or the legacy remoteConfigurationId). Fetch and apply happen in the same tick there, so first_applied - last_synced would always be ~0. I can add it if you prefer having the CDN to fetch half for those setups. What do you think?

Test instructions

Needs a real published remote configuration ID.

  1. yarn dev-server start
  2. Add a sandbox page with remoteConfiguration: { id: '<rc-id>' }, proxy: '/proxy', telemetrySampleRate: 100 and telemetryConfigurationSampleRate: 100
  3. Load it once. localStorage.getItem('dd_rc_<rc-id>') has version: 3 and a metadata with lastModified, lastSynced and syncId, no firstApplied yet
  4. Load it again. firstApplied is set, lastSynced and syncId unchanged
  5. agent-browser tab new to flush, then yarn dev-server intake telemetry-configuration-events | jq '.telemetry.configuration.remote_configuration'

First load reports nothing, second reports the four fields:

{"last_modified":1777557229000,"last_synced":1787930428705,
 "first_applied":1787930438546,"sync_id":"476d2ee9-fb31-4c30-824a-5410d4850ad0"}

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change. The existing e2e seeds the cache and checks config application, not telemetry. The two page load flow plus sampling makes it awkward, I'd rather do it separately.
  • Updated documentation and/or relevant AGENTS.md file

// version. Skipping the write here is also what keeps `firstApplied` alive across refetches.
// TODO: compare on `ETag` instead once the CDN exposes it through
// `Access-Control-Expose-Headers`. The stringify compare is key-order sensitive, which holds
// only because both sides come from `JSON.parse` of the same CDN payload.

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.

This early return is the whole sync_id semantic, and it's also what keeps firstApplied from being wiped when the background fetch pulls the same config back. Worth knowing before touching the comparison.

* readable cross-origin without the CDN having to expose it explicitly. It carries an HTTP-date,
* so the value is only accurate to the second.
*/
function parseLastModified(response: Response): number | undefined {

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.

last-modified is the only useful header we can read here. etag and x-amz-version-id are not CORS-safelisted and the CDN doesn't send Access-Control-Expose-Headers, so they come back null in the browser even though curl sees them. That's why there's no version_id in this PR.

if (cacheResult.status === 'hit') {
return applyRemoteConfiguration(initConfiguration, cacheResult.config, supportedContextManagers, metrics)
return {
// Stamping is synchronous, so it always lands before the background sync above can write.

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.

doBackgroundCacheSync starts the fetch before this line, so it looks racy. It isn't, the stamp is synchronous and the fetch can't resolve before the next microtask. I left the order alone to keep the diff small, but I can move the sync call below if it reads better.

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 31, 2026

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 182.02 KiB 182.86 KiB +852 B +0.46%
Rum Profiler 8.43 KiB 8.43 KiB 0 B 0.00%
Rum Recorder 25.32 KiB 25.32 KiB 0 B 0.00%
Logs 57.96 KiB 57.96 KiB 0 B 0.00%
Rum Salesforce N/A 140.90 KiB N/A N/A N/A
Rum Slim 140.08 KiB 140.90 KiB +838 B +0.58%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%
Rum Shopify N/A 207.65 KiB N/A N/A N/A
Rum-shopify Profiler N/A 8.43 KiB N/A N/A N/A
Rum-shopify Recorder N/A 3.74 KiB N/A N/A N/A

@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 31, 2026

Copy link
Copy Markdown

Tests

All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 74.07%
Overall Coverage: 76.99% (-0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9febebe | Docs | View more details | Give us feedback!

@mormubis
mormubis force-pushed the adlrb/remote-config-telemetry branch 2 times, most recently from 9c2e781 to 5514ed4 Compare September 2, 2026 10:10
@mormubis
mormubis force-pushed the adlrb/remote-config-telemetry branch from 5514ed4 to 9febebe Compare September 4, 2026 14:42
@mormubis
mormubis marked this pull request as ready for review September 7, 2026 15:11
@mormubis
mormubis requested a review from a team as a code owner September 7, 2026 15:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 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-09-07T15:18:36.261133Z 9febebe 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.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9febebe9c3

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

import type { RemoteConfiguration } from './remoteConfiguration'

export const CACHE_VERSION = 2
export const CACHE_VERSION = 3

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve version-2 cache entries during upgrade

issue: Existing installations have version-2 entries containing a usable configuration, but this version bump makes read() classify every one as an error and delete it. On the first page load after upgrading, clients using required: true will not start RUM at all, while other clients temporarily run without their cached remote overrides until another navigation; accept and migrate the previous shape (or at least apply its config without telemetry metadata) to avoid this rollout-wide gap.

Useful? React with 👍 / 👎.

Comment on lines +127 to +129
if (cached.status === 'hit' && JSON.stringify(cached.config) === JSON.stringify(config)) {
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Refresh sync metadata when Last-Modified changes

issue: When the CDN republishes the same JSON payload with a new Last-Modified value, this early return discards that new publish timestamp and retains the previous lastModified, lastSynced, firstApplied, and syncId. Those sessions are consequently attributed to the old publication and the new propagation latency is never measured, even though the newly collected lastModified value provides a way to distinguish this fetch from the cached publication.

Useful? React with 👍 / 👎.

return applyRemoteConfiguration(initConfiguration, cacheResult.config, supportedContextManagers, metrics)
return {
// Stamping is synchronous, so it always lands before the background sync above can write.
metadata: configurationCache.stampFirstApplied(cacheResult),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Stamp firstApplied only after initialization succeeds

issue: This persists firstApplied before the cached configuration is resolved and validated by doInit. For example, if a dynamic applicationId is unavailable on the first load, validation rejects the configuration and no RUM session starts, but the cache is still marked as applied; if that value becomes available on a later load, telemetry reports the failed load's timestamp rather than when the configuration actually took effect.

Useful? React with 👍 / 👎.

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.

1 participant