Skip to content

Commit 5e8ad31

Browse files
docs(crash): sequence diagram #5827
Add a sequence diagram which explains the crash monitoring flow
1 parent 96783ea commit 5e8ad31

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

docs/telemetry-perf.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,70 @@ How long it took from when the user stopped pressing a key to when they were sho
258258
rHandler->>User: add to already shown results
259259
end
260260
```
261+
262+
## Crash Monitoring
263+
264+
We make an attempt to gather information regarding when the IDE crashes, then report it to telemetry. This is the diagram of the steps that take place.
265+
266+
### Sequence Diagram
267+
268+
> Keep in mind that the entire sequence below is duplicated for each instance of our extension.
269+
> They all work together to "crash check" on behalf of the other crashed extension instance.
270+
271+
`Crash Service`: The high level "service" that starts the heartbeats and crash checks
272+
273+
`Heartbeat`: Sends heartbeats which signal that the extension is still running and has not crashed
274+
275+
`Crash Checker`: Observes the heartbeats, reporting a telemetry event if a crash is detected
276+
277+
`File System State`: The user's file system where we store the heartbeat files from each extension instance
278+
279+
```mermaid
280+
%%{init: {'theme':'default'}}%%
281+
sequenceDiagram
282+
autonumber
283+
284+
participant VSC as VS Code
285+
participant Service as Crash Service
286+
participant Checker as Crash Checker
287+
participant Heartbeat as Heartbeat
288+
participant State as File System State
289+
participant Telemetry as Telemetry
290+
291+
rect rgb(121, 210, 121)
292+
alt Extension Startup
293+
VSC ->> Service: activate() - Start Monitoring
294+
295+
Service ->> Heartbeat: Start Heartbeats
296+
Heartbeat ->> State: Send Initial Heartbeat <br/> (in a folder add a unique file w/ timestamp)
297+
rect rgb(64, 191, 64)
298+
par every N minutes
299+
Heartbeat ->> State: Send Heartbeat <br/> (overwrite the unique file w/ new timestamp)
300+
end
301+
end
302+
303+
Service ->> Checker: Start Crash Checking
304+
rect rgb(64, 191, 64)
305+
par every N*2 minutes
306+
Checker ->> Checker: If computer went to sleep, skip this iteration (gives time for a heartbeat)
307+
Checker ->> State: Request all heartbeat timestamps (readdir all heartbeat files)
308+
State ->> Checker: Receive all heartbeat timestamps
309+
loop for each crashed extension (it's timestamp >= N*2 minutes)
310+
Checker ->> State: Delete heartbeat file
311+
Checker ->> Telemetry: Send metric representing a crash: session_end
312+
end
313+
end
314+
end
315+
end
316+
end
317+
318+
rect rgb(255, 128, 128)
319+
alt Graceful Shutdown
320+
VSC ->> Service: deactivate() - Stop Monitoring
321+
Service ->> Checker: Stop
322+
Service ->> Heartbeat: Stop
323+
Heartbeat ->> State: Delete timestamp file <br/> (This is missed when a crash happens)
324+
end
325+
end
326+
327+
```

0 commit comments

Comments
 (0)