Skip to content

Commit

Permalink
fix(ttd): Add span ids to time to display debug logs (#3868)
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich authored Jun 7, 2024
1 parent 837def0 commit 229ffc0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fix

- Add missing logs to dropped App Start spans ([#3861](https://github.com/getsentry/sentry-react-native/pull/3861))
- Add Span IDs to Time to Display debug logs ([#3868](https://github.com/getsentry/sentry-react-native/pull/3868))

### Dependencies

Expand Down
14 changes: 8 additions & 6 deletions src/js/tracing/timetodisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ function updateInitialDisplaySpan(frameTimestampSeconds: number): void {

if (fullDisplayBeforeInitialDisplay.has(activeSpan)) {
fullDisplayBeforeInitialDisplay.delete(activeSpan);
logger.debug(`[TimeToDisplay] Updating full display with initial display (${span.spanContext().spanId}) end.`);
updateFullDisplaySpan(frameTimestampSeconds, span);
}

Expand All @@ -233,7 +234,7 @@ function updateInitialDisplaySpan(frameTimestampSeconds: number): void {
function updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDisplaySpan?: Span): void {
const activeSpan = getActiveSpan();
if (!activeSpan) {
logger.warn(`[TimeToDisplay] No active span found to attach ui.load.full_display to.`);
logger.warn(`[TimeToDisplay] No active span found to update ui.load.full_display in.`);
return;
}

Expand All @@ -247,25 +248,26 @@ function updateFullDisplaySpan(frameTimestampSeconds: number, passedInitialDispl
const initialDisplayEndTimestamp = existingInitialDisplaySpan && spanToJSON(existingInitialDisplaySpan).timestamp;
if (!initialDisplayEndTimestamp) {
fullDisplayBeforeInitialDisplay.set(activeSpan, true);
logger.warn(`[TimeToDisplay] Full display called before initial display for active span.`);
logger.warn(`[TimeToDisplay] Full display called before initial display for active span (${activeSpan.spanContext().spanId}).`);
return;
}

const span = startTimeToFullDisplaySpan();
if (!span) {
logger.warn(`[TimeToDisplay] No span found or created, possibly performance is disabled.`);
logger.warn(`[TimeToDisplay] No TimeToFullDisplay span found or created, possibly performance is disabled.`);
return;
}

if (spanToJSON(span).timestamp) {
logger.warn(`[TimeToDisplay] ${spanToJSON(span).description} span already ended.`);
const spanJSON = spanToJSON(span);
if (spanJSON.timestamp) {
logger.warn(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span already ended.`);
return;
}

span.end(frameTimestampSeconds);

span.setStatus('ok');
logger.debug(`[TimeToDisplay] ${spanToJSON(span).description} span updated with end timestamp.`);
logger.debug(`[TimeToDisplay] ${spanJSON.description} (${spanJSON.span_id}) span updated with end timestamp.`);

setSpanDurationAsMeasurement('time_to_full_display', span);
}

0 comments on commit 229ffc0

Please sign in to comment.