Enable more metrics
- Dominant language
- C#
- Stars
- 6
- Forks
- 2
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 4
Description
- https://learn.microsoft.com/en-us/aspnet/core/blazor/performance/?view=aspnetcore-10.0
## Gemini slop:
### Step 1: Install Required NuGet Packages
To capture "all" standard metrics, you need the core SDK plus the instrumentation libraries for the different parts of the .NET stack.
Run the following commands in your project folder:
```bash
# Core OpenTelemetry and ASP.NET Core integration
dotnet add package OpenTelemetry.Extensions.Hosting
dotnet add package OpenTelemetry.Instrumentation.AspNetCore
# Runtime metrics (GC, Memory, CPU, ThreadPool, etc.)
dotnet add package OpenTelemetry.Instrumentation.Runtime
# Process metrics (Physical/Virtual memory, CPU time for the process)
dotnet add package OpenTelemetry.Instrumentation.Process
# HttpClient metrics (Outgoing HTTP request durations, error rates)
dotnet add package OpenTelemetry.Instrumentation.Http
# Exporter (Choose one: Prometheus is common for metrics)
dotnet add package OpenTelemetry.Exporter.Prometheus.AspNetCore
# OR for Console output (debugging):
# dotnet add package OpenTelemetry.Exporter.Console
```
### Step 2: Configure Global Metrics Export
In your `Program.cs`, configure OpenTelemetry. The key to getting "all" metrics is chaining the `Add...Instrumentation` methods.
```csharp
using OpenTelemetry.Metrics;
var builder = WebApplication.CreateBuilder(args);
// Add OpenTelemetry Metrics
builder.Services.AddOpenTelemetry()
.WithMetrics(metrics =>
{
metrics
// 1. Enable Built-in Metrics (The "All" part)
.AddAspNetCoreInstrumentation() // Incoming HTTP requests (ASP.NET Core)
.AddHttpClientInstrumentation() // Outgoing HTTP requests (HttpClient)
.AddRuntimeInstrumentation() // Memory, GC, ThreadPool, Assemblies
.AddProcessInstrumentation() // CPU usage, RAM usage
// 2. Add Custom Metrics
// Subscribe to a specific custom meter by name
.AddMeter("MyCompany.MyApplication.Meter")
// OR use a Wildcard to subscribe to ALL custom meters starting with a prefix
.AddMeter("MyCompany.*")
// 3. Configure the Exporter (Where to send the data)
// Example: Expose a Prometheus scraping endpoint
.AddPrometheusExporter();
// Example: Debugging to Console
// .AddConsoleExporter();
});
var app = builder.Build();
// 4. Map the Prometheus scraping endpoint (if using Prometheus)
app.MapPrometheusScrapingEndpoint();
app.MapGet("/", () => "Hello World!");
app.Run();
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the ASP.NET Core performance reference linked in the issue and inspecting the Program.cs configuration shown there. Clarify which metrics this application should expose and which exporter is required; completion would mean the selected metrics are configured and available through the Prometheus scraping endpoint.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100