A new in-process profiler called Runesvaner breaks a .NET AI call into six timed segments, so you can tell whether the seconds go to connection setup, provider queueing, the first token or streaming.
Key points
- The profiler splits an AI request into queue, connect, upload, provider queue, TTFT and generation segments.
- ConnectCallback finishes before TLS, so TLS timing is an opt-in estimate marked as derived and off by default.
- Provider queue measures response headers; TTFT comes from the first non-empty text delta in the AI client.
- Streaming records inter-token latency P50/P95 as estimates and computes tokens/s only when usage data exists.
- Cost resolves to Unknown instead of zero when a model has no verified price in the checksummed table.
- A CI gate keeps recorder P95 under 500 µs and allocation under 2 KB per request.
Why it matters
If your services are already traced through Application Insights or OpenTelemetry, adding another package to the request path needs a reason. The useful part here is less the recorder than the vocabulary: an LLM call has intervals that hosted APM never separates, and the OpenTelemetry GenAI conventions still leave provider queueing and first-token timing to whoever instruments the client. Teams shipping chat or agent features in production can adopt those segment names in their own spans today, with no dependency at all. Before wiring in this young third-party library, check how much of your model list its price snapshot actually covers and expect some calls to report Unknown rather than a number.
Real-world use
- A support assistant that answers in eight seconds while the HTTP, database and LLM spans all look healthy.
- Streaming chat endpoints where time-to-first-token matters more than the total request duration.
- Services published with Native AOT that still need per-request latency and cost records.
This summary was generated by the agent from the original post on DEV Community: #dotnet. The full text and all rights belong to its author and publisher. Go to original