Vight.AspNetCore
.NET / ASP.NET Core
Add Vight to ASP.NET Core services with the Vight.AspNetCore package and the AddVightApm service registration.
Integration model
The ASP.NET Core integration registers tracing, metrics, and Vight resource attributes through the application service collection. Configure it before the app is built so request instrumentation and runtime signals use the same service identity.
The registration should live beside the rest of your service configuration in Program.cs. Keep values sourced from environment variables in deployed services so release, environment, and project routing can be changed without code edits.
Install
dotnet add package Vight.AspNetCoreConfigure Program.cs
using Vight.Apm.AspNetCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddVightApm(options =>
{
options.ServiceName =
Environment.GetEnvironmentVariable("VIGHT_SERVICE_NAME") ?? "checkout-api";
options.Environment =
Environment.GetEnvironmentVariable("VIGHT_ENVIRONMENT") ?? builder.Environment.EnvironmentName;
options.Version =
Environment.GetEnvironmentVariable("VIGHT_SERVICE_VERSION") ?? "1.0.0";
options.DeploymentId =
Environment.GetEnvironmentVariable("VIGHT_DEPLOYMENT_ID") ?? "";
options.OtlpEndpoint = new Uri(
Environment.GetEnvironmentVariable("VIGHT_OTLP_ENDPOINT") ?? "https://ingest.vight.dev");
options.IngestionKey =
Environment.GetEnvironmentVariable("VIGHT_INGESTION_KEY") ?? "";
});
var app = builder.Build();
app.MapGet("/", () => "ok");
app.Run();What this enables
- Request spans
- ASP.NET Core requests are represented as inbound spans with route, method, status, and duration context.
- Outbound calls
- HTTP client activity is attached to the trace so dependency time can be separated from application time.
- Runtime signals
- Runtime and process metrics are reported with the same service identity used by traces and logs.
- Export
- Telemetry is exported over OTLP HTTP/protobuf to the Vight endpoint configured for the project.
Startup order
Register Vight before building the application and before handling requests. If service identity values are changed after instrumentation starts, traces, logs, and runtime signals can land under different labels.