Skip to content

feat: Improve agent startup#1760

Merged
ptang-nr merged 33 commits into
mainfrom
NR-509779-improve-startup
Jun 23, 2026
Merged

feat: Improve agent startup#1760
ptang-nr merged 33 commits into
mainfrom
NR-509779-improve-startup

Conversation

@ptang-nr

@ptang-nr ptang-nr commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

Provide better support for scenarios where agent startup can be interrupted before RUM call completes successfully and feature session modes are saved into local storage (where applicable).

Overview

In this PR,

  • the agent startup avoids defaulting and locking a new session into OFF mode for Session Trace, Session Replay, and/or Browser Logging when the first RUM call in a session is incomplete (for example, due to redirects or early navigations).
  • additionally when the RUM call completes, the agent will now cache the RUM response in the session/local storage such that the same feature modes can be reused for the duration of the session.
    • RUM call sends with fsh = 1, when it is the first RUM call in the session and there are no cached RUM response
    • RUM call sends with fsh = 0, when a cached RUM response is detected
  • if a cached RUM response is present for a given session, the agent will use the cached response to continue startup

Related Issue(s)

https://new-relic.atlassian.net/browse/NR-509779

Testing

Extended integration tests in affected parts of the agent.
Manually tested scenario to ensure RUM response is cached in the session.

Some tests were failing when retries is set to 0. Fixed up and removed the retries as they don't seem needed for unit/integration tests (?)
- If entitlement is unconfirmed, avoid locking session into OFF mode
- Use null instead of OFF as the default value (need null to write into LS)
@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown

Supportability Metric Usage Changes:

No matching changes found

Supportability Metrics .md File Changes:

supportability_metrics.md was changed? false

New supportability metrics require changes to supportability_metrics.md, as well as a new PR to Angler. Please ensure an Angler PR is created and linked to this PR.

Comment thread src/common/harvest/harvester.js
@github-actions

github-actions Bot commented Apr 21, 2026

Copy link
Copy Markdown

Asset Size Report

Merging this pull request will result in the following asset size changes:

Agent Asset Previous Size New Size Diff
lite loader 26.79 kB / 10.24 kB (gzip) 26.86 kB / 10.26 kB (gzip) 0.23% / 0.16% (gzip)
lite async-chunk 58.92 kB / 19.76 kB (gzip) 59.62 kB / 20.05 kB (gzip) 1.18% / 1.49% (gzip)
pro loader 66.61 kB / 23.46 kB (gzip) 66.89 kB / 23.53 kB (gzip) 0.41% / 0.27% (gzip)
pro async-chunk 96.39 kB / 30.65 kB (gzip) 97.17 kB / 30.83 kB (gzip) 0.81% / 0.57% (gzip)
spa loader 69.01 kB / 24.24 kB (gzip) 69.28 kB / 24.3 kB (gzip) 0.4% / 0.25% (gzip)
spa async-chunk 108.54 kB / 33.76 kB (gzip) 109.32 kB / 34.02 kB (gzip) 0.72% / 0.76% (gzip)

@codecov

codecov Bot commented Apr 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.74359% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.07%. Comparing base (f7df627) to head (6076551).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/common/harvest/send.js 88.37% 8 Missing and 2 partials ⚠️
src/features/session_replay/aggregate/index.js 85.00% 3 Missing ⚠️
src/features/session_trace/aggregate/index.js 85.71% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1760      +/-   ##
==========================================
+ Coverage   89.54%   90.07%   +0.53%     
==========================================
  Files         213      214       +1     
  Lines        7864     7852      -12     
  Branches     1657     1669      +12     
==========================================
+ Hits         7042     7073      +31     
+ Misses        743      709      -34     
+ Partials       79       70       -9     
Flag Coverage Δ
unit-tests 86.03% <89.74%> (+1.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

Comment thread tests/unit/common/util/script-tracker.test.js
Comment thread tests/specs/logging/harvesting.e2e.js

@metal-messiah metal-messiah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just some general WIP comments, looking good!

Comment thread src/common/session/session-entity.js
Comment thread src/features/session_replay/aggregate/index.js Outdated
Comment thread src/features/session_trace/aggregate/index.js Outdated
@github-actions

github-actions Bot commented Apr 22, 2026

Copy link
Copy Markdown

Static Badge

Last ran on June 16, 2026 13:01:32 CDT
Checking merge of (a58738a) into main (3fd403e)

@ptang-nr ptang-nr marked this pull request as ready for review April 24, 2026 16:08
@ptang-nr ptang-nr changed the title (WIP) feat: Improve agent startup feat: Improve agent startup Apr 29, 2026
@metal-messiah metal-messiah self-assigned this Apr 29, 2026
Comment thread src/features/page_view_event/aggregate/index.js Outdated
metal-messiah
metal-messiah previously approved these changes Apr 30, 2026

@metal-messiah metal-messiah left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good and makes sense. I assume app metadata is unneeded for the cache, but just want to double check that above ⬆️ before merging.

@cwli24 cwli24 self-assigned this Apr 30, 2026
Comment thread src/features/logging/aggregate/index.js Outdated
Comment thread src/features/logging/aggregate/index.js Outdated
ptang-nr added 2 commits May 6, 2026 15:16
- Don't wait for new RUM call if a cached response is present.
- Added `app` to the cached response
- Added a rough implementation of namespaced LS to flush out any tests that would break.
@ptang-nr ptang-nr marked this pull request as draft May 14, 2026 18:19
@ptang-nr ptang-nr marked this pull request as ready for review June 5, 2026 20:17
@ptang-nr ptang-nr force-pushed the NR-509779-improve-startup branch from ee1182c to d774a7f Compare June 8, 2026 18:12
@ptang-nr ptang-nr added Blocked and removed Blocked labels Jun 17, 2026
@ptang-nr ptang-nr merged commit d75f4bf into main Jun 23, 2026
20 checks passed
@ptang-nr ptang-nr deleted the NR-509779-improve-startup branch June 23, 2026 18:34
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.

3 participants