Add query health endpoint with Route attribute support#2281
Merged
Conversation
- Created Route attribute for custom query routes - Implemented QueryHealthTracker service for tracking observable query subscriptions - Created QueryHealth read model with custom route /.cratis/queries/health - Integrated health tracking into ObservableQueryDemultiplexer - Updated proxy generator and runtime mapper to support Route attribute - Added CustomRoute property to IQueryPerformer, ModelBoundQueryPerformer, and ControllerQueryPerformer
Copilot
AI
changed the title
[WIP] Add query health endpoint to retrieve observable query status
Add query health endpoint with Route attribute support
Jun 8, 2026
|
NuGet packages for this PR, e.g. Cratis.Arc: |
JsonSerializer.deserializeFromInstance and deserializeArrayFromInstance break when called with String, Number, or Boolean as the instanceType — they return empty values instead of passing the data through unchanged. Skip deserialization entirely for primitive types and pass the raw data (or Array.from for enumerables and changeSet arrays) directly through.
…ixtures QueryPerformerProvider uses QueryMetadataRegistry when populated, falling back to ITypes.All only when the registry is empty. ITypes.All is populated by source-generated providers — test assemblies don't run source generators, so their [ReadModel] types are invisible and no HTTP endpoints are registered, causing 404 failures in the integration specs. Scanning the test assembly for [ReadModel] types and registering each query method with QueryMetadataRegistry before the host starts ensures performers are created and endpoints are mapped correctly.
Reflects the [Route("/.cratis/queries/health")] attribute added to the
ObserveHealth query method, replacing the conventional route.
Introduce QuerySubscriber and QuerySubscriptionAggregate records that group all
active subscriptions by query name — matching the queryName property on generated
TypeScript proxies exactly ({TypeFullName}.{MethodName} format).
The new QuerySubscriptions property on QueryHealth provides a query-centric view
across all transport modes (multiplexed WebSocket and direct SSE), enabling tooling
to correlate frontend cache diagnostics with backend subscription state using the
same query identifier on both sides.
Also fix ReadModelType in CreateSubscriptionMetadata: was incorrectly set to the
full QueryIdentifier; now strips the trailing .{MethodName} segment so the type
name refers to the read model type only.
Document the /.cratis/queries/health observable endpoint: response shape,
both connection-centric and query-centric views, how transport modes affect
the output, and the cross-stack correlation approach using the shared
{TypeFullName}.{MethodName} query identifier format.
Extend the frontend observable query diagnostics page with a step-by-step
investigation flow that shows how to match a frontend cache entry to its
backend subscribers using the same queryName identifier on both sides.
…ariable' Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Implements observable query health monitoring at
/.cratis/queries/healthwith a new Route attribute for custom endpoint paths.Added
[Route]attribute for specifying custom routes on query classes or methods (method takes precedence)IQueryHealthTrackerservice tracking all active observable query subscriptionsQueryHealthread model exposing connection health via observable query at/.cratis/queries/healthws-{counter}for WebSocket, GUID for SSEFixed
Changed
ObservableQueryDemultiplexernow tracks subscription lifecycle (register, unregister, ping, pong, data served)IQueryPerformerincludesCustomRoutepropertyModelBoundQueryPerformerandControllerQueryPerformerdetect Route attribute via reflectionQueryEndpointMapperprefers custom routes over conventional route generationQueryExtensionsdetects Route attribute and uses custom route in generated codeUsage
Health data includes per-connection subscriptions with query identifiers, read model types, timestamps, and client details.