< Summary

Information
Class: OpenAiIntegration.PredictionTelemetryMetadata
Assembly: OpenAiIntegration
File(s): /home/runner/work/KicktippAi/KicktippAi/src/OpenAiIntegration/PredictionTelemetryMetadata.cs
Line coverage
38%
Covered lines: 10
Uncovered lines: 16
Coverable lines: 26
Total lines: 58
Line coverage: 38.4%
Branch coverage
37%
Covered branches: 6
Total branches: 16
Branch coverage: 37.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
.ctor(...)100%210%
get_HomeTeam()100%210%
set_HomeTeam(...)100%210%
get_AwayTeam()100%210%
set_AwayTeam(...)100%210%
get_RepredictionIndex()100%210%
set_RepredictionIndex(...)100%210%
ApplyToObservation(...)0%7280%
BuildDelimitedFilterValue(...)100%66100%
SetObservationMetadata(...)0%620%

File(s)

/home/runner/work/KicktippAi/KicktippAi/src/OpenAiIntegration/PredictionTelemetryMetadata.cs

#LineLine coverage
 1using System.Diagnostics;
 2using System.Globalization;
 3
 4namespace OpenAiIntegration;
 5
 6/// <summary>
 7/// Filterable Langfuse metadata for prediction observations.
 8/// </summary>
 19public sealed record PredictionTelemetryMetadata(
 010    string? HomeTeam = null,
 011    string? AwayTeam = null,
 012    int? RepredictionIndex = null)
 13{
 14    public void ApplyToObservation(Activity? activity)
 15    {
 016        if (activity is null)
 17        {
 018            return;
 19        }
 20
 021        SetObservationMetadata(activity, "homeTeam", HomeTeam);
 022        SetObservationMetadata(activity, "awayTeam", AwayTeam);
 23
 024        if (RepredictionIndex.HasValue)
 25        {
 026            SetObservationMetadata(activity, "repredictionIndex", RepredictionIndex.Value.ToString(CultureInfo.Invariant
 27        }
 28
 029        if (!string.IsNullOrWhiteSpace(HomeTeam) && !string.IsNullOrWhiteSpace(AwayTeam))
 30        {
 031            SetObservationMetadata(activity, "match", $"{HomeTeam} vs {AwayTeam}");
 32        }
 033    }
 34
 35    public static string BuildDelimitedFilterValue(IEnumerable<string> values)
 36    {
 137        var normalizedValues = values
 138            .Where(value => !string.IsNullOrWhiteSpace(value))
 139            .Select(value => value.Trim())
 140            .Distinct(StringComparer.Ordinal)
 141            .OrderBy(value => value, StringComparer.Ordinal)
 142            .ToArray();
 43
 144        return normalizedValues.Length == 0
 145            ? string.Empty
 146            : $"|{string.Join("|", normalizedValues)}|";
 47    }
 48
 49    private static void SetObservationMetadata(Activity activity, string key, string? value)
 50    {
 051        if (string.IsNullOrWhiteSpace(value))
 52        {
 053            return;
 54        }
 55
 056        activity.SetTag($"langfuse.observation.metadata.{key}", value);
 057    }
 58}