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

feat: adds warning log if excessive StartWaitTime is used. #218

Merged
merged 2 commits into from
May 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(15);
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