< Summary

Information
Class: Elsa.Diagnostics.ConsoleLogs.Services.ElsaConsoleLogOptions
Assembly: Elsa.Diagnostics.ConsoleLogs
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.ConsoleLogs/Services/ElsaConsoleLogOptions.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 31
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ConfigureDefaults(...)75%44100%
SetMetadata(...)100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Diagnostics.ConsoleLogs/Services/ElsaConsoleLogOptions.cs

#LineLine coverage
 1using ConsoleLogStreaming.Core.Options;
 2
 3namespace Elsa.Diagnostics.ConsoleLogs.Services;
 4
 5internal static class ElsaConsoleLogOptions
 6{
 7    public static void ConfigureDefaults(ConsoleLogOptions options)
 8    {
 109        var sourceId = $"{Environment.MachineName}-{Environment.ProcessId}";
 1010        var podName = Environment.GetEnvironmentVariable("HOSTNAME");
 11
 1012        options.SourceId = sourceId;
 1013        options.SourceDisplayName = !string.IsNullOrWhiteSpace(podName) ? podName : sourceId;
 1014        options.ServiceName = Environment.GetEnvironmentVariable("OTEL_SERVICE_NAME") ?? AppDomain.CurrentDomain.Friendl
 1015        options.PreserveAnsi = true;
 1016        options.RecentCapacity = 2_000;
 1017        options.MaxRecentQuerySize = 250;
 18
 1019        SetMetadata(options, "kubernetes.pod.name", podName);
 1020        SetMetadata(options, "kubernetes.namespace.name", Environment.GetEnvironmentVariable("POD_NAMESPACE"));
 1021        SetMetadata(options, "container.name", Environment.GetEnvironmentVariable("CONTAINER_NAME"));
 1022        SetMetadata(options, "kubernetes.node.name", Environment.GetEnvironmentVariable("NODE_NAME"));
 1023        SetMetadata(options, "process.started_at", DateTimeOffset.UtcNow.ToString("O"));
 1024    }
 25
 26    private static void SetMetadata(ConsoleLogOptions options, string key, string? value)
 27    {
 5028        if (!string.IsNullOrWhiteSpace(value))
 1029            options.SourceMetadata[key] = value;
 5030    }
 31}