Telemetry
Telemetry
FabrCore includes comprehensive OpenTelemetry instrumentation across server and client packages for full observability of your AI agent systems.
OpenTelemetry Setup
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddSource("FabrCore.Sdk.*")
.AddSource("FabrCore.Host.*")
.AddSource("FabrCore.Client.*"))
.WithMetrics(metrics => metrics
.AddMeter("FabrCore.Sdk.*")
.AddMeter("FabrCore.Host.*")
.AddMeter("FabrCore.Client.*"));
Metrics
Server Metrics
WebSocket (FabrCore.Host.WebSocket)
| Metric | Type | Description |
|---|---|---|
fabrcore.websocket.connections.accepted | Counter | WebSocket connections accepted |
fabrcore.websocket.connections.rejected | Counter | WebSocket connections rejected |
fabrcore.websocket.sessions.created | Counter | WebSocket sessions created |
fabrcore.websocket.messages.received | Counter | Messages received via WebSocket |
fabrcore.websocket.messages.sent | Counter | Messages sent via WebSocket |
Agent Grain (FabrCore.Host.AgentGrain)
| Metric | Type | Description |
|---|---|---|
fabrcore.agent.configured | Counter | Agents configured |
fabrcore.agent.messages.processed | Counter | Messages processed |
fabrcore.agent.message.duration | Histogram | Message processing duration |
fabrcore.agent.errors | Counter | Errors by type |
SDK (FabrCore.Sdk.FabrCoreAgentProxy)
| Metric | Type | Description |
|---|---|---|
fabrcore.sdk.agent_proxy.initialized | Counter | Agents initialized |
fabrcore.sdk.agent_proxy.message.duration | Histogram | Message processing time |
fabrcore.sdk.agent_proxy.errors | Counter | Error count by type |
Client Metrics
Connection (FabrCore.Client.Connection)
| Metric | Type | Description |
|---|---|---|
fabrcore.client.connection.retries | Counter | Connection retry attempts |
fabrcore.client.connection.success | Counter | Successful connections |
fabrcore.client.connection.failures | Counter | Failed connections |
API Client (FabrCore.Client.FabrHostApiClient)
| Metric | Type | Description |
|---|---|---|
fabrcore.api_client.requests | Counter | API requests made |
fabrcore.api_client.errors | Counter | API errors |
fabrcore.api_client.request.duration | Histogram | API request duration |
Client Agent Proxy (FabrCore.Client.FabrCoreClientAgentProxy)
| Metric | Type | Description |
|---|---|---|
fabrcore.client.agent_proxy.initialized | Counter | Agent proxy initializations |
fabrcore.client.agent_proxy.messages.processed | Counter | Messages processed |
fabrcore.client.agent_proxy.message.duration | Histogram | Message processing time |
fabrcore.client.agent_proxy.errors | Counter | Agent proxy errors |
Distributed Tracing
Activity Sources
| Source | Operations |
|---|---|
FabrCore.Sdk.FabrCoreAgentProxy | Initialize, OnMessage, OnEvent, GetHealth, FlushState |
FabrCore.Sdk.FabrCoreChatClientService | GetChatClient, FetchModelConfig, FetchApiKey |
FabrCore.Client.ClientContext | Context operations |
FabrCore.Client.ClientContextFactory | Factory operations |
FabrCore.Client.DirectMessageSender | Direct messaging operations |
FabrCore.Client.FabrCoreClientAgentProxy | Agent proxy operations |
FabrCore.Client.Extensions | Client configuration and setup |
FabrCore.Client.Connection | Orleans connection lifecycle |
FabrCore.Client.FabrHostApiClient | HTTP API client operations |
Structured Logging
Use the built-in logger in your agents for structured logging that integrates with OpenTelemetry:
public override async Task<AgentMessage> OnMessage(AgentMessage message)
{
logger.LogInformation(
"Processing message from {FromHandle}",
message.FromHandle);
try
{
// Process message
}
catch (Exception ex)
{
logger.LogError(ex,
"Error processing message {MessageId}",
message.Id);
throw;
}
}
FabrCore propagates TraceId across agent boundaries via the AgentMessage.TraceId property. This enables end-to-end distributed tracing across multi-agent workflows.
Tool Invocation Logging
Use Microsoft.Extensions.AI's UseLogging() middleware to capture tool invocations, arguments, and results through the standard ILogger pipeline:
var chatClient = new ChatClientBuilder(innerClient)
.UseLogging(loggerFactory)
.Build();
This logs tool names, arguments, results, and duration through your existing logging infrastructure — no custom log aggregation agents needed. Combine with your observability stack (Application Insights, Seq, ELK, Grafana) for production monitoring.
Health Endpoints
FabrCore exposes diagnostics endpoints for monitoring. Combine these with ASP.NET Core health checks for Kubernetes probes and alerting:
| Endpoint | Returns |
|---|---|
GET /fabrcoreapi/diagnostics/agents | All registered agents with status |
GET /fabrcoreapi/diagnostics/agents/statistics | Total, active, deactivated counts |
GET /fabrcoreapi/discovery | Available agents, plugins, and tools |
GET /fabrapi/Agent/health/{handle} | Per-agent health (Basic, Detailed, Full) |
ASP.NET Core Health Check Integration
// Register health checks that query FabrCore diagnostics
builder.Services.AddHealthChecks()
.AddCheck<FabrCoreAgentHealthCheck>("fabrcore-agents");
var app = builder.Build();
// Map the standard health endpoint
app.MapHealthChecks("/health");
This integrates with Kubernetes liveness/readiness probes, Azure App Service health checks, and standard monitoring infrastructure.
LLM Token Tracking
FabrCore automatically tracks LLM token usage across all agent interactions through the monitoring system. The TokenTrackingChatClient wraps chat client calls to capture input and output token counts, while LlmUsageScope aggregates usage across multiple LLM calls within a single message processing cycle.
Token counts are automatically attached to agent response messages via Args (e.g., _tokens_input, _tokens_output, _llm_calls), making usage data available to clients without additional configuration.
See full token tracking documentation in the Monitoring guide for details on configuring token tracking, building custom usage dashboards, and integrating with cost monitoring systems.