Fix dashboard resource filtering for custom OpenTelemetry service names #9722
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.
Problem
When users configure OpenTelemetry with custom service names using
.ConfigureResource(b => b.AddService(builder.Environment.ApplicationName))
, the dashboard resource filtering dropdowns fail to work correctly. Only the "All" option shows data, while selecting specific resources shows empty results. For Metrics, which has no "All" option, this makes metrics completely inaccessible.Root Cause
The issue occurs due to a mismatch between:
When navigating from the Resources page to Metrics/Traces/Logs, the URL contains the original app host resource name, but the telemetry applications are keyed by the custom service name. The
ApplicationsSelectHelpers.GetApplication
method fails to find a match and returns the fallback ("All"), causing empty results.Solution
Added a fallback strategy to
ApplicationsSelectHelpers.GetApplication
: when no exact matches are found and there's only one application available, return that application instead of the fallback. This handles the common case where users have a single service with a custom name while preserving existing behavior for multiple applications.Testing
Impact
Fixes #9632.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.