Skip to content

Commit d0bf93e

Browse files
rubennortefacebook-github-bot
authored andcommitted
Log synthetic events for trace start/end when the trace finishes (#52937)
Summary: Pull Request resolved: #52937 Changelog: [internal] Minor refactor to log the synthetic events for trace start when the trace finishes. This is to simplify future work to implement a sliding window for trace events. Reviewed By: hoxyq Differential Revision: D79271692
1 parent 09c209b commit d0bf93e

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ bool PerformanceTracer::startTracing() {
3434
}
3535

3636
tracingAtomic_ = true;
37-
37+
currentTraceStartTime_ = HighResTimeStamp::now();
3838
return true;
3939
}
4040

@@ -60,6 +60,17 @@ std::optional<std::vector<TraceEvent>> PerformanceTracer::stopTracing() {
6060
// samples will be displayed as empty. We use these events to avoid that.
6161
// This could happen for non-bridgeless apps, where Performance interface is
6262
// not supported and no spec-compliant Event Loop implementation.
63+
64+
events.emplace_back(TraceEvent{
65+
.name = "TracingStartedInPage",
66+
.cat = "disabled-by-default-devtools.timeline",
67+
.ph = 'I',
68+
.ts = currentTraceStartTime_,
69+
.pid = processId_,
70+
.tid = oscompat::getCurrentThreadId(),
71+
.args = folly::dynamic::object("data", folly::dynamic::object()),
72+
});
73+
6374
events.emplace_back(TraceEvent{
6475
.name = "ReactNative-TracingStopped",
6576
.cat = "disabled-by-default-devtools.timeline",

packages/react-native/ReactCommon/jsinspector-modern/tracing/PerformanceTracer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ class PerformanceTracer {
149149
*/
150150
uint32_t performanceMeasureCount_{0};
151151

152+
HighResTimeStamp currentTraceStartTime_;
153+
152154
std::vector<TraceEvent> buffer_;
155+
153156
/**
154157
* Protects data members of this class for concurrent access, including
155158
* the tracingAtomic_, in order to eliminate potential "logic" races.

0 commit comments

Comments
 (0)