| | | 1 | | using ConsoleLogStreaming.Core.Options; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Diagnostics.ConsoleLogs.Services; |
| | | 4 | | |
| | | 5 | | internal static class ElsaConsoleLogOptions |
| | | 6 | | { |
| | | 7 | | public static void ConfigureDefaults(ConsoleLogOptions options) |
| | | 8 | | { |
| | 10 | 9 | | var sourceId = $"{Environment.MachineName}-{Environment.ProcessId}"; |
| | 10 | 10 | | var podName = Environment.GetEnvironmentVariable("HOSTNAME"); |
| | | 11 | | |
| | 10 | 12 | | options.SourceId = sourceId; |
| | 10 | 13 | | options.SourceDisplayName = !string.IsNullOrWhiteSpace(podName) ? podName : sourceId; |
| | 10 | 14 | | options.ServiceName = Environment.GetEnvironmentVariable("OTEL_SERVICE_NAME") ?? AppDomain.CurrentDomain.Friendl |
| | 10 | 15 | | options.PreserveAnsi = true; |
| | 10 | 16 | | options.RecentCapacity = 2_000; |
| | 10 | 17 | | options.MaxRecentQuerySize = 250; |
| | | 18 | | |
| | 10 | 19 | | SetMetadata(options, "kubernetes.pod.name", podName); |
| | 10 | 20 | | SetMetadata(options, "kubernetes.namespace.name", Environment.GetEnvironmentVariable("POD_NAMESPACE")); |
| | 10 | 21 | | SetMetadata(options, "container.name", Environment.GetEnvironmentVariable("CONTAINER_NAME")); |
| | 10 | 22 | | SetMetadata(options, "kubernetes.node.name", Environment.GetEnvironmentVariable("NODE_NAME")); |
| | 10 | 23 | | SetMetadata(options, "process.started_at", DateTimeOffset.UtcNow.ToString("O")); |
| | 10 | 24 | | } |
| | | 25 | | |
| | | 26 | | private static void SetMetadata(ConsoleLogOptions options, string key, string? value) |
| | | 27 | | { |
| | 50 | 28 | | if (!string.IsNullOrWhiteSpace(value)) |
| | 10 | 29 | | options.SourceMetadata[key] = value; |
| | 50 | 30 | | } |
| | | 31 | | } |