Repository navigation
feat(dashboard): add silo lifecycle dependency graph view - #10145
Merged
ReubenBond merged 3 commits intoMay 29, 2026
Merged
Conversation
Add a new "Lifecycle" page to the Orleans Dashboard that renders the silo startup and shutdown sequence as a Mermaid flowchart, grouping participants by ServiceLifecycleStage (including the additional numeric-only stages some components register at). Backend: - Internal LifecycleStageInfo / LifecycleObserverInfo serializable models. - LifecycleStageInspector reflects over SiloLifecycleSubject.observers and unwraps the LifecycleExtensions Observer / StartupObserver delegate wrappers to recover observer names, stage names, and the OnStart / OnStop target methods. Compiler-generated suffixes from static local functions (g__Name|N) and anonymous lambdas (b__N_N) are stripped, so the dashboard shows readable method names even when the subscription was made via a static local function inside an explicit interface implementation with nested generics. - ISiloGrainService.GetLifecycleStages() implemented in SiloGrainService (injects ISiloLifecycleSubject) and forwarded through SiloGrainProxy. - DashboardClient.GetLifecycleStages() asks any active silo (via IManagementGrain.GetHosts(onlyActive: true)) since all silos share the same lifecycle. - New /LifecycleStages HTTP route in MapOrleansDashboard. Frontend: - Add mermaid dependency. - New src/lifecycle/lifecycle.tsx renders startup (low - high) and shutdown (reversed) flowcharts plus per-stage observer tables. Strips Mermaid's pinned SVG width/height/max-width so the rendered diagram scales to its viewBox and the bottom row isn't clipped when the host container narrows. - Wire #/lifecycle route and a sidebar Lifecycle menu entry. Runtime/Dashboard refactor: - Replace every anonymous lambda passed to ISiloLifecycle.Subscribe with a named local function (or no-op helper) so the dashboard view reports a meaningful method name for each participant. Covers Silo, PlacementService, LocalGrainDirectory, DistributedGrainDirectory, ClusterManifestProvider, ActivationMigrationManager, GrainCallCancellationManager, ActivationWorkingSet, ClientDirectory, IncomingRequestMonitor, LocalReminderService, GatewayConnectionListener, SiloStatusListenerManager, DeploymentLoadPublisher, ServiceLifecycle, and the dashboard GrainProfiler. Tests: - LifecycleStageInspectorTests covers grouping/ordering, named-vs-numeric stage detection, start-only observers, the null-lifecycle guard, the static-local-function-with-explicit-interface case, and the anonymous lambda fallback formatting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The Mermaid-emitted viewBox for the lifecycle flowchart is computed before the browser lays out the HTML labels inside the `foreignObject` elements (which Mermaid hardcodes to `width: 200px`). On a real silo this leaves the bottom row of stages — including the final `Active` and `Last` boxes — below the viewBox lower edge and clipped by the surrounding card, while a large strip of whitespace appears above the diagram (the viewBox's negative `min-y`). After the SVG is inserted into the DOM via `dangerouslySetInnerHTML`, schedule a `requestAnimationFrame` callback that queries the live SVG element, calls `getBBox()` for the actual rendered bounds, and rewrites both the `viewBox` attribute and the `aspect-ratio` style to match (plus a small padding). The recomputation reruns whenever the SVG changes or the tab switches between Startup and Shutdown.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new Lifecycle view to the Orleans Dashboard which exposes silo startup/shutdown lifecycle participants and renders them as a Mermaid dependency graph, backed by runtime lifecycle introspection and surfaced via a new dashboard API endpoint.
Changes:
- Added server-side lifecycle introspection (
LifecycleStageInspector) and a new dashboard endpoint/client method to fetch lifecycle stage/observer metadata. - Refactored many
ISiloLifecycle.Subscriberegistrations from anonymous lambdas to named local functions so observer method names are diagnosable. - Added a new React page which renders Startup/Shutdown diagrams and tables using Mermaid (including an SVG viewBox post-layout fix).
Show a summary per file
| File | Description |
|---|---|
| test/Orleans.Dashboard.Tests/Orleans.Dashboard.UnitTests/LifecycleStageInspectorTests.cs | Adds unit tests for lifecycle extraction, ordering/grouping, and name “prettification”. |
| src/Orleans.Runtime/Silo/Silo.cs | Replaces anonymous lifecycle lambdas with named local functions for clearer diagnostics. |
| src/Orleans.Runtime/Placement/PlacementService.cs | Introduces named no-op start callback for lifecycle wiring. |
| src/Orleans.Runtime/Placement/DeploymentLoadPublisher.cs | Replaces inline stop lambda with named local function for clearer diagnostics. |
| src/Orleans.Runtime/Networking/GatewayConnectionListener.cs | Replaces inline lifecycle lambda with named local function. |
| src/Orleans.Runtime/MembershipService/SiloStatusListenerManager.cs | Replaces inline no-op delegates with named no-op helpers. |
| src/Orleans.Runtime/Manifest/ClusterManifestProvider.cs | Replaces inline no-op stop delegate with a named local function. |
| src/Orleans.Runtime/GrainDirectory/LocalGrainDirectory.cs | Replaces lifecycle lambdas with named local functions for start/stop. |
| src/Orleans.Runtime/GrainDirectory/DistributedGrainDirectory.cs | Replaces inline no-op start lambda with named helper. |
| src/Orleans.Runtime/GrainDirectory/ClientDirectory.cs | Refactors lifecycle start/stop lambdas into named local functions (more readable/introspectable). |
| src/Orleans.Runtime/Catalog/IncomingRequestMonitor.cs | Refactors lifecycle callbacks into named local functions. |
| src/Orleans.Runtime/Catalog/ActivationWorkingSet.cs | Refactors lifecycle callbacks into named local functions. |
| src/Orleans.Runtime/Catalog/ActivationMigrationManager.cs | Refactors lifecycle callbacks into named local functions. |
| src/Orleans.Runtime/Cancellation/GrainCallCancellationManager.cs | Refactors lifecycle callbacks into named local functions. |
| src/Orleans.Reminders/ReminderService/LocalReminderService.cs | Refactors lifecycle callbacks into named local functions and adds named no-op stop. |
| src/Orleans.Core/Lifecycle/ServiceLifecycle.cs | Replaces inline no-op delegates with named local functions. |
| src/Dashboard/Orleans.Dashboard/ServiceCollectionExtensions.cs | Adds /LifecycleStages dashboard route. |
| src/Dashboard/Orleans.Dashboard/Model/LifecycleStageInfo.cs | Adds serialized model describing a lifecycle stage and its observers. |
| src/Dashboard/Orleans.Dashboard/Model/LifecycleObserverInfo.cs | Adds serialized model describing an observer and its start/stop methods. |
| src/Dashboard/Orleans.Dashboard/Metrics/GrainProfiler.cs | Refactors lifecycle subscription to named methods for better diagnostics. |
| src/Dashboard/Orleans.Dashboard/Implementation/SiloGrainService.cs | Injects ISiloLifecycleSubject and exposes GetLifecycleStages(). |
| src/Dashboard/Orleans.Dashboard/Implementation/LifecycleStageInspector.cs | New reflection-based extractor for lifecycle stages/observers with cleaned method names. |
| src/Dashboard/Orleans.Dashboard/Implementation/Grains/SiloGrainProxy.cs | Adds GetLifecycleStages() pass-through. |
| src/Dashboard/Orleans.Dashboard/Core/ISiloGrainService.cs | Adds GetLifecycleStages() grain service API. |
| src/Dashboard/Orleans.Dashboard/Core/IDashboardClient.cs | Adds GetLifecycleStages() client API. |
| src/Dashboard/Orleans.Dashboard/Core/DashboardClient.cs | Implements lifecycle stage retrieval by querying an active silo via management grain. |
| src/Dashboard/Orleans.Dashboard.App/src/lifecycle/lifecycle.tsx | New UI page rendering startup/shutdown Mermaid graphs and observer tables; includes SVG viewBox fix. |
| src/Dashboard/Orleans.Dashboard.App/src/index.tsx | Adds routing and menu entry for the Lifecycle page and fetches lifecycle data. |
| src/Dashboard/Orleans.Dashboard.App/package.json | Adds mermaid dependency. |
| src/Dashboard/Orleans.Dashboard.App/package-lock.json | Locks Mermaid and transitive dependencies. |
Copilot's findings
Files not reviewed (1)
- src/Dashboard/Orleans.Dashboard.App/package-lock.json: Language not supported
- Files reviewed: 29/30 changed files
- Comments generated: 2
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Jun 15, 2026
This was referenced Jun 22, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a Lifecycle view to the Orleans Dashboard that renders the silo startup and shutdown stages as a Mermaid dependency graph.
Problem
Orleans silos compose their startup/shutdown from many ILifecycleParticipant registrations across the runtime, providers, and storage backends. Today there's no way for an operator to look at a running silo and answer "what runs at stage X?" or "where does the silo currently sit in its boot sequence?" — that information is only visible at debug-log level via
SiloLifecycleSubject.In addition, a large share of those registrations were made via anonymous lambdas (
ct => Task.Run(...)), so even when introspected they surface as compiler-generated<Participate>b__N_Nnames that are useless for diagnostics.Solution
Two changes, in two commits:
feat(dashboard): add silo lifecycle dependency graph viewLifecycleStageInspectorreflects overSiloLifecycleSubject.observersto recover each observer's name, stage, and OnStart/OnStop target method (drilling through the privateLifecycleExtensions.Observer/StartupObserverdelegate wrappers). Compiler-generated suffixes from static local functions (g__Name|N) and anonymous lambdas (b__N_N) are stripped so the output reads asType.MethodNamerather than a mangled symbol.ISiloGrainService.GetLifecycleStages()exposes the data;DashboardClientasks any active silo viaIManagementGrain.GetHosts(onlyActive: true)since all silos share the same lifecycle./LifecycleStagesroute inMapOrleansDashboard.Lifecyclepage renders a Mermaidflowchart TDfor Startup and (in a separate tab) Shutdown, plus per-stage observer tables. Addsmermaidas a dependency and a sidebar menu entry.ISiloLifecycle.Subscribeacross the runtime and dashboard into named local functions (orNoOpStart/NoOpStophelpers) so the view shows meaningful method names. TouchesSilo,PlacementService,LocalGrainDirectory,DistributedGrainDirectory,ClusterManifestProvider,ActivationMigrationManager,GrainCallCancellationManager,ActivationWorkingSet,ClientDirectory,IncomingRequestMonitor,LocalReminderService,GatewayConnectionListener,SiloStatusListenerManager,DeploymentLoadPublisher,ServiceLifecycle, andGrainProfiler.LifecycleStageInspectorTestscovering grouping/ordering, named-vs-numeric stage detection, start-only observers, the null-lifecycle guard, the explicit-interface static-local-function case, and the anonymous-lambda fallback formatting.fix(dashboard): recompute lifecycle SVG viewBox from rendered boundsviewBoxbefore the browser lays out the HTML labels insideforeignObjectelements, so the bottom row of stages ends up clipped and a strip of whitespace appears above the diagram. After insertion werequestAnimationFrame→getBBox()→ rewriteviewBoxand install intrinsicwidth/heightattributes so the SVG renders at natural pixel size. The host card scrolls when the diagram exceeds the panel.Rationale
Lifecycle wiring is a key part of the silo's contract with hosted components, but most users only encounter it when something fails mid-startup. Surfacing it as a first-class dashboard view — together with the named-function refactor that makes the output legible — gives operators a fast, accurate map of what runs when, and gives contributors a way to spot ordering mistakes without resorting to trace logs.
Microsoft Reviewers: Open in CodeFlow