Skip to content

rts: add to activity log - #4093

Open
marksvc wants to merge 2 commits into
masterfrom
task/rts-logging-browser
Open

marksvc wants to merge 2 commits into
masterfrom
task/rts-logging-browser

Conversation

@marksvc

@marksvc marksvc commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator
  • Adds more middleware hooks.
  • Remove use of AgentInternal from realtime-server.ts. Add
    declarations to Agent as needed. This had fallout such as accounting
    for agent possibly being null by type when checking things like
    context.agent?.clientId.
  • Changed some error messaging from saying the op, to just the op
    path. This information flows into the activity logs.
  • Some Byte size measuring is now being done in realtime usage of the
    server, not just upon intermittent SIGUSR2 request.
  • Clarified typing for agent.connectSession resulted in some null
    guards + throw being added.
  • ResourceMonitor now cares if it's "enabled", because if so it will
    build up some information over time to flush out on request.
  • ResourceMonitor logs some additional information to a new file,
    resource-usage.jsonl, alongside existing .csv files.
  • The change to resource-monitor.ts subscribedDocsCount is a fix from
    incorrect behaviour.
  • An AGENTS.md file was placed alongside our sharedb typings to give
    specific instructions to AI on how to treat these.
  • sharedb typings received various enhancements. Including declaring
    our custom property, connectSession.

Open in Devin Review


This change is Reviewable

- Adds more middleware hooks.
- Remove use of AgentInternal from realtime-server.ts. Add
declarations to Agent as needed. This had fallout such as accounting
for `agent` possibly being null by type when checking things like
`context.agent?.clientId`.
- Changed some error messaging from saying the op, to just the op
path. This information flows into the activity logs.
- Some Byte size measuring is now being done in realtime usage of the
server, not just upon intermittent SIGUSR2 request.
- Clarified typing for agent.connectSession resulted in some null
guards + throw being added.
- ResourceMonitor now cares if it's "enabled", because if so it will
build up some information over time to flush out on request.
- ResourceMonitor logs some additional information to a new file,
`resource-usage.jsonl`, alongside existing .csv files.
- The change to resource-monitor.ts subscribedDocsCount is a fix from
incorrect behaviour.
- An AGENTS.md file was placed alongside our sharedb typings to give
specific instructions to AI on how to treat these.
- sharedb typings received various enhancements. Including declaring
our custom property, `connectSession`.
@marksvc
marksvc marked this pull request as draft September 9, 2026 22:09
@marksvc marksvc added the do not merge See PR description and/or comments for explanation label Sep 9, 2026
@marksvc

marksvc commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

Labeling as "do not merge" so I can be involved in the timing, and able to watch when the code starts to be used on the staging server. But I do want the PR to be reviewed :).

@marksvc marksvc added testing not required e2e Run e2e tests for this pull request labels Sep 9, 2026
@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.23497% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.97%. Comparing base (36cc0e2) to head (3e9d149).
⚠️ Report is 9 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/RealtimeServer/common/resource-monitor.ts 63.51% 23 Missing and 4 partials ⚠️
src/RealtimeServer/common/realtime-server.ts 89.41% 9 Missing ⚠️
...timeServer/common/services/project-data-service.ts 66.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4093      +/-   ##
==========================================
+ Coverage   80.94%   80.97%   +0.02%     
==========================================
  Files         664      664              
  Lines       42152    42308     +156     
  Branches     6916     6993      +77     
==========================================
+ Hits        34120    34258     +138     
  Misses       6882     6882              
- Partials     1150     1168      +18     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@marksvc

marksvc commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

src/RealtimeServer/common/activity-logger.ts line 42 at r1 (raw file):

 * reports produced by ResourceMonitor. Logging is controlled by the SF_RTS_LOG_LEVEL environment variable.
 */
export class ActivityLogger {

Note: AI code review identifies various cracks in the design of the logging and resource usage reporting system. I've sought to make it work well, and defend against various situations, but it's less important that the reporting system work flawlessly and more important that we get more reporting.

@marksvc

marksvc commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

I marked this PR as testing not required. The testing I want to see (beyond what I've done) is the E2E test pass, and usage on QA by the test team.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

📸 Screenshot diff deployed! (1 change)

View the visual diff at: https://pr-4093--sf-screenshot-diffs.netlify.app

@marksvc
marksvc marked this pull request as ready for review September 9, 2026 22:49
@marksvc

marksvc commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

The motivation for this PR is to add lots more information to the RealtimeServer activity log, to aid in understanding what is happening when we see the resource usage increasing.

@pmachapman
pmachapman self-requested a review September 14, 2026 23:01
@pmachapman pmachapman self-assigned this Sep 14, 2026

@pmachapman pmachapman left a comment

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.

:lgtm:

@pmachapman reviewed 15 files and all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on marksvc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not merge See PR description and/or comments for explanation e2e Run e2e tests for this pull request testing not required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants