Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.

Commit 6f6cdec

Browse files
authored
feat: adds warning log if excessive StartWaitTime is used. (#218)
1 parent f01a54d commit 6f6cdec

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pkgs/sdk/server/src/LdClient.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ public sealed class LdClient : IDisposable, ILdClient
4343
private readonly Logger _evalLog;
4444
private readonly IHookExecutor _hookExecutor;
4545

46+
private readonly TimeSpan ExcessiveInitWaitTime = TimeSpan.FromSeconds(60);
47+
private const String InitWaitTimeInfo = "Waiting up to {0} milliseconds for LaunchDarkly client to start.";
48+
private const String ExcessiveInitWaitTimeWarning =
49+
"LaunchDarkly client created with StartWaitTime of {0} milliseconds. We recommend a timeout of less than {1} milliseconds.";
50+
private const String DidNotInitializeTimelyWarning = "Client did not initialize within {0} milliseconds.";
51+
4652
#endregion
4753

4854
#region Public properties
@@ -205,8 +211,11 @@ public LdClient(Configuration config)
205211

206212
if (!(_dataSource is ComponentsImpl.NullDataSource))
207213
{
208-
_log.Info("Waiting up to {0} milliseconds for LaunchDarkly client to start...",
209-
_configuration.StartWaitTime.TotalMilliseconds);
214+
_log.Info(InitWaitTimeInfo, _configuration.StartWaitTime.TotalMilliseconds);
215+
if (_configuration.StartWaitTime >= ExcessiveInitWaitTime)
216+
{
217+
_log.Warn(ExcessiveInitWaitTimeWarning, _configuration.StartWaitTime.TotalMilliseconds, ExcessiveInitWaitTime.TotalMilliseconds);
218+
}
210219
}
211220

212221
try

0 commit comments

Comments
 (0)