Skip to content

[release/13.2] Simplify TelemetryApiService.GetTrace and support short trace IDs#15613

Open
JamesNK wants to merge 4 commits intorelease/13.2from
telemetry-api-short-traceid
Open

[release/13.2] Simplify TelemetryApiService.GetTrace and support short trace IDs#15613
JamesNK wants to merge 4 commits intorelease/13.2from
telemetry-api-short-traceid

Conversation

@JamesNK
Copy link
Member

@JamesNK JamesNK commented Mar 26, 2026

Description

Simplify TelemetryApiService.GetTrace and add support for short trace ID lookups.

Changes:

  • TelemetryApiService.GetTrace: Replaced manual GetTraces() + LINQ search with a direct call to TelemetryRepository.GetTrace(traceId), which already handles short trace ID matching via OtlpHelpers.MatchTelemetryId.
  • TelemetryRepository.GetTraceUnsynchronized: Added early return for trace IDs shorter than ShortenedIdLength (7 chars) to skip the loop when the ID is too short for a meaningful prefix match.
  • Unit tests: Added parameterized test covering full trace ID, shortened (7-char prefix) trace ID, and non-existent trace ID scenarios.

Fixes #15611

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
    • No

- Use TelemetryRepository.GetTrace instead of fetching all traces
- Add early return in GetTraceUnsynchronized for IDs shorter than ShortenedIdLength
- Add parameterized unit test for full, short, and nonexistent trace IDs
Copilot AI review requested due to automatic review settings March 26, 2026 07:32
@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15613

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15613"

Copy link
Contributor

Copilot AI left a comment

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 streamlines trace lookup in the Dashboard telemetry API and aims to support shortened (prefix) trace IDs by delegating lookup to TelemetryRepository.GetTrace, which uses OtlpHelpers.MatchTelemetryId.

Changes:

  • Reworked TelemetryApiService.GetTrace to call TelemetryRepository.GetTrace(traceId) directly instead of paging GetTraces() and searching in-memory.
  • Added a short-circuit in TelemetryRepository.GetTraceUnsynchronized for trace IDs shorter than ShortenedIdLength (7).
  • Added a parameterized unit test covering full ID, 7-char prefix ID, and not-found cases.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Aspire.Dashboard/Api/TelemetryApiService.cs Simplifies trace retrieval by using repository direct lookup (enables shortened ID matching via repository logic).
src/Aspire.Dashboard/Otlp/Storage/TelemetryRepository.cs Adds an early return for “too short” trace IDs in GetTraceUnsynchronized.
tests/Aspire.Dashboard.Tests/TelemetryApiServiceTests.cs Adds theory coverage for full/prefix/invalid trace ID lookups through the API service.

@JamesNK JamesNK added area-cli area-dashboard Servicing-consider Issue for next servicing release review and removed area-cli labels Mar 26, 2026
@JamesNK JamesNK added this to the 13.2.x milestone Mar 26, 2026
@JamesNK JamesNK changed the title Simplify TelemetryApiService.GetTrace and support short trace IDs [release/13.2] Simplify TelemetryApiService.GetTrace and support short trace IDs Mar 26, 2026
JamesNK added 2 commits March 26, 2026 15:42
MatchTelemetryId already handles short IDs correctly with exact equality
fallback, so the guard was preventing valid exact-match lookups.
@github-actions
Copy link
Contributor

🎬 CLI E2E Test Recordings — 51 recordings uploaded (commit c6b1542)

View recordings
Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
AddPackageWhileAppHostRunningDetached ▶️ View Recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
Banner_DisplayedOnFirstRun ▶️ View Recording
Banner_DisplayedWithExplicitFlag ▶️ View Recording
CertificatesClean_RemovesCertificates ▶️ View Recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
CreateAndRunEmptyAppHostProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
CreateAndRunTypeScriptStarterProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DescribeCommandResolvesReplicaNames ▶️ View Recording
DescribeCommandShowsRunningResources ▶️ View Recording
DetachFormatJsonProducesValidJson ▶️ View Recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
GlobalMigration_PreservesAllValueTypes ▶️ View Recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
LogsCommandShowsResourceLogs ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
RestoreGeneratesSdkFiles ▶️ View Recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
RunWithMissingAwaitShowsHelpfulError ▶️ View Recording
SecretCrudOnDotNetAppHost ▶️ View Recording
SecretCrudOnTypeScriptAppHost ▶️ View Recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
StopAllAppHostsFromAppHostDirectory ▶️ View Recording
StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
StopNonInteractiveSingleAppHost ▶️ View Recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
TypeScriptAppHostWithProjectReferenceIntegration ▶️ View Recording

📹 Recordings uploaded automatically from CI run #23583252353

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-dashboard Servicing-consider Issue for next servicing release review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants