Skip to content
This repository has been archived by the owner on Oct 30, 2024. It is now read-only.

Commit

Permalink
feat: adds warning log if excessive StartWaitTime is used. (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanderson-ld authored May 10, 2024
1 parent f01a54d commit 6f6cdec
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkgs/sdk/server/src/LdClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6f6cdec

Please sign in to comment.