[RUM] React Profiler#4505
Draft
MandragoreVR wants to merge 2 commits intomainfrom
Draft
Conversation
|
✨ Fix all issues with BitsAI or with Cursor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This PR is an attempt made by Claude to have a working React Profiler. This is part of the initiative for the Agentic Week (detailed here).
Changes
Generated by Claude
Schema & type generation (
rum-events-format,scripts/)rum-events-formatsubmodule toteo.chaillou/RUM-react-profilingbranch, which adds React profiling JSONschemas (
react-profiling-browser-schema.json,react-profile-trace-schema.json,_common-schema.json)scripts/lib/generatedSchemaTypes.tssoyarn json-schemas:generateproducespackages/rum-react/src/types/reactProfiling.tsandpackages/rum-react/src/types/reactProfileTrace.tsPlugin API surface (
packages/rum-core)OnRumStartOptionsinplugins.tswithprofilingEndpointBuilder,configuration,lifeCycle,session,viewHistory, andcreateEncoderso plugins can access profiling infrastructurerumPublicApi.tswhen callingcallPluginsMethod('onRumStart', ...)DeflateEncoderStreamId.REACT_PROFILING = 7inpackages/coretrackCommonViewMetrics.tsandrumPublicApi.tscontainsetViewLoadingTimetelemetry changes
React profiler core (
packages/rum-react)createReactProfiler.ts(new, 282 lines): Windowed profiling controller that batches component renders intosamples, rotates windows on a configurable interval or visibility change, and sends
FormDatapayloads (event.jsonreact-profiling.json) to/api/v2/profileviacreateFormDataTransportreactPlugin.ts: OnonRumStart, creates and starts the profiler when the session is sampled atprofilingSampleRate. ExposesisReactProfilingRunning()andgetRunningReactProfiler()for use by the<ReactProfiler>componentreactProfiler.tsx(new, 164 lines):<ReactProfiler name="...">component using a dual strategy —<React.Profiler>forbase_duration+ sentinelLifeCyclecomponents for per-phase durations (render,layoutEffect,effect)collectReactComponentRender.ts(new): Bridge that forwards render data from the<ReactProfiler>componentto the running profiler's
addComponentRendertimer.ts,performance/index.ts: Timer utility for phase measurement; re-exportReactProfilerentries/main.ts: ExportReactProfilerandReactProfilerContextfrom the package public APIreactProfiler.spec.tsx(new, 433 lines): Unit tests for the<ReactProfiler>componentTest app (
test/apps/react-shopist-like)@datadog/browser-rumand@datadog/browser-rum-reactdependencies with tarball resolutionsprofilingSampleRate: 100and the React plugin inmain.tsx<ProductCard>with<ReactProfiler name="ProductCard">Test helpers (
packages/rum-react/test)initializeReactPluginto acceptlifeCycle,sessionManager,viewHistory,createEncoder, andrumConfigurationfor profiling-related tests