Repository navigation
feat(metrics): add canonical cached grain-type dimensions - #11253
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Two unresolved moderate findings affect grain-type sentinel uniqueness and constructor-failure observer cleanup.
Get a fresh assessment by requesting another Copilot review.
Review tier: Lite
Findings: 1
Open findings (1)
What changed in this PR
Adds cached canonical grain_type dimensions to Orleans metrics, with population/lifecycle accounting, schema migration guidance, tests, and dashboard updates.
Changes:
- Adds per-type cached metrics and population gauges.
- Updates lifecycle and instance accounting while preserving management statistics.
- Documents and tests the new metric schema and dashboard queries.
Review findings:
src/Orleans.Core/Diagnostics/Metrics/GrainTypeMetrics.cs:16— Moderate, 3 votes:"unknown"can collide with a valid grain type, producing duplicate series.src/Orleans.Runtime/Catalog/ActivationData.cs:1014— Moderate, 1 vote: constructor failures skipOnDestroyActivation, breaking observer cleanup.
| File | Summary |
|---|---|
test/Orleans.Runtime.Tests/Diagnostics/GrainInstrumentsTests.cs |
Tests instance metrics, tags, and accounting. |
test/Orleans.Runtime.Internal.Tests/ActivationsLifeCycleTests/ActivationDataMigrationTests.cs |
Tests lifecycle, migration, cancellation, disposal, and stateless workers. |
test/Orleans.Core.Tests/Runtime/CatalogInstrumentsTests.cs |
Tests typed metrics, trackers, caching, and allocation behavior. |
test/Orleans.Core.Tests/Runtime/ActivationCollectorTests.cs |
Tests population and collection accounting. |
src/Orleans.Runtime/Catalog/GrainTypeSharedContext.cs |
Shares cached type metrics across activations. |
src/Orleans.Runtime/Catalog/Catalog.cs |
Tags catalog lifecycle and nonexistent-activation events. |
src/Orleans.Runtime/Catalog/ActivationWorkingSet.cs |
Tracks per-type working-set populations. |
src/Orleans.Runtime/Catalog/ActivationDirectory.cs |
Tracks per-type catalog populations. |
src/Orleans.Runtime/Catalog/ActivationData.cs |
Updates lifecycle metrics and disposal accounting. |
src/Orleans.Runtime/Catalog/ActivationCollector.cs |
Preserves collection-level shutdown events. |
src/Orleans.Core/Statistics/GrainMetricsListener.cs |
Removes the global metrics listener. |
src/Orleans.Core/Statistics/GrainCountStatistics.cs |
Uses local grain instrumentation statistics. |
src/Orleans.Core/Diagnostics/Metrics/GrainTypeMetrics.cs |
Defines cached per-type metric state. |
src/Orleans.Core/Diagnostics/Metrics/GrainInstruments.cs |
Adds canonical tags and local instance accounting. |
src/Orleans.Core/Diagnostics/Metrics/CatalogInstruments.cs |
Adds tagged lifecycle instruments and population gauges. |
samples/GPSTracker/README.md |
Documents dashboard migration guidance. |
samples/GPSTracker/grafana_dash.json |
Updates canonical and legacy metric queries. |
docs/site/src/content/docs/migration-guide.md |
Documents metric schema migration. |
docs/site/src/content/docs/host/monitoring/metrics.md |
Updates metric descriptions and aggregation semantics. |
docs/site/src/content/docs/host/monitoring/metrics-catalog.md |
Documents metric dimensions, scopes, and identity. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
c33e9c9 to
c63b483
Compare
Code coverage
Report-only conclusion: improved. The current-main baseline is commit Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities. The comparison remains report-only while normal line and branch variance is calibrated. Coverage details |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The DurableJobsJournaling dashboard still queries the removed type label and must be migrated to grain_type or an explicit legacy-schema query.
Review tier: Lite
Findings: None
Resolved since last review (1)
9fcfc01 to
41f780c
Compare


Activation populations and lifecycle metrics need a consistent grain-type identity so operators can correlate growth, churn, failures, and latency. This adds
grain_typedimensions using the canonicalGrainId.Type.ToString()value, cached per registered type and shared across activations.status,directory,via, and once-only completion. Capture directory failures before deactivation cleanup cancels the activation token, preserving thedirectory_erroroutcome.Metric schema migration:
orleans-grainschanges fromtypecontaining a CLR implementation name tograin_typecontaining the canonical identity. Migration guidance describes query updates, event-versus-population aggregation, emitter identity, and freshness. The sample Grafana dashboard supports canonical and legacy schemas separately.Collection scans retain their scan-level scope. The historical additional shutdown event for each nonempty collection batch carries only
via=collection, preserving aggregate event totals. Working-set members which expose no grain identity contribute untagged populations, distinct from a grain literally namedunknown. Request and streaming metrics retain their existing schemas.Microsoft Reviewers: Open in CodeFlow