< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
ApplyToObservation(...)100%88100%
BuildDelimitedFilterValue(...)100%66100%
SetObservationMetadata(...)100%22100%

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(
 110    string? HomeTeam = null,
 111    string? AwayTeam = null,
 112    int? RepredictionIndex = null)
 13{
 14    public void ApplyToObservation(Activity? activity)
 15    {
 116        if (activity is null)
 17        {
 118            return;
 19        }
 20
 121        SetObservationMetadata(activity, "homeTeam", HomeTeam);
 122        SetObservationMetadata(activity, "awayTeam", AwayTeam);
 23
 124        if (RepredictionIndex.HasValue)
 25        {
 126            SetObservationMetadata(activity, "repredictionIndex", RepredictionIndex.Value.ToString(CultureInfo.Invariant
 27        }
 28
 129        if (!string.IsNullOrWhiteSpace(HomeTeam) && !string.IsNullOrWhiteSpace(AwayTeam))
 30        {
 131            SetObservationMetadata(activity, "match", $"{HomeTeam} vs {AwayTeam}");
 32        }
 133    }
 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    {
 151        if (string.IsNullOrWhiteSpace(value))
 52        {
 153            return;
 54        }
 55
 156        activity.SetTag($"langfuse.observation.metadata.{key}", value);
 157    }
 58}