Skip to content

Set proxy.forwarder activity DisplayName to request path#3031

Closed
LindqvistMartin wants to merge 1 commit into
dotnet:mainfrom
LindqvistMartin:fix/2667-trace-request-path
Closed

Set proxy.forwarder activity DisplayName to request path#3031
LindqvistMartin wants to merge 1 commit into
dotnet:mainfrom
LindqvistMartin:fix/2667-trace-request-path

Conversation

@LindqvistMartin

Copy link
Copy Markdown

Fixes #2667.

The proxy.forwarder activity is created with a constant name, so every YARP request shows up under the same name in Aspire / OTel dashboards. This sets DisplayName to Request.Path so requests are distinguishable. OperationName stays "proxy.forwarder" so anything filtering by activity name isn't affected. Empty paths keep the default.

Added Invoke_SetsActivityDisplayName_FromRequestPath in ProxyPipelineInitializerMiddlewareTests. Verified it fails on main and passes with the change.

The issue is tagged Type: Documentation — let me know if you'd rather close this in favor of a docs-only fix instead.

@LindqvistMartin

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@LindqvistMartin

Copy link
Copy Markdown
Author

Friendly ping. The red CI is unrelated flaky functional tests (HTTP/2 reset / socket abort), not from this change. Can rebase to re-trigger if useful.

@MihaZupan

Copy link
Copy Markdown
Member

The issue is tagged Type: Documentation — let me know if you'd rather close this in favor of a docs-only fix instead.

Yeah, my concern from the issue hasn't changed - #2667 (comment). If setting the name to the full path was a good idea to do by default, then why aren't we doing it in ASP.NET Core instead.

This PR is also changing the activity that YARP emits and not the wrapping one ASP.NET creates, so presumably the dashboard would still show you lots of the same name as top-level traces, but with more informative child traces?

@LindqvistMartin

Copy link
Copy Markdown
Author

Yeah, agreed on both.

The rename only touches the proxy.forwarder activity, which is a child of the ASP.NET Core hosting activity. The dashboard's trace list is keyed off the hosting activity, so it doesn't change. Only the child span ends up with the path, so this doesn't really fix what the issue was about.

And full path as the default name is the wrong call cardinality-wise, same reason ASP.NET Core stays away from it. Worse here since YARP routes are usually catch-all. Path's already on the activity as a tag anyway, so the data's there, it's just the default name.

Since it's labelled Documentation, probably cleaner to add a short doc on setting DisplayName yourself from a custom middleware or an ActivityListener, for anyone who wants per-path names and is ok with the cardinality cost. I can write that up, or just close this, whatever you prefer.

@MihaZupan

Copy link
Copy Markdown
Member

Adding that documentation is valuable, but it'd go in the https://github.com/dotnet/AspNetCore.Docs repo, so I'll close this PR for now

@MihaZupan MihaZupan closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telemetry - use the request path for name of trace

2 participants