Description
I'm using the Serilog tracing nuget package to add tracing to our framework asp.net mvc application as described here:
serilog-tracing/serilog-tracing#145
Issue is related to this line of code:
Log.Logger.StartActivity(@"{HttpMethod} {RawUrl}", HttpContext.Current.Request.HttpMethod, HttpContext.Current.Request.RawUrl);
Here we start the activity logging the HttpMethod and the RawUrl.
When using this sink to send the traces to an aspire dashboard, the Name property of the span is set to the Message Template, which results in the following on the aspire dashboard.
As you can see, the displayed name is not formatted, the property names are still visible. On the left side in the list of spans related to the trace, and also on the right where the properties are displayed.
The properties needed to format the name/message are present with the span.
(the last trace line is generated by a different service, and not with the serilog sink. on that line it is displayed correctly)
I see in the OtlpEventBuilder.cs
, that this is done by design?
public static void ProcessName(Span span, LogEvent logEvent)
{
if (!string.IsNullOrWhiteSpace(logEvent.MessageTemplate.Text))
{
span.Name = logEvent.MessageTemplate.Text;
}
}
Is there a way to configure the sink to also use the formatted message for the spans? I see that there is a feature for formatting the messages of the structured logs, but not the names of the span.
Perhaps a configurable setting to enforce the parsing of the Span name?