Skip to content

Commit b0b5b95

Browse files
committed
Added UpdateSettingsWhenIdleInterval to allow the configuration to always be up-to-date.
1 parent d57723e commit b0b5b95

File tree

6 files changed

+25
-48
lines changed

6 files changed

+25
-48
lines changed

Source/Shared/Configuration/ExceptionlessConfiguration.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class ExceptionlessConfiguration {
2222
private string _serverUrl;
2323
private int _submissionBatchSize;
2424
private ValidationResult _validationResult;
25+
private TimeSpan _updateSettingsWhenIdleInterval;
2526
private readonly List<string> _exclusions = new List<string>();
2627
private readonly List<string> _userAgentBotPatterns = new List<string>();
2728
private readonly List<Func<Event, bool>> _eventExclusions = new List<Func<Event, bool>>();
@@ -41,6 +42,7 @@ public ExceptionlessConfiguration(IDependencyResolver resolver) {
4142
DefaultData = new DataDictionary();
4243
Settings = new SettingsDictionary();
4344
IncludePrivateInformation = true;
45+
_updateSettingsWhenIdleInterval = TimeSpan.FromMinutes(2);
4446

4547
_resolver = resolver;
4648

@@ -152,6 +154,21 @@ public string ApiKey {
152154
/// </summary>
153155
public SettingsDictionary Settings { get; private set; }
154156

157+
/// <summary>
158+
/// How often the client should check for updated server settings when idle. The default is every 2 minutes.
159+
/// </summary>
160+
public TimeSpan UpdateSettingsWhenIdleInterval {
161+
get { return _updateSettingsWhenIdleInterval; }
162+
set {
163+
if (value > TimeSpan.Zero && value < TimeSpan.FromSeconds(15))
164+
_updateSettingsWhenIdleInterval = TimeSpan.FromSeconds(15);
165+
else if (value <= TimeSpan.Zero)
166+
_updateSettingsWhenIdleInterval = TimeSpan.FromMilliseconds(-1);
167+
else
168+
_updateSettingsWhenIdleInterval = value;
169+
}
170+
}
171+
155172
/// <summary>
156173
/// Gets or sets a value indicating whether to include private information about the local machine.
157174
/// </summary>

Source/Shared/Exceptionless.Portable.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
<Compile Include="Plugins\Default\050_EnvironmentInfoPlugin.cs" />
7777
<Compile Include="Plugins\Default\005_HandleAggregateExceptionsPlugin.cs" />
7878
<Compile Include="Plugins\Default\010_EventExclusionPlugin.cs" />
79-
<Compile Include="Plugins\Default\1020_UpdateConfigurationSettingsWhileIdlePlugin.cs" />
8079
<Compile Include="Plugins\PriortyAttribute.cs" />
8180
<Compile Include="EventBuilder.cs" />
8281
<Compile Include="Events\ConfigurationUpdatedEventArgs.cs" />

Source/Shared/ExceptionlessClient.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
2+
using System.Threading;
23
using System.Threading.Tasks;
4+
using Exceptionless.Configuration;
35
using Exceptionless.Dependency;
46
using Exceptionless.Plugins;
57
using Exceptionless.Logging;
@@ -10,6 +12,7 @@
1012

1113
namespace Exceptionless {
1214
public class ExceptionlessClient : IDisposable {
15+
private readonly Timer _updateSettingsTimer;
1316
private readonly Lazy<IExceptionlessLog> _log;
1417
private readonly Lazy<IEventQueue> _queue;
1518
private readonly Lazy<ISubmissionClient> _submissionClient;
@@ -41,6 +44,9 @@ public ExceptionlessClient(ExceptionlessConfiguration configuration) {
4144

4245
_submissionClient = new Lazy<ISubmissionClient>(() => Configuration.Resolver.GetSubmissionClient());
4346
_lastReferenceIdManager = new Lazy<ILastReferenceIdManager>(() => Configuration.Resolver.GetLastReferenceIdManager());
47+
48+
var initialDelay = configuration.UpdateSettingsWhenIdleInterval > TimeSpan.Zero ? TimeSpan.FromSeconds(5) : TimeSpan.FromMilliseconds(-1);
49+
_updateSettingsTimer = new Timer(state => SettingsManager.UpdateSettings(Configuration), null, initialDelay, configuration.UpdateSettingsWhenIdleInterval);
4450
}
4551

4652
public ExceptionlessConfiguration Configuration { get; private set; }
@@ -175,6 +181,7 @@ public void SubmitEvent(Event ev, ContextData pluginContextData = null) {
175181
}
176182

177183
OnSubmittedEvent(new EventSubmittedEventArgs(this, ev, pluginContextData));
184+
_updateSettingsTimer.Change(Configuration.UpdateSettingsWhenIdleInterval, Configuration.UpdateSettingsWhenIdleInterval);
178185
}
179186

180187
/// <summary>Creates a new instance of <see cref="Event" />.</summary>

Source/Shared/Plugins/Default/1020_UpdateConfigurationSettingsWhileIdlePlugin.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.

Source/Shared/Plugins/EventPluginManager.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public static void AddDefaultPlugins(ExceptionlessConfiguration config) {
3232
config.AddPlugin<EnvironmentInfoPlugin>();
3333
config.AddPlugin<SubmissionMethodPlugin>();
3434
config.AddPlugin<CancelSessionsWithNoUserPlugin>();
35-
config.AddPlugin<UpdateConfigurationSettingsWhileIdlePlugin>(new UpdateConfigurationSettingsWhileIdlePlugin(config));
3635
}
3736
}
3837
}

Source/Shared/Queue/DefaultEventQueue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ public void Process() {
5252
if (_processingQueue)
5353
return;
5454

55-
_log.Trace(typeof(DefaultEventQueue), "Processing queue...");
5655
if (!_config.Enabled) {
5756
_log.Info(typeof(DefaultEventQueue), "Configuration is disabled. The queue will not be processed.");
5857
return;
5958
}
6059

60+
_log.Trace(typeof(DefaultEventQueue), "Processing queue...");
6161
_processingQueue = true;
6262

6363
try {

0 commit comments

Comments
 (0)