Remove telemetry API data limits and refactor URL builders#16020
Remove telemetry API data limits and refactor URL builders#16020
Conversation
- Remove MaxQueryCount from TelemetryApiService, use int.MaxValue so storage queries return all data and limits are controlled by callers. - Add TelemetryCommandHelpers.MaxTelemetryLimit (int.MaxValue) for CLI export and MCP tools to fetch all available telemetry data. - Refactor DashboardUrls telemetry URL builders from params tuples to explicit named parameters matching MapTelemetryApi endpoints. - Replace BuildQueryString with AddQueryString pattern for consistency. - Update tests for new URL builder signatures and large limit scenarios.
Add GetSpans_WithLimit_ReturnsMostRecentSpans, GetTraces_WithLimit_ReturnsMostRecentTraces, and GetLogs_WithLimit_ReturnsMostRecentLogs tests to TelemetryApiServiceTests.
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16020Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16020" |
There was a problem hiding this comment.
Pull request overview
Removes artificial data caps in the dashboard telemetry API/CLI flows (so exports and MCP tools don’t silently truncate), and refactors telemetry URL builders in DashboardUrls to use explicit, endpoint-aligned parameters.
Changes:
- Updated dashboard telemetry API queries to request all stored items (
Count = int.MaxValue) and rely on the caller-providedlimitfor truncation. - Added a CLI-side “fetch max available” limit constant and propagated it to export + MCP telemetry fetches.
- Refactored
DashboardUrlstelemetry URL builders to explicit parameters and aligned query-string building with the existingAddQueryStringpattern; updated/added unit and integration tests.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Shared/Telemetry/TelemetryTestHelpers.cs | Adds maxLogCount option to allow large-log scenarios in tests. |
| tests/Aspire.Dashboard.Tests/TelemetryApiServiceTests.cs | Adds coverage for “limit returns most recent” and large-limit log retrieval. |
| tests/Aspire.Dashboard.Tests/Integration/TelemetryApiTests.cs | Updates integration coverage to use very large limit values in query-param checks. |
| tests/Aspire.Cli.Tests/Commands/TelemetryCommandTests.cs | Updates tests to validate new telemetry logs URL builder behavior. |
| src/Shared/DashboardUrls.cs | Refactors telemetry URL builders to explicit parameters and uses AddQueryString + shared resource param appending. |
| src/Aspire.Dashboard/Api/TelemetryApiService.cs | Removes MaxQueryCount and requests all stored telemetry items from storage before applying API-level limit. |
| src/Aspire.Cli/Mcp/Tools/ListTraceStructuredLogsTool.cs | Ensures MCP trace structured logs fetch requests the maximum available data. |
| src/Aspire.Cli/Mcp/Tools/ListTracesTool.cs | Ensures MCP traces fetch requests the maximum available data. |
| src/Aspire.Cli/Mcp/Tools/ListStructuredLogsTool.cs | Ensures MCP structured logs fetch requests the maximum available data. |
| src/Aspire.Cli/Commands/TelemetryTracesCommand.cs | Simplifies URL construction using new typed URL builder parameters. |
| src/Aspire.Cli/Commands/TelemetrySpansCommand.cs | Simplifies URL construction and preserves follow-mode limit behavior via typed URL builder parameters. |
| src/Aspire.Cli/Commands/TelemetryLogsCommand.cs | Simplifies URL construction and preserves follow-mode limit behavior via typed URL builder parameters. |
| src/Aspire.Cli/Commands/TelemetryCommandHelpers.cs | Adds MaxTelemetryLimit constant (used to request “max available” results). |
| src/Aspire.Cli/Commands/ExportCommand.cs | Ensures export fetches all available structured logs/traces in a single API call. |
Comments suppressed due to low confidence (2)
src/Aspire.Dashboard/Api/TelemetryApiService.cs:56
- When multiple resources are specified, this method queries the repository once per resource key and then aggregates results with AddRange. Traces/spans that involve more than one of the selected resources can be returned multiple times, inflating TotalCount/ReturnedCount and potentially causing duplicates in the response. Consider deduplicating by (TraceId, SpanId) after aggregation or changing the query strategy to avoid per-resource queries for multi-resource filters.
foreach (var resourceKey in resourceKeys)
{
var result = telemetryRepository.GetTraces(new GetTracesRequest
{
ResourceKey = resourceKey,
StartIndex = 0,
Count = int.MaxValue,
Filters = [],
FilterText = string.Empty
});
allSpans.AddRange(result.PagedResult.Items.SelectMany(t => t.Spans));
src/Aspire.Dashboard/Api/TelemetryApiService.cs:127
- For multi-resource filters, aggregating GetTraces results per resource key can duplicate the same trace when it contains spans from more than one selected resource. This can skew TotalCount/ReturnedCount and cause duplicates to be returned/limited incorrectly. Consider deduplicating by TraceId after aggregation (or avoid per-resource querying when multiple resource names are supplied).
foreach (var resourceKey in resourceKeys)
{
var result = telemetryRepository.GetTraces(new GetTracesRequest
{
ResourceKey = resourceKey,
StartIndex = 0,
Count = int.MaxValue,
Filters = [],
FilterText = string.Empty
});
allTraces.AddRange(result.PagedResult.Items);
|
🎬 CLI E2E Test Recordings — 55 recordings uploaded (commit View recordings
📹 Recordings uploaded automatically from CI run #24216472327 |
|
/backport to release/13.2 |
|
Started backporting to |
Description
Remove artificial telemetry data limits in the dashboard API and CLI, and refactor URL builder methods for type safety and consistency.
Changes:
MaxQueryCountfromTelemetryApiService: Storage queries now useint.MaxValueso all data is returned and limits are controlled by the caller'slimitparameter.TelemetryCommandHelpers.MaxTelemetryLimit(int.MaxValue): CLI export and MCP tools pass this to fetch all available telemetry data in a single API call.DashboardUrlstelemetry URL builders: Changed fromparams (string, string?)[]tuples to explicit named parameters matchingMapTelemetryApiendpoints, improving type safety and discoverability.BuildQueryStringwithAddQueryStringpattern: Aligns telemetry URL construction with the existing pattern used byStructuredLogsUrland other URL builders in the same class.Motivation: The export command and MCP tools were silently truncating telemetry data due to default limits (100 traces, 200 logs) when no
limitparameter was passed. This made exports incomplete without any warning.Checklist