This sample demonstrates Xavier's OpenTelemetry integration for distributed tracing and metrics.
Important: Xavier does NOT auto-enable exporters. This is intentional per the project spec.
You must configure exporters via callbacks:
builder.AddXavier(options =>
{
options.Observability.Enabled = true;
options.Observability.ServiceName = "MyApi";
// Configure tracing exporter
options.Observability.ConfigureTracing = tracing =>
tracing.AddOtlpExporter(o => o.Endpoint = new Uri("http://localhost:4317"));
// Configure metrics exporter
options.Observability.ConfigureMetrics = metrics =>
metrics.AddOtlpExporter(o => o.Endpoint = new Uri("http://localhost:4317"));
});- OpenTelemetry tracing with ASP.NET Core instrumentation
- OpenTelemetry metrics with ASP.NET Core instrumentation
- HTTP client distributed tracing
- Runtime metrics (GC, threads, etc.)
- Console and OTLP exporters
dotnet runcurl http://localhost:5000/api/trace-demoWatch the console for trace output.
curl http://localhost:5000/api/slowcurl http://localhost:5000/api/metrics-demo-
Start Jaeger:
docker run -d --name jaeger \ -p 16686:16686 \ -p 4317:4317 \ jaegertracing/all-in-one:latest
-
Uncomment the OTLP exporter in Program.cs
-
Run the sample and visit http://localhost:16686
{
"Xavier": {
"Observability": {
"Enabled": true,
"ServiceName": "MyApi",
"ServiceVersion": "1.0.0",
"EnableTracing": true,
"EnableMetrics": true,
"EnableRuntimeMetrics": true
}
}
}- Exporters must be added via
ConfigureTracing/ConfigureMetricscallbacks - Xavier does NOT read exporter config from appsettings.json
- This is intentional to avoid forcing dependencies on specific exporters