-
Notifications
You must be signed in to change notification settings - Fork 716
Route name on Traces and Logs #1037
-
I would like to see the version on route instead of v{version:apiVersion} on Traces and Logs. Is there any way ?
For example:
imageThe http url does not have the selected version for the endpoint.
Beta Was this translation helpful? Give feedback.
All reactions
I poked around a bit more and I found this line:
This clearly shows that it uses the Endpoint.RoutePattern.RawText as the value. The route template is defined as v{version:apiVersion}/WeatherForecast so that is what I would expect to see. What you would probably prefer is to is IEndpointNameMetadata, which usually maps to OperationId in OpenAPI. There is also IEndpointSummaryMetadata and IEndpointDescriptionMetadata, but those probably provide longer descriptions than what you are looking for.
I don't see an...
Replies: 2 comments 12 replies
-
Try this nuget and see if it fits your need.
https://www.nuget.org/packages/ServiceLevelIndicators.Asp.ApiVersioning
Beta Was this translation helpful? Give feedback.
All reactions
-
Hey, good ?
That package adds an attribute to an specific metric, right ?
But what I mean is the display on traces/logs, it is always v{version:apiVersion}/route-blabla. I think it should be the version.
In my MVC controllers I always use [Route("v{version:apiVersion}/asset-classes")], and it is expected to replace that pattern to the selected version.
Beta Was this translation helpful? Give feedback.
All reactions
-
It emits a metrics giving the latency of each API with API version as a dimension. By attaching a TraceID, you can figure out the API version of the traces.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
I agree, but this behaviour is expected ? Should not the display be v1/asset-classes on traces titles ?
Beta Was this translation helpful? Give feedback.
All reactions
-
That I don't know. I have only used API version as a query parameter and not in the URL. I plan to play around with Aspire soon.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
Both Aspire and VS 17. 9 is in preview so I will wait for the release version.
Beta Was this translation helpful? Give feedback.
All reactions
-
Is there no place where the full request URL is shown in the trace? It looks like it is only showing the route template. It's not clear whether that is happening. If the endpoint was hit, then the actual request URL should be the value shown. Unless something else strange is happening in the implementation, I would expect something like order/{id}/items to be shown the same way. Aspire is in preview so there's always the chance this is a bug. I don't know how the values shown in the trace are generated (yet).
Beta Was this translation helpful? Give feedback.
All reactions
-
This looks like it might be for a Minimal API. Is it? It also looks like you want the value of http.target to show up for Activity.DisplayName and http.route. These appear to be showing you your defined route templates. I don't know there is a solution for http.route, but there may be a way to specify an alternate Activity.DisplayName. I would expect the same behavior for any route template that contains parameters; otherwise, something special is happening. That doesn't make sense because the routing system has to match a request to the template. There is no in-between. When you match, you have a template against the request URL, when you don't, you only have the request URL.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
@commonsensesoftware, this example is a MVC Controller:
[ApiController]
[Route("v{version:apiVersion}/[controller]")]
public class WeatherForecastController(ISampleApiClient sampleApiClient) : ControllerBase
{
}
Full trace:
imageBeta Was this translation helpful? Give feedback.
All reactions
-
I think this implementation is the source:
It uses httpRoute.
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 1
-
I poked around a bit more and I found this line:
This clearly shows that it uses the Endpoint.RoutePattern.RawText as the value. The route template is defined as v{version:apiVersion}/WeatherForecast so that is what I would expect to see. What you would probably prefer is to is IEndpointNameMetadata, which usually maps to OperationId in OpenAPI. There is also IEndpointSummaryMetadata and IEndpointDescriptionMetadata, but those probably provide longer descriptions than what you are looking for.
I don't see any hooks or other approaches to influence the trace and log values so - for now - I don't think there are any solutions. I would recommend creating an issue in the Open Telemetry repo and ask them to honor some of the other available metadata.
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
I agree as well, I will open an issue there. Thank you for your attention. For now I will remove the pattern from route and explicitly set the version.
Beta Was this translation helpful? Give feedback.