Closed
Description
While investigating an issue with gen_ai telemetry, I noticed that the work done on a Blazor server doesn't occur within the scope of an Activity, but there is an Activity recorded and emitted by OTel for Blazor requests.
steps to reproduce
- Create an Aspire sample application
- This has OTel configured with the dashboard etc.
- Update the counter page code to:
@page "/counter"
@using System.Diagnostics
@rendermode InteractiveServer
@inject ILogger<Counter> logger
<PageTitle>Counter</PageTitle>
<h1>Counter</h1>
<p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
private int currentCount = 0;
private void IncrementCount()
{
currentCount++;
var activity = Activity.Current;
var ctx = (new HttpContextAccessor()).HttpContext;
logger.LogInformation("In `IncrementCount`");
}
}
Adding the ILogger, imports and extra code to IncrementCount()
- Set a breakpoint on
logger.LogInformation("In
IncrementCount");
line, and F5, and click the counter button. The breakpoint will be hit but there will not be an Activity or HttpContext. - Look at the OTel output in the dashboard, there will be a Trace for the call to the Counter Page, and there will be a structured log entry, but they are not associated with each other.