private static TraceConfig TryLoadTraceConfig(IConfiguration configuration) { var isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); var traceConfig = isLinux ? TraceConfig.CreateDefaultForLinux() : TraceConfig.CreateDefaultForWindows(); var tracerSection = configuration.GetSection("Tracer"); if (tracerSection != null) { ////not use this to process nullable props //var config = tracerSection.Get<TraceConfig>(); var traceSaveProcessEnabled = tracerSection.GetValue <bool?>("TraceSaveProcessEnabled", null); if (traceSaveProcessEnabled != null) { traceConfig.TraceSaveProcessEnabled = traceSaveProcessEnabled.Value; } var traceSendProcessEnabled = tracerSection.GetValue <bool?>("TraceSendProcessEnabled", null); if (traceSendProcessEnabled != null) { traceConfig.TraceSendProcessEnabled = traceSendProcessEnabled.Value; } var traceEndPoint = tracerSection.GetValue <string>("TraceEndPoint", null); if (!string.IsNullOrWhiteSpace(traceEndPoint)) { traceConfig.TraceEndPoint = traceEndPoint.Trim(); } var defaultTracerId = tracerSection.GetValue <string>("DefaultTracerId", null); if (!string.IsNullOrWhiteSpace(defaultTracerId)) { traceConfig.DefaultTracerId = defaultTracerId.Trim(); } var flushIntervalSecond = tracerSection.GetValue <int?>("FlushIntervalSecond", null); if (flushIntervalSecond != null) { traceConfig.FlushIntervalSecond = flushIntervalSecond.Value; } var traceArchiveFolder = tracerSection.GetValue <string>("TraceArchiveFolder", null); if (!string.IsNullOrWhiteSpace(traceArchiveFolder)) { traceConfig.TraceArchiveFolder = traceArchiveFolder.Trim(); } } return(traceConfig); }