From 6f6cdec155fd46bcfc17ce18246e760c456adbaf Mon Sep 17 00:00:00 2001 From: Todd Anderson <127344469+tanderson-ld@users.noreply.github.com> Date: Fri, 10 May 2024 11:41:45 -0500 Subject: [PATCH] feat: adds warning log if excessive StartWaitTime is used. (#218) --- pkgs/sdk/server/src/LdClient.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkgs/sdk/server/src/LdClient.cs b/pkgs/sdk/server/src/LdClient.cs index 34518685..3ae3f722 100644 --- a/pkgs/sdk/server/src/LdClient.cs +++ b/pkgs/sdk/server/src/LdClient.cs @@ -43,6 +43,12 @@ public sealed class LdClient : IDisposable, ILdClient private readonly Logger _evalLog; private readonly IHookExecutor _hookExecutor; + private readonly TimeSpan ExcessiveInitWaitTime = TimeSpan.FromSeconds(60); + private const String InitWaitTimeInfo = "Waiting up to {0} milliseconds for LaunchDarkly client to start."; + private const String ExcessiveInitWaitTimeWarning = + "LaunchDarkly client created with StartWaitTime of {0} milliseconds. We recommend a timeout of less than {1} milliseconds."; + private const String DidNotInitializeTimelyWarning = "Client did not initialize within {0} milliseconds."; + #endregion #region Public properties @@ -205,8 +211,11 @@ public LdClient(Configuration config) if (!(_dataSource is ComponentsImpl.NullDataSource)) { - _log.Info("Waiting up to {0} milliseconds for LaunchDarkly client to start...", - _configuration.StartWaitTime.TotalMilliseconds); + _log.Info(InitWaitTimeInfo, _configuration.StartWaitTime.TotalMilliseconds); + if (_configuration.StartWaitTime >= ExcessiveInitWaitTime) + { + _log.Warn(ExcessiveInitWaitTimeWarning, _configuration.StartWaitTime.TotalMilliseconds, ExcessiveInitWaitTime.TotalMilliseconds); + } } try