Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to use Standalone Aspire dashboard in Blazor 8?

$
0
0

In this video: https://youtu.be/BnjHArsYGLM?si=hzogiatb4-323S&t=463@SamSpencer and @NoaFolk talk about OpenTelemetry and .NET8.

Around 7:43 Noa talks about the standalone Aspire dashboard and how you can use it without the need for a full Aspire projects setup.

Sadly they didn't share a working repo.

I've created a new Blazor WebApp using the new template for .NET 8 (the template creates two projects, a ServerSide and ClientSide one) and I added OpenTelemetry. I use the ConsoleExporter and I can see it is logging like I want. I even added a few metrics.

But I can't get the Dashboard to work. Does anybody else get this working?

This is my Program.cs, in my ServerSide project:

var builder = WebApplication.CreateBuilder(args);builder.Services.AddSingleton<CustomMeters>();builder.Services.AddOpenTelemetry()    .WithMetrics(metrics => metrics            .AddMeter("Microsoft.AspNetCore.Hosting")            .AddMeter("Microsoft.AspNetCore.Server.Kestrel")            .AddMeter("Microsoft.AspNetCore.Http.Connections")            .AddMeter("System.NET.Http")            .AddHttpClientInstrumentation()            .AddAspNetCoreInstrumentation()            .AddOtlpExporter())              // <== This should create the dashboard    .WithTracing(tracing => tracing            .SetSampler(new AlwaysOnSampler())            .AddHttpClientInstrumentation()            .AddAspNetCoreInstrumentation()    );// Clear default logging providers used by WebApplication host.builder.Logging.ClearProviders();builder.Logging.AddOpenTelemetry(options =>{    options.AddConsoleExporter();    options.AddOtlpExporter(otlpOptions =>        otlpOptions.Endpoint = new Uri(builder.Configuration.GetValue("Otlp:Endpoint", defaultValue: "http://localhost:4317")!));});// Add services to the container.builder.Services.AddRazorComponents()    .AddInteractiveServerComponents()    .AddInteractiveWebAssemblyComponents();var app = builder.Build();[..]

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>