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

spike: web performance #13299

Closed
wants to merge 85 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
fb4a26d
wip: CH schema
pauldambra Dec 13, 2022
0aeebc8
updates to schema - almost migrates :'(
pauldambra Dec 13, 2022
aa08a1a
some notes
pauldambra Dec 13, 2022
9341b3a
need to format table name in
pauldambra Dec 13, 2022
defd038
fix migrations
pauldambra Dec 13, 2022
c3b2544
be specific, more or less
pauldambra Dec 13, 2022
2d15107
trim the fat
pauldambra Dec 13, 2022
0d9fd6b
Added performance event processing
benjackwhite Dec 13, 2022
58a2be2
sharded migration
pauldambra Dec 13, 2022
589c94e
Refactor inspector area
benjackwhite Dec 13, 2022
51bdd98
Merge branches 'feat/web-performance-schema' and 'feat/web-performanc…
benjackwhite Dec 13, 2022
7e84d11
correct the migration :shrug:
pauldambra Dec 13, 2022
97d6055
Added to tests
benjackwhite Dec 13, 2022
09f84b2
Moved buttons
benjackwhite Dec 13, 2022
19ec544
better mapping of fields
pauldambra Dec 13, 2022
57dfe87
remove writeable table, we don't know either
pauldambra Dec 13, 2022
7f28787
rename file
pauldambra Dec 14, 2022
f366738
fewer things in order by :confuse face:
pauldambra Dec 14, 2022
d6d1fe9
one time origin is less confusing
pauldambra Dec 14, 2022
71c362f
add a comment
pauldambra Dec 14, 2022
b66cf54
snapshot the table queries
pauldambra Dec 14, 2022
09e3b0a
Refactoring all the things...
benjackwhite Dec 14, 2022
e5534cf
fixes and add writeable back
pauldambra Dec 14, 2022
e2e14d9
wild fixes
pauldambra Dec 14, 2022
e2c2b19
wip
benjackwhite Dec 14, 2022
e535f03
Merge branch 'feat/web-performance-schema' of github.com:PostHog/post…
benjackwhite Dec 14, 2022
3eb29c7
slightly less mind-bending column gen
pauldambra Dec 14, 2022
265027a
Merge branch 'master' into feat/web-performance-schema
pauldambra Dec 14, 2022
84bd59b
super scrappy API listing
pauldambra Dec 14, 2022
2e68de2
Add a bad timestamp
pauldambra Dec 14, 2022
939b68d
wip
benjackwhite Dec 14, 2022
91049be
Merge branch 'feat/web-performance-schema' of github.com:PostHog/post…
benjackwhite Dec 14, 2022
bdb09b1
more granular timestamp needed in the API
pauldambra Dec 14, 2022
e6222a9
Added more stuff
benjackwhite Dec 14, 2022
eb25d95
Merge branch 'feat/web-performance-schema' of github.com:PostHog/post…
benjackwhite Dec 14, 2022
8b286cb
Updated to support console logs
benjackwhite Dec 14, 2022
9f6eee6
Fix
benjackwhite Dec 14, 2022
3e81890
Merge branch 'master' into feat/web-performance-schema
benjackwhite Dec 15, 2022
011a470
Fixes
benjackwhite Dec 15, 2022
521c194
Fix
benjackwhite Dec 15, 2022
d209b59
Fix
benjackwhite Dec 15, 2022
1ac8d84
Format times correctly
benjackwhite Dec 15, 2022
6a4ac8e
accept calculated timestamp from client
pauldambra Dec 15, 2022
4e143fb
nullable _timestamp was a setup problem locally
pauldambra Dec 15, 2022
17c6ebc
Fix
benjackwhite Dec 15, 2022
a6716d6
back to nullable datetime errors from clickhouse
pauldambra Dec 15, 2022
34d7359
Started adding mini filters
benjackwhite Dec 15, 2022
21a26b3
Merge branch 'feat/web-performance-schema' of github.com:PostHog/post…
benjackwhite Dec 15, 2022
14bf6be
Added feature flag
benjackwhite Dec 15, 2022
14e245a
Fix search positioning
benjackwhite Dec 15, 2022
afa598f
Added events
benjackwhite Dec 15, 2022
c790210
Fix more things
benjackwhite Dec 15, 2022
8c86a30
Filter events for "all" view
benjackwhite Dec 16, 2022
5da57ff
Optimise layout for your screen size
benjackwhite Dec 16, 2022
e54c0aa
Fixed console logs
benjackwhite Dec 16, 2022
ecf9203
Added timestampMode
benjackwhite Dec 16, 2022
37515b6
Added flag just for performance
benjackwhite Dec 16, 2022
6978e7d
add note
pauldambra Dec 16, 2022
2fafc73
start updating schema
pauldambra Dec 16, 2022
427f1ba
sql as lambdas not formatted strings
pauldambra Dec 16, 2022
b5d0bc7
obey replication setting
pauldambra Dec 16, 2022
50b3c25
Revert "obey replication setting"
pauldambra Dec 16, 2022
93458be
Fixes filters
benjackwhite Dec 16, 2022
4e1e814
Add console log support
benjackwhite Dec 16, 2022
9044dd0
Fixed some more things
benjackwhite Dec 16, 2022
8af79d0
Changed to button
benjackwhite Dec 16, 2022
658a6c3
Fixed up styles and colors for matched events
benjackwhite Dec 19, 2022
b72d3e6
Merge branch 'master' into feat/web-performance-schema
benjackwhite Dec 19, 2022
bd5f4db
Fixed up performance of scrolling list
benjackwhite Dec 19, 2022
1cff685
Added clickable elements
benjackwhite Dec 19, 2022
6d73841
Fix
benjackwhite Dec 19, 2022
a32f190
Fixed seeking
benjackwhite Dec 19, 2022
ffc0966
Started adding position marker
benjackwhite Dec 20, 2022
47d52f9
Merge branch 'master' into feat/web-performance-schema
benjackwhite Dec 20, 2022
14eb01f
Fix
benjackwhite Dec 20, 2022
bd440b6
Fix duplicate thumbar
benjackwhite Dec 20, 2022
80a68df
Added empty state notice for console logs and performance
benjackwhite Dec 20, 2022
61ab01b
Fixes
benjackwhite Dec 20, 2022
e80f096
Moved persistent settings to settings logic
benjackwhite Dec 20, 2022
f769cf6
Added LemonSkeleton loader
benjackwhite Dec 20, 2022
a63fb5d
Added feature flag check
benjackwhite Dec 20, 2022
ab14bef
Fix
benjackwhite Dec 20, 2022
3fef4b8
Merge branch 'master' into feat/web-performance-schema
benjackwhite Dec 20, 2022
d9fd806
Merge branch 'master' into feat/web-performance-schema
benjackwhite Dec 21, 2022
d826982
Merge branch 'master' into feat/web-performance-schema
benjackwhite Dec 21, 2022
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
18 changes: 4 additions & 14 deletions frontend/src/scenes/session-recordings/player/PlayerController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,14 @@ import { LemonButton, LemonButtonWithPopup } from 'lib/components/LemonButton'
import { IconExport, IconFullScreen, IconPause, IconPlay, IconSkipInactivity } from 'lib/components/icons'
import { Tooltip } from 'lib/components/Tooltip'
import clsx from 'clsx'
import { PlayerInspectorPicker } from './PlayerInspector'
import { playerSettingsLogic } from './playerSettingsLogic'
import { More } from 'lib/components/LemonButton/More'
import { LemonCheckbox } from '@posthog/lemon-ui'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { FEATURE_FLAGS } from 'lib/constants'
import { PlayerMetaLinks } from './PlayerMetaLinks'

interface PlayerControllerProps extends SessionRecordingPlayerLogicProps {
hideInspectorPicker?: boolean
}

export function PlayerController({
sessionRecordingId,
playerKey,
hideInspectorPicker = false,
}: PlayerControllerProps): JSX.Element {
export function PlayerController({ sessionRecordingId, playerKey }: SessionRecordingPlayerLogicProps): JSX.Element {
const logic = sessionRecordingPlayerLogic({ sessionRecordingId, playerKey })
const { togglePlayPause, exportRecordingToFile } = useActions(logic)
const { currentPlayerState } = useValues(logic)
Expand All @@ -41,10 +33,8 @@ export function PlayerController({
<div className="p-3 bg-light flex flex-col select-none space-y-2">
<Seekbar sessionRecordingId={sessionRecordingId} playerKey={playerKey} />
<div className="flex justify-between items-center h-8 gap-2">
<div className="flex items-center gap-2 flex-1">
{!hideInspectorPicker && !isFullScreen && (
<PlayerInspectorPicker sessionRecordingId={sessionRecordingId} playerKey={playerKey} />
)}
<div className="flex-1">
<PlayerMetaLinks sessionRecordingId={sessionRecordingId} playerKey={playerKey} />
</div>
<div className="flex items-center gap-1">
<SeekSkip sessionRecordingId={sessionRecordingId} playerKey={playerKey} direction="backward" />
Expand Down
353 changes: 228 additions & 125 deletions frontend/src/scenes/session-recordings/player/PlayerInspector.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,8 @@ export function PlayerMetaLinks({ sessionRecordingId, playerKey }: SessionRecord
}

return (
<div className="flex flex-row justify-end gap-2">
<LemonButton
icon={<IconLink />}
onClick={onShare}
tooltip="Share recording"
size={isFullScreen ? 'small' : 'medium'}
>
<div className="flex flex-row gap-2">
<LemonButton icon={<IconLink />} onClick={onShare} tooltip="Share recording" size={'small'}>
Share
</LemonButton>
<LemonButton
Expand All @@ -50,7 +45,7 @@ export function PlayerMetaLinks({ sessionRecordingId, playerKey }: SessionRecord
<IconPlus />
</IconWithCount>
}
size={isFullScreen ? 'small' : 'medium'}
size={'small'}
tooltip="Save recording to static playlist"
>
Save
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import {
import { PlayerFrame } from 'scenes/session-recordings/player/PlayerFrame'
import { PlayerController } from 'scenes/session-recordings/player/PlayerController'
import { LemonDivider } from 'lib/components/LemonDivider'
import { PlayerInspector, PlayerInspectorPicker } from 'scenes/session-recordings/player/PlayerInspector'
import { PlayerFilter } from 'scenes/session-recordings/player/list/PlayerFilter'
import { PlayerInspector } from 'scenes/session-recordings/player/PlayerInspector'
import { PlayerMeta } from './PlayerMeta'
import { sessionRecordingDataLogic } from './sessionRecordingDataLogic'
import clsx from 'clsx'
Expand Down Expand Up @@ -155,22 +154,11 @@ export function SessionRecordingPlayer({
/>
</div>
<LemonDivider className="my-0" />
<PlayerController
sessionRecordingId={sessionRecordingId}
playerKey={playerKey}
hideInspectorPicker={size !== 'small'}
/>
<PlayerController sessionRecordingId={sessionRecordingId} playerKey={playerKey} />
</div>
{!isFullScreen && (
<div className="SessionRecordingPlayer__inspector">
{size !== 'small' && (
<div className="border-b p-2">
<PlayerInspectorPicker sessionRecordingId={sessionRecordingId} playerKey={playerKey} />
</div>
)}
<PlayerFilter sessionRecordingId={sessionRecordingId} playerKey={playerKey} matching={matching} />
<LemonDivider className="my-0" />
<PlayerInspector sessionRecordingId={sessionRecordingId} playerKey={playerKey} />
<PlayerInspector {...logicProps} />
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,90 +11,3 @@ import { LemonInput } from 'lib/components/LemonInput/LemonInput'
import { eventsListLogic } from 'scenes/session-recordings/player/list/eventsListLogic'
import { consoleLogsListLogic } from 'scenes/session-recordings/player/list/consoleLogsListLogic'
import { SessionRecordingPlayerLogicProps } from '../sessionRecordingPlayerLogic'

export function PlayerFilter({
sessionRecordingId,
playerKey,
matching,
}: SessionRecordingPlayerLogicProps): JSX.Element {
const logicProps = { sessionRecordingId, playerKey }
const { windowIdFilter, showOnlyMatching, tab } = useValues(sharedListLogic(logicProps))
const { setWindowIdFilter, setShowOnlyMatching } = useActions(sharedListLogic(logicProps))
const { eventListLocalFilters } = useValues(eventsListLogic(logicProps))
const { setEventListLocalFilters } = useActions(eventsListLogic(logicProps))
const { consoleListLocalFilters } = useValues(consoleLogsListLogic(logicProps))
const { setConsoleListLocalFilters } = useActions(consoleLogsListLogic(logicProps))
const { windowIds } = useValues(playerMetaLogic(logicProps))

return (
<div className="PlayerFilter flex justify-between gap-2 bg-side p-2 flex-wrap">
<div className="flex items-center gap-2 flex-wrap">
{tab === SessionRecordingPlayerTab.EVENTS ? (
<>
<LemonInput
key="event-list-search-input"
onChange={(query) => setEventListLocalFilters({ query })}
placeholder="Search events"
type="search"
value={eventListLocalFilters.query}
/>
{matching?.length ? (
<LemonSwitch
checked={showOnlyMatching}
bordered
label={
<span className="flex items-center gap-2 whitespace-nowrap">
Only show matching events
<Tooltip
title="Display only the events that match the global filter."
className="text-base text-muted-alt mr-2"
>
<IconInfo />
</Tooltip>
</span>
}
onChange={setShowOnlyMatching}
/>
) : null}
</>
) : (
<LemonInput
key="console-list-search-input"
onChange={(query) => setConsoleListLocalFilters({ query })}
placeholder="Search console logs"
type="search"
value={consoleListLocalFilters.query}
/>
)}
</div>

{windowIds.length > 1 ? (
<div className="flex items-center gap-2 flex-wrap">
<LemonSelect
data-attr="player-window-select"
value={windowIdFilter ?? undefined}
onChange={(val) => setWindowIdFilter(val as WindowOption)}
options={[
{
value: RecordingWindowFilter.All,
label: 'All windows',
icon: <IconWindow value="A" className="text-muted" />,
},
...windowIds.map((windowId, index) => ({
value: windowId,
label: `Window ${index + 1}`,
icon: <IconWindow value={index + 1} className="text-muted" />,
})),
]}
/>
<Tooltip
title="Each recording window translates to a distinct browser tab or window."
className="text-base text-muted-alt mr-2"
>
<IconInfo />
</Tooltip>
</div>
) : null}
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
width: 100%;

@include screen($md) {
width: 30%;
min-width: 350px;
max-width: 400px;
width: 350px;
}

.SessionRecordingsPlaylist__list-item {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ export enum SessionRecordingUsageType {
export enum SessionRecordingPlayerTab {
EVENTS = 'events',
CONSOLE = 'console',
PERFORMANCE = 'performance',
}

export enum SessionPlayerState {
Expand Down
1 change: 1 addition & 0 deletions plugin-server/src/config/kafka-topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const KAFKA_PERSON = `${prefix}clickhouse_person${suffix}`
export const KAFKA_PERSON_UNIQUE_ID = `${prefix}clickhouse_person_unique_id${suffix}`
export const KAFKA_PERSON_DISTINCT_ID = `${prefix}clickhouse_person_distinct_id${suffix}`
export const KAFKA_SESSION_RECORDING_EVENTS = `${prefix}clickhouse_session_recording_events${suffix}`
export const KAFKA_PERFORMANCE_EVENTS = `${prefix}clickhouse_performance_events${suffix}`
export const KAFKA_EVENTS_PLUGIN_INGESTION = `${prefix}events_plugin_ingestion${suffix}`
export const KAFKA_PLUGIN_LOG_ENTRIES = `${prefix}plugin_log_entries${suffix}`
export const KAFKA_EVENTS_DEAD_LETTER_QUEUE = `${prefix}events_dead_letter_queue${suffix}`
Expand Down
106 changes: 106 additions & 0 deletions plugin-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,112 @@ export interface RawSessionRecordingEvent {
created_at: string
}

export interface RawPerformanceEvent {
uuid: string
team_id: number
distinct_id: string
session_id: string
window_id: string
pageview_id: string
current_url: string

// BASE_EVENT_COLUMNS
time_origin: number
origin_timestamp: string
entry_type: string
name: string

// RESOURCE_EVENT_COLUMNS
start_time: number
redirect_start: number
redirect_end: number
worker_start: number
fetch_start: number
domain_lookup_start: number
domain_lookup_end: number
connect_start: number
secure_connection_start: number
connect_end: number
request_start: number
response_start: number
response_end: number
decoded_body_size: number
encoded_body_size: number

initiator_type: string
next_hop_protocol: string
render_blocking_status: string
response_status: number
transfer_size: number

// LARGEST_CONTENTFUL_PAINT_EVENT_COLUMNS
largest_contentful_paint_element: string
largest_contentful_paint_render_time: number
largest_contentful_paint_load_time: number
largest_contentful_paint_size: number
largest_contentful_paint_id: string
largest_contentful_paint_url: string

// NAVIGATION_EVENT_COLUMNS
dom_complete: number
dom_content_loaded_event: number
dom_interactive: number
load_event_end: number
load_event_start: number
redirect_count: number
navigation_type: string
unload_event_end: number
unload_event_start: number
}

export const PerformanceEventReverseMapping: { [key: number]: keyof RawPerformanceEvent } = {
// BASE_PERFORMANCE_EVENT_COLUMNS
0: 'entry_type',
1: 'time_origin',
2: 'name',

// RESOURCE_EVENT_COLUMNS
3: 'start_time',
4: 'redirect_start',
5: 'redirect_end',
6: 'worker_start',
7: 'fetch_start',
8: 'domain_lookup_start',
9: 'domain_lookup_end',
10: 'connect_start',
11: 'secure_connection_start',
12: 'connect_end',
13: 'request_start',
14: 'response_start',
15: 'response_end',
16: 'decoded_body_size',
17: 'encoded_body_size',
18: 'initiator_type',
19: 'next_hop_protocol',
20: 'render_blocking_status',
21: 'response_status',
22: 'transfer_size',

// LARGEST_CONTENTFUL_PAINT_EVENT_COLUMNS
23: 'largest_contentful_paint_element',
24: 'largest_contentful_paint_render_time',
25: 'largest_contentful_paint_load_time',
26: 'largest_contentful_paint_size',
27: 'largest_contentful_paint_id',
28: 'largest_contentful_paint_url',

// NAVIGATION_EVENT_COLUMNS
29: 'dom_complete',
30: 'dom_content_loaded_event',
31: 'dom_interactive',
32: 'load_event_end',
33: 'load_event_start',
34: 'redirect_count',
35: 'navigation_type',
36: 'unload_event_end',
37: 'unload_event_start',
}

export enum TimestampFormat {
ClickHouseSecondPrecision = 'clickhouse-second-precision',
ClickHouse = 'clickhouse',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { runProcessEvent } from '../../plugins/run'
import { LazyPersonContainer } from '../lazy-person-container'
import { EventPipelineRunner, StepResult } from './runner'

const EVENTS_TO_IGNORE = ['$snapshot', '$performance_event']

export async function pluginsProcessEventStep(
runner: EventPipelineRunner,
event: PluginEvent,
Expand All @@ -13,7 +15,7 @@ export async function pluginsProcessEventStep(
let processedEvent: PluginEvent | null = event

// run processEvent on all events that are not $snapshot
if (event.event !== '$snapshot') {
if (!EVENTS_TO_IGNORE.includes(event.event)) {
processedEvent = await runInstrumentedFunction({
server: runner.hub,
event,
Expand Down
Loading