Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Perfomance] Add is_initial_load meta #206645

Merged
merged 27 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d61eb1d
[Perfomance] Add `is_initial_load` meta
kpatticha Jan 14, 2025
42bb08a
Merge branch 'main' into 4185-initial-load
kpatticha Jan 17, 2025
d03ad87
Merge branch 'main' into 4185-initial-load
kpatticha Jan 17, 2025
06e16e0
Merge branch 'main' of github.com:elastic/kibana into 4185-initial-load
kpatticha Feb 12, 2025
4d6fde0
[APM] Refactor ttmp instrumentation
kpatticha Feb 13, 2025
4e914cc
[Performance] Add ability to track ttfmp on refresh
kpatticha Feb 14, 2025
08662d7
Remove target
kpatticha Feb 14, 2025
7302198
[Infra] Track tttmp on refresh
kpatticha Feb 14, 2025
427f1a2
clean up
kpatticha Feb 14, 2025
23f4b1f
Merge branch 'main' of github.com:elastic/kibana into 4185-initial-load
kpatticha Feb 14, 2025
ae7659f
Keep the logic in parent component
kpatticha Feb 14, 2025
4fca592
Address PR comments
kpatticha Feb 14, 2025
91fcf76
Update tests
kpatticha Feb 14, 2025
f7f9fdc
Merge branch 'main' of github.com:elastic/kibana into 4185-initial-load
kpatticha Feb 14, 2025
662cb3b
Merge branch 'main' into 4185-initial-load
elasticmachine Feb 17, 2025
23c098e
Fix eslint
kpatticha Feb 18, 2025
0ec81ef
Merge branch '4185-initial-load' of github.com:kpatticha/kibana into …
kpatticha Feb 18, 2025
da1b2c9
Rename markPerformanceRefreshStart to onPageRefreshStart
kpatticha Feb 18, 2025
4dd16aa
Fix tests
kpatticha Feb 18, 2025
294a3e5
Fix onRefresh for metrics explorer
kpatticha Feb 18, 2025
8914b20
Fix lint
kpatticha Feb 19, 2025
8fda218
Merge branch 'main' of github.com:elastic/kibana into 4185-initial-load
kpatticha Feb 19, 2025
4edf641
Fix apm tests
kpatticha Feb 25, 2025
466045c
Fix tests
kpatticha Feb 25, 2025
c9be509
trigger onPageReady only when data changes
kpatticha Feb 25, 2025
3a95be3
Fix infra tests
kpatticha Feb 25, 2025
117d6a2
Merge branch 'main' into 4185-initial-load
elasticmachine Feb 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export function trackPerformanceMeasureEntries(analytics: AnalyticsClient, isDev
target,
query_range_secs: meta?.queryRangeSecs,
query_offset_secs: meta?.queryOffsetSecs,
is_initial_load: meta?.isInitialLoad,
},
});
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ import { EventData } from '../performance_context';
interface PerformanceMeta {
queryRangeSecs: number;
queryOffsetSecs: number;
isInitialLoad: boolean;
}

export function measureInteraction() {
performance.mark(perfomanceMarkers.startPageChange);
const trackedRoutes: string[] = [];
const trackedRoutes = new Set<string>();

return {
/**
* Marks the end of the page ready state and measures the performance between the start of the page change and the end of the page ready state.
Expand All @@ -46,22 +48,21 @@ export function measureInteraction() {
queryRangeSecs: getTimeDifferenceInSeconds(dateRangesInEpoch),
queryOffsetSecs:
rangeTo === 'now' ? 0 : getOffsetFromNowInSeconds(dateRangesInEpoch.endDate),
isInitialLoad: !trackedRoutes.has(pathname),
};
}

if (!trackedRoutes.includes(pathname)) {
performance.measure(pathname, {
detail: {
eventName: 'kibana:plugin_render_time',
type: 'kibana:performance',
customMetrics: eventData?.customMetrics,
meta: performanceMeta,
},
start: perfomanceMarkers.startPageChange,
end: perfomanceMarkers.endPageReady,
});
trackedRoutes.push(pathname);
}
performance.measure(pathname, {
detail: {
eventName: 'kibana:plugin_render_time',
type: 'kibana:performance',
customMetrics: eventData?.customMetrics,
meta: performanceMeta,
},
start: perfomanceMarkers.startPageChange,
end: perfomanceMarkers.endPageReady,
});
trackedRoutes.add(pathname);
},
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ describe('measureInteraction', () => {
meta: {
queryRangeSecs: 900,
queryOffsetSecs: 0,
isInitialLoad: true,
},
},
end: 'end::pageReady',
Expand Down Expand Up @@ -88,6 +89,7 @@ describe('measureInteraction', () => {
meta: {
queryRangeSecs: 1800,
queryOffsetSecs: 0,
isInitialLoad: true,
},
},
end: 'end::pageReady',
Expand Down Expand Up @@ -115,6 +117,7 @@ describe('measureInteraction', () => {
meta: {
queryRangeSecs: 86400,
queryOffsetSecs: -1800,
isInitialLoad: true,
},
},
end: 'end::pageReady',
Expand Down Expand Up @@ -142,20 +145,40 @@ describe('measureInteraction', () => {
meta: {
queryRangeSecs: 86400,
queryOffsetSecs: 1800,
isInitialLoad: true,
},
},
end: 'end::pageReady',
start: 'start::pageChange',
});
});

it('should not measure the same route twice', () => {
it('should set isInitialLoad to false on subsequent pageReady calls', () => {
const interaction = measureInteraction();
const pathname = '/test-path';
jest.spyOn(global.Date, 'now').mockReturnValue(1733704200000); // 2024-12-09T00:30:00Z

interaction.pageReady(pathname);
interaction.pageReady(pathname);
const eventData = {
meta: { rangeFrom: '2024-12-08T01:00:00Z', rangeTo: '2024-12-09T01:00:00Z' },
};

expect(performance.measure).toHaveBeenCalledTimes(1);
interaction.pageReady(pathname, eventData);
interaction.pageReady(pathname, eventData);

expect(performance.mark).toHaveBeenCalledWith(perfomanceMarkers.endPageReady);
expect(performance.measure).toHaveBeenCalledWith(pathname, {
detail: {
eventName: 'kibana:plugin_render_time',
type: 'kibana:performance',
customMetrics: undefined,
meta: {
queryRangeSecs: 86400,
queryOffsetSecs: 1800,
isInitialLoad: false,
},
},
end: 'end::pageReady',
start: 'start::pageChange',
});
});
});