< Summary

Information
Class: Services.SystemMonitoringServices.SystemMonitoringSignalWriter
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/SystemMonitoringServices/SystemMonitoringSignalWriter.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 39
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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%
RecordAsync()100%44100%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/SystemMonitoringServices/SystemMonitoringSignalWriter.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.Extensions.Logging;
 3using OzonDomains.Models;
 4using OzonRepositories.Context;
 5
 6namespace Services.SystemMonitoringServices;
 7
 8public interface ISystemMonitoringSignalWriter
 9{
 10    Task RecordAsync(string sourceKey, string outcome, string? scopeKey = null, string? message = null, CancellationToke
 11}
 12
 13/// <summary>Пассивная телеметрия интеграций. Сообщения намеренно ограничены и не предназначены для payload/секретов.</s
 1214public sealed class SystemMonitoringSignalWriter(
 1215    ApplicationDbContext context,
 1216    ILogger<SystemMonitoringSignalWriter> logger) : ISystemMonitoringSignalWriter
 17{
 18    public async Task RecordAsync(string sourceKey, string outcome, string? scopeKey = null, string? message = null, Can
 19    {
 1420        var signal = new SystemMonitoringSignal
 1421        {
 1422            SourceKey = sourceKey[..Math.Min(sourceKey.Length, 100)],
 1423            Outcome = outcome[..Math.Min(outcome.Length, 16)],
 1424            ScopeKey = scopeKey?[..Math.Min(scopeKey.Length, 120)],
 1425            Message = message?[..Math.Min(message.Length, 500)]
 1426        };
 27
 28        try
 29        {
 1430            context.SystemMonitoringSignals.Add(signal);
 1431            await context.SaveChangesAsync(cancellationToken);
 1232        }
 233        catch (Exception ex) when (!cancellationToken.IsCancellationRequested)
 34        {
 135            context.Entry(signal).State = EntityState.Detached;
 136            logger.LogWarning(ex, "Не удалось записать пассивный сигнал {SourceKey}", sourceKey);
 137        }
 1338    }
 39}