Skip to content

♻️ Simplify debugger template evaluation#4730

Merged
watson merged 2 commits into
mainfrom
watson/DEBUG-5733/refactor-template-cache
Jun 5, 2026
Merged

♻️ Simplify debugger template evaluation#4730
watson merged 2 commits into
mainfrom
watson/DEBUG-5733/refactor-template-cache

Conversation

@watson
Copy link
Copy Markdown
Collaborator

@watson watson commented Jun 5, 2026

Motivation

Simplify debugger template evaluation and remove unnecessary cache cleanup paths. The previous implementation stored compiled template cache objects on probes and explicitly cleared those caches when probes were removed, but the caches were already only reachable through the probe instance and could be garbage-collected with it. Moving evaluation behind an initialized-probe function keeps this behavior local to probe initialization and makes the runtime code easier to maintain.

Changes

  • Remove explicit cache clearing for probe conditions and dynamic templates when probes are removed or cleared.
  • Replace the compiled template object stored in probe.template with an evaluateTemplate(context) function on initialized probes.
  • Keep probe.template as the original template string after initialization.
  • Update template/probe tests to cover the new evaluation shape instead of cache object internals.

Test instructions

  • yarn test:unit --spec packages/browser-debugger/src/domain/template.spec.ts --spec packages/browser-debugger/src/domain/probes.spec.ts
  • yarn typecheck

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

Stop clearing compiled template and condition caches when probes are removed or
cleared. Removed probes can be garbage-collected with their caches, so the
explicit cache-clearing API is unnecessary.
@watson watson requested review from a team as code owners June 5, 2026 09:42
Copy link
Copy Markdown
Collaborator Author

watson commented Jun 5, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@cit-pr-commenter-54b7da
Copy link
Copy Markdown

cit-pr-commenter-54b7da Bot commented Jun 5, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 171.79 KiB 171.79 KiB 0 B 0.00%
Rum Profiler 7.88 KiB 7.88 KiB 0 B 0.00%
Rum Recorder 21.21 KiB 21.21 KiB 0 B 0.00%
Logs 54.31 KiB 54.31 KiB 0 B 0.00%
Rum Slim 129.70 KiB 129.70 KiB 0 B 0.00%
Worker 22.96 KiB 22.96 KiB 0 B 0.00%

@datadog-prod-us1-3
Copy link
Copy Markdown

datadog-prod-us1-3 Bot commented Jun 5, 2026

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 76.47%
Overall Coverage: 76.71% (+0.00%)

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

@watson watson force-pushed the watson/DEBUG-5733/refactor-template-cache branch from 0edbca8 to 90a1c84 Compare June 5, 2026 10:03
Hide dynamic template function creation behind an `evaluateTemplate` probe method
so message rendering no longer reaches through the compiled template cache.
@watson watson force-pushed the watson/DEBUG-5733/refactor-template-cache branch from 90a1c84 to 284e2b3 Compare June 5, 2026 11:02
@watson watson merged commit c0a5a61 into main Jun 5, 2026
30 of 31 checks passed
@watson watson deleted the watson/DEBUG-5733/refactor-template-cache branch June 5, 2026 13:17
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants