MODULE 12 · LESSON 12.1
Trace a complete request
Trace one request across agents, models and business tools.
Lesson 68 of 86 · FabrCore 2.0
Overview
W3C trace context ties messages, events and child operations together. OpenTelemetry exports the activity tree; the monitor provides a different retained/queryable view. Child work should inherit causal context without reusing the parent's span ID.
Trace context connects work across boundaries
A trace identifies the overall request and spans identify individual operations within it. A child tool/database call should retain the causal trace while receiving its own span identity. FabrCore's ActivitySources/meters must be registered with the exporter before the viewer can display them. Application-specific work can add child Activity spans.
A trace and a monitor answer different questions
OpenTelemetry exports causal timing and diagnostics to your chosen backend. Retained monitoring provides queryable message/model records with its own retention and coverage. Missing data can mean an unregistered source, sampling, exporter failure or a different silo, not that the operation never ran. Use the request ID and timing to correlate these views.
Trace one investigation
- Register the documented FabrCore ActivitySources/meters with an OpenTelemetry exporter and optional Aspire development viewer.
- Stamp/propagate message trace context through the supported helpers. Create child Activity spans for application-specific HTTP or database operations.
- Run SR-1042 through the assistant and a specialist, then inspect the parent/child relationships and model attribution.
// In your Program.cs, after AddFabrCoreServer:
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddSource("FabrCore.*") // pick up every FabrCore ActivitySource
.AddHttpClientInstrumentation() // optional but recommended
.AddAspNetCoreInstrumentation() // optional for server
.AddOtlpExporter(o => // OR .AddJaegerExporter() / .AddConsoleExporter()
{
o.Endpoint = new Uri("http://localhost:4317");
}))
.WithMetrics(metrics => metrics
.AddMeter("FabrCore.*") // FabrCore meters (Host.Extensions, Host grains, SDK, ...)
.AddOtlpExporter());
public class MyAgent : FabrCoreAgentProxy
{
private static readonly ActivitySource Source = new("MyCompany.MyAgent");
public override async Task<AgentMessage> OnMessage(AgentMessage message)
{
using var activity = Source.StartActivity("search-docs");
activity?.SetTag("query.length", message.Message?.Length ?? 0);
var result = await DoTheWork(message);
var response = message.Response();
response.Message = result;
// Grain will StampFromActivity before returning to the caller; optional here.
return response;
}
}
Find the parent and child operations
- Send one recognizable SR-1042 investigation through an agent and read-only tool with the configured exporter enabled. Locate its trace in the viewer.
- Expand the trace and identify ingress, agent/model work and your instrumented application call. Child operations should have related trace context and distinct span IDs.
- Make the fixture tool fail and repeat. Verify the failing operation is attributable to the right span rather than appearing as an unrelated request or disappearing silently.
The useful result is a causal explanation of time and failure. Tracing does not replace business outcome checks or prove signed evidence integrity.
If the result is different
Missing exporter/source registration can hide valid activities. Do not copy SpanId into a response as though it were a new span.
Go deeper
Explore the related documentation.