< Summary

Information
Class: Elsa.Diagnostics.StructuredLogs.Providers.InMemory.InMemoryStructuredLogProvider
Assembly: Elsa.Diagnostics.StructuredLogs
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.StructuredLogs/Providers/InMemory/InMemoryStructuredLogProvider.cs
Line coverage
72%
Covered lines: 13
Uncovered lines: 5
Coverable lines: 18
Total lines: 55
Line coverage: 72.2%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
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%
PublishAsync()100%11100%
GetRecentAsync(...)100%11100%
SubscribeAsync()75%44100%
SubscribeWithDroppedEventsAsync(...)100%11100%
ListSourcesAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.StructuredLogs/Providers/InMemory/InMemoryStructuredLogProvider.cs

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2using Elsa.Diagnostics.StructuredLogs.Contracts;
 3using Elsa.Diagnostics.StructuredLogs.Models;
 4using Elsa.Diagnostics.StructuredLogs.Options;
 5using Microsoft.Extensions.Options;
 6
 7namespace Elsa.Diagnostics.StructuredLogs.Providers.InMemory;
 8
 9public class InMemoryStructuredLogProvider : IStructuredLogStreamProvider
 10{
 11    private readonly InMemoryStructuredLogStore _store;
 12    private readonly InMemoryStructuredLogLiveFeed _liveFeed;
 13
 614    public InMemoryStructuredLogProvider(IOptions<StructuredLogsOptions> options, IStructuredLogSourceRegistry sourceReg
 15    {
 616        _store = new(options, sourceRegistry);
 617        _liveFeed = new(options);
 618    }
 19
 020    public InMemoryStructuredLogProvider(InMemoryStructuredLogStore store, InMemoryStructuredLogLiveFeed liveFeed)
 21    {
 022        _store = store;
 023        _liveFeed = liveFeed;
 024    }
 25
 26    public async ValueTask PublishAsync(StructuredLogEvent logEvent, CancellationToken cancellationToken = default)
 27    {
 1528        await _store.WriteAsync(logEvent, cancellationToken);
 1529        await _liveFeed.PublishAsync(logEvent, cancellationToken);
 1530    }
 31
 32    public ValueTask<RecentStructuredLogsResult> GetRecentAsync(StructuredLogFilter filter, CancellationToken cancellati
 33    {
 434        return _store.QueryAsync(filter, cancellationToken);
 35    }
 36
 37    public async IAsyncEnumerable<StructuredLogEvent> SubscribeAsync(StructuredLogFilter filter, [EnumeratorCancellation
 38    {
 339        await foreach (var item in SubscribeWithDroppedEventsAsync(filter, cancellationToken))
 40        {
 141            if (item.LogEvent != null)
 142                yield return item.LogEvent;
 43        }
 144    }
 45
 46    public IAsyncEnumerable<StructuredLogStreamItem> SubscribeWithDroppedEventsAsync(StructuredLogFilter filter, Cancell
 47    {
 248        return _liveFeed.SubscribeAsync(filter, cancellationToken);
 49    }
 50
 51    public ValueTask<IReadOnlyCollection<StructuredLogSource>> ListSourcesAsync(CancellationToken cancellationToken = de
 52    {
 053        return _store.ListSourcesAsync(cancellationToken);
 54    }
 55}