< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Diagnostics.DiagnosticsFunctionInvocationExtensions
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Diagnostics/DiagnosticsFunctionInvocationExtensions.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 39
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
UseDiagnosticsFunctionInvocation(...)100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Diagnostics/DiagnosticsFunctionInvocationExtensions.cs

#LineLine coverage
 1using Microsoft.Extensions.AI;
 2
 3using NexusLabs.Needlr.AgentFramework.Progress;
 4
 5namespace NexusLabs.Needlr.AgentFramework.Diagnostics;
 6
 7/// <summary>
 8/// Extension methods for wiring <see cref="DiagnosticsFunctionInvokingChatClient"/>
 9/// into an MEAI chat client pipeline.
 10/// </summary>
 11public static class DiagnosticsFunctionInvocationExtensions
 12{
 13    /// <summary>
 14    /// Inserts a <see cref="DiagnosticsFunctionInvokingChatClient"/> into the pipeline
 15    /// that records per-tool-call diagnostics, OTel metrics, and Activity spans.
 16    /// </summary>
 17    /// <remarks>
 18    /// <para>
 19    /// This replaces the standard <c>UseFunctionInvocation()</c> call. Do not use both —
 20    /// it would create two <c>FunctionInvokingChatClient</c> layers and produce
 21    /// duplicate tool calls.
 22    /// </para>
 23    /// </remarks>
 24    /// <param name="builder">The chat client builder.</param>
 25    /// <param name="metrics">Optional OTel metrics recorder.</param>
 26    /// <param name="progressAccessor">Optional progress reporter for real-time events.</param>
 27    /// <returns>The builder, for chaining.</returns>
 28    public static ChatClientBuilder UseDiagnosticsFunctionInvocation(
 29        this ChatClientBuilder builder,
 30        IAgentMetrics? metrics = null,
 31        IProgressReporterAccessor? progressAccessor = null)
 32    {
 133        ArgumentNullException.ThrowIfNull(builder);
 34
 135        return builder.Use(innerClient =>
 236            new DiagnosticsFunctionInvokingChatClient(
 237                innerClient, metrics, progressAccessor));
 38    }
 39}