Skip to content

feat(dashboard): add silo lifecycle dependency graph view - #10145

Merged
ReubenBond merged 3 commits into
dotnet:mainfrom
ReubenBond:rebond/dashboard-silo-lifecycle-view
May 29, 2026
Merged

ReubenBond merged 3 commits into
dotnet:mainfrom
ReubenBond:rebond/dashboard-silo-lifecycle-view

Conversation

@ReubenBond

@ReubenBond ReubenBond commented May 28, 2026 •

Copy link
Copy Markdown
Member

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_N names that are useless for diagnostics.

Solution

Two changes, in two commits:

  1. feat(dashboard): add silo lifecycle dependency graph view

    • New LifecycleStageInspector reflects over SiloLifecycleSubject.observers to recover each observer's name, stage, and OnStart/OnStop target method (drilling through the private LifecycleExtensions.Observer / StartupObserver delegate wrappers). Compiler-generated suffixes from static local functions (g__Name|N) and anonymous lambdas (b__N_N) are stripped so the output reads as Type.MethodName rather than a mangled symbol.
    • New ISiloGrainService.GetLifecycleStages() exposes the data; DashboardClient asks any active silo via IManagementGrain.GetHosts(onlyActive: true) since all silos share the same lifecycle.
    • New /LifecycleStages route in MapOrleansDashboard.
    • New React/TypeScript Lifecycle page renders a Mermaid flowchart TD for Startup and (in a separate tab) Shutdown, plus per-stage observer tables. Adds mermaid as a dependency and a sidebar menu entry.
    • Refactors every anonymous lambda passed to ISiloLifecycle.Subscribe across the runtime and dashboard into named local functions (or NoOpStart/NoOpStop helpers) so the view shows meaningful method names. Touches Silo, PlacementService, LocalGrainDirectory, DistributedGrainDirectory, ClusterManifestProvider, ActivationMigrationManager, GrainCallCancellationManager, ActivationWorkingSet, ClientDirectory, IncomingRequestMonitor, LocalReminderService, GatewayConnectionListener, SiloStatusListenerManager, DeploymentLoadPublisher, ServiceLifecycle, and GrainProfiler.
    • Adds LifecycleStageInspectorTests covering 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.
  2. fix(dashboard): recompute lifecycle SVG viewBox from rendered bounds

    • Mermaid computes its SVG viewBox before the browser lays out the HTML labels inside foreignObject elements, so the bottom row of stages ends up clipped and a strip of whitespace appears above the diagram. After insertion we requestAnimationFrame → getBBox() → rewrite viewBox and install intrinsic width/height attributes 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

ReubenBond and others added 2 commits May 28, 2026 14:46
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Subscribe registrations 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>
@ReubenBond
ReubenBond added this pull request to the merge queue May 28, 2026
Merged via the queue into dotnet:main with commit e93b593 May 29, 2026
62 checks passed
@ReubenBond
ReubenBond deleted the rebond/dashboard-silo-lifecycle-view branch May 29, 2026 00:21
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants