< Summary

Information
Class: NexusLabs.Needlr.AgentFramework.Langfuse.LangfuseScoreTarget
Assembly: NexusLabs.Needlr.AgentFramework.Langfuse
File(s): /home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Langfuse/LangfuseScoreTarget.cs
Line coverage
93%
Covered lines: 15
Uncovered lines: 1
Coverable lines: 16
Total lines: 58
Line coverage: 93.7%
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_TraceId()100%11100%
get_ObservationId()100%11100%
get_SessionId()100%11100%
get_ContextId()100%210%
Trace(...)100%11100%
Observation(...)100%11100%
Session(...)100%11100%

File(s)

/home/runner/work/needlr/needlr/src/NexusLabs.Needlr.AgentFramework.Langfuse/LangfuseScoreTarget.cs

#LineLine coverage
 1namespace NexusLabs.Needlr.AgentFramework.Langfuse;
 2
 3/// <summary>
 4/// Identifies the Langfuse object a score is attached to. Langfuse supports scoring a trace, a
 5/// specific observation within a trace, or a whole session (a score may also target a dataset run,
 6/// which the experiment path handles separately).
 7/// </summary>
 8internal readonly record struct LangfuseScoreTarget
 9{
 10    private LangfuseScoreTarget(string? traceId, string? observationId, string? sessionId, string contextId)
 11    {
 1112        TraceId = traceId;
 1113        ObservationId = observationId;
 1114        SessionId = sessionId;
 1115        ContextId = contextId;
 1116    }
 17
 18    /// <summary>Gets the trace id, or <see langword="null"/> for a session-only score.</summary>
 1319    public string? TraceId { get; }
 20
 21    /// <summary>Gets the observation id, or <see langword="null"/>.</summary>
 1122    public string? ObservationId { get; }
 23
 24    /// <summary>Gets the session id, or <see langword="null"/>.</summary>
 1125    public string? SessionId { get; }
 26
 27    /// <summary>Gets a human-readable id used in diagnostics when a score upload fails.</summary>
 028    public string ContextId { get; }
 29
 30    /// <summary>Targets an entire trace.</summary>
 31    /// <param name="traceId">The trace id.</param>
 32    /// <returns>A trace-level target.</returns>
 33    public static LangfuseScoreTarget Trace(string traceId)
 34    {
 835        ArgumentException.ThrowIfNullOrWhiteSpace(traceId);
 836        return new LangfuseScoreTarget(traceId, observationId: null, sessionId: null, traceId);
 37    }
 38
 39    /// <summary>Targets a specific observation within a trace.</summary>
 40    /// <param name="traceId">The owning trace id.</param>
 41    /// <param name="observationId">The observation id.</param>
 42    /// <returns>An observation-level target.</returns>
 43    public static LangfuseScoreTarget Observation(string traceId, string observationId)
 44    {
 145        ArgumentException.ThrowIfNullOrWhiteSpace(traceId);
 146        ArgumentException.ThrowIfNullOrWhiteSpace(observationId);
 147        return new LangfuseScoreTarget(traceId, observationId, sessionId: null, observationId);
 48    }
 49
 50    /// <summary>Targets a whole session.</summary>
 51    /// <param name="sessionId">The session id.</param>
 52    /// <returns>A session-level target.</returns>
 53    public static LangfuseScoreTarget Session(string sessionId)
 54    {
 255        ArgumentException.ThrowIfNullOrWhiteSpace(sessionId);
 256        return new LangfuseScoreTarget(traceId: null, observationId: null, sessionId, sessionId);
 57    }
 58}