Skip to content

Conversation

@HugoGarrido
Copy link
Collaborator

Motivation

LCP Subparts are values that compute the final LCP measure the browser SDK.

This is helpful for troubleshooting LCP since it help to define what type of LCP issue we are facing (server, render etc.) by looking at the biggest contributor (more details in this doc)

Here is a breakdown of each part :

Subpart Meaning
TTFB Already tracked by the Browser SDK as firstByte
Resource load delay Time between firstByte and the loading start of the resource associated with the LCP. 0 if no resource are attached to the LCP
Resource load duration Time to takes to load the resource attached to the LCP0 if no resource are attached to the LCP
Element render delay Time between the LCP resource finishes loading and the LCP element is fully rendered

This PR adds the collection of the LCP subparts when we collect the LCP

Changes

  • In trackLargestContentfulPaint when we have an LCP entry :
    • re-measure the TTFB (keeping the name firstByte)
    • get the performance entry related to the LCP resource if applicable
    • compute an optional subParts object that is added in the final payload
  • Extract a helper to safely compute the firstByte value
  • Extract a helper to safely read performance global
  • Update tests, fixtures and types to support the new subParts object

Test instructions

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.

@github-actions
Copy link

github-actions bot commented Jan 19, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@cit-pr-commenter-54b7da
Copy link

cit-pr-commenter-54b7da bot commented Jan 20, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 164.36 KiB 164.97 KiB +621 B +0.37%
Rum Profiler 4.33 KiB 4.33 KiB 0 B 0.00%
Rum Recorder 24.27 KiB 24.27 KiB 0 B 0.00%
Logs 56.14 KiB 56.14 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 121.57 KiB 122.14 KiB +592 B +0.48%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0042 0.0041 -2.38%
RUM - add action 0.0135 0.0132 -2.22%
RUM - add error 0.0131 0.0126 -3.82%
RUM - add timing 0.0029 0.0028 -3.45%
RUM - start view 0.0043 0.0033 -23.26%
RUM - start/stop session replay recording 0.0008 0.0007 -12.50%
Logs - log message 0.0147 0.0143 -2.72%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 26.27 KiB 25.69 KiB -591 B
RUM - add action 48.61 KiB 48.66 KiB +48 B
RUM - add timing 24.97 KiB 26.06 KiB +1.09 KiB
RUM - add error 54.76 KiB 55.11 KiB +361 B
RUM - start/stop session replay recording 23.95 KiB 25.19 KiB +1.25 KiB
RUM - start view 424.85 KiB 426.04 KiB +1.19 KiB
Logs - log message 95.72 KiB 44.24 KiB -51.48 KiB

🔗 RealWorld

@datadog-official
Copy link

datadog-official bot commented Jan 20, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage
Patch Coverage: 69.23%
Overall Coverage: 77.29% (+0.03%)

View detailed report

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e0dd7ee | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@HugoGarrido
Copy link
Collaborator Author

I have read the CLA Document and I hereby sign the CLA

@HugoGarrido HugoGarrido marked this pull request as ready for review January 22, 2026 10:13
@HugoGarrido HugoGarrido requested a review from a team as a code owner January 22, 2026 10:13
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

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: 94434b0253

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

Comment on lines +76 to +78
const lcpResourceEntry = resourceUrl
? (getResourceEntries()?.find((e) => e.name === resourceUrl) as PerformanceResourceTiming | undefined)
: undefined

Choose a reason for hiding this comment

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

P2 Badge Match the LCP resource to the correct request

The LCP resource timing is selected via getResourceEntries()?.find((e) => e.name === resourceUrl), which returns the first entry with that URL. Resource entries persist for the whole page and can include multiple requests for the same URL (e.g., preloads, cache-busting reloads, or SPA route changes). In those cases the first entry is often unrelated to the LCP element, so loadDelay/loadTime/renderDelay are computed from stale timings, corrupting the subparts metrics. Consider picking the most recent matching entry whose timing precedes lcpEntry.startTime instead of the first match.

Useful? React with 👍 / 👎.

Comment on lines 80 to 81
const firstByte = getSafeFirstByte(getNavigationEntry()) || (0 as RelativeTime)
const lcpRequestStart = Math.max(firstByte, lcpResourceEntry?.startTime || 0)

Choose a reason for hiding this comment

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

P2 Badge Avoid reporting subparts when firstByte is invalid

When getSafeFirstByte() returns undefined for negative or future responseStart values (the exact cases it is meant to guard against), the code falls back to 0 and still emits subparts. This will silently report a 0ms TTFB and inflate renderDelay for affected browsers, which is misleading data rather than a safe omission. Consider skipping subParts or leaving firstByte undefined when getSafeFirstByte() fails.

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.

2 participants