< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Diagnostics.ToolCallCollectorHolder
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Diagnostics/ToolCallCollectorHolder.cs
Line coverage
83%
Covered lines: 5
Uncovered lines: 1
Coverable lines: 6
Total lines: 33
Line coverage: 83.3%
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
.ctor()100%11100%
get_HasRealCollector()100%210%
SetCollector(...)100%11100%
DrainToolCalls()100%11100%

File(s)

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

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Diagnostics;
 2
 3/// <summary>
 4/// DI-registered singleton that holds the <see cref="IToolCallCollector"/> instance.
 5/// The diagnostics middleware sets the real collector during factory construction; consumers
 6/// resolve this to access it. Unlike a static holder, each DI container has its own instance,
 7/// making it testable and thread-safe across containers.
 8/// </summary>
 9[DoNotAutoRegister]
 10public sealed class ToolCallCollectorHolder : IToolCallCollector
 11{
 8912    private IToolCallCollector _inner = NullToolCallCollector.Instance;
 13
 14    /// <summary>
 15    /// Gets whether a real (non-null) collector has been installed via
 16    /// <see cref="SetCollector"/>. When <see langword="true"/>,
 17    /// <c>UsingDiagnostics()</c> has already wired a diagnostics middleware
 18    /// onto the chat client pipeline and external consumers should not install
 19    /// a duplicate.
 20    /// </summary>
 021    internal bool HasRealCollector => _inner is not NullToolCallCollector;
 22
 23    /// <summary>Sets the real collector. Called by <c>UsingDiagnostics()</c> during factory construction.</summary>
 24    internal void SetCollector(IToolCallCollector collector)
 25    {
 3526        ArgumentNullException.ThrowIfNull(collector);
 3527        _inner = collector;
 3528    }
 29
 30    /// <inheritdoc />
 31    public IReadOnlyList<ToolCallDiagnostics> DrainToolCalls() =>
 2132        _inner.DrainToolCalls();
 33}