< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Diagnostics.GenAiTokenUsageTags
Assembly: NexusLabs.Needlr.AgentFramework
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework/Diagnostics/GenAiTokenUsageTags.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 41
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
get_OperationName()100%11100%
get_RequestModel()100%11100%
get_ResponseModel()100%11100%
get_ProviderName()100%11100%
get_ServerAddress()100%11100%
get_ServerPort()100%11100%

File(s)

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

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Diagnostics;
 2
 3/// <summary>
 4/// Strongly-typed bag of optional tags attached to a <see cref="IGenAiTokenMetrics.RecordTokenUsage"/>
 5/// measurement. Mirrors the tag schema written by MEAI's
 6/// <see cref="Microsoft.Extensions.AI.OpenTelemetryChatClient"/> on the same
 7/// <c>gen_ai.client.token.usage</c> histogram so the resulting series share a label set
 8/// and aggregate cleanly under a single OpenTelemetry <c>MetricStreamIdentity</c>.
 9/// </summary>
 10/// <remarks>
 11/// <para>
 12/// Any property whose value is <see langword="null"/> is omitted from the recorded measurement.
 13/// This matches MEAI's behaviour, where MEAI also omits tags whose source data is unavailable.
 14/// </para>
 15/// <para>
 16/// <see cref="ServerPort"/> SHOULD be supplied whenever <see cref="ServerAddress"/> is
 17/// supplied, matching MEAI's behaviour of always emitting <c>server.port</c> alongside
 18/// <c>server.address</c> with no scheme-default special-casing.
 19/// </para>
 20/// </remarks>
 21/// <param name="OperationName">
 22/// Value for the <c>gen_ai.operation.name</c> tag, or <see langword="null"/> to use the
 23/// default <c>"chat"</c>. Note: <c>new GenAiTokenUsageTags()</c> (parameterless
 24/// invocation) yields <see langword="null"/> here even though the primary constructor
 25/// declares a default — that is the standard C# record-struct behaviour for the
 26/// implicit parameterless constructor. The implementation substitutes <c>"chat"</c> in
 27/// either case so callers can use <c>default</c>/<c>new GenAiTokenUsageTags()</c>
 28/// without surprise.
 29/// </param>
 30/// <param name="RequestModel">Value for the <c>gen_ai.request.model</c> tag, or <see langword="null"/> to omit.</param>
 31/// <param name="ResponseModel">Value for the <c>gen_ai.response.model</c> tag, or <see langword="null"/> to omit.</para
 32/// <param name="ProviderName">Value for the <c>gen_ai.provider.name</c> tag, or <see langword="null"/> to omit.</param>
 33/// <param name="ServerAddress">Value for the <c>server.address</c> tag, or <see langword="null"/> to omit.</param>
 34/// <param name="ServerPort">Value for the <c>server.port</c> tag, or <see langword="null"/> to omit.</param>
 35public readonly record struct GenAiTokenUsageTags(
 5636    string? OperationName = null,
 3837    string? RequestModel = null,
 5338    string? ResponseModel = null,
 3439    string? ProviderName = null,
 4040    string? ServerAddress = null,
 641    int? ServerPort = null);