Skip to content

Commit

Permalink
Add additional condition before requesting update. (#3095)
Browse files Browse the repository at this point in the history
* Add additional condition before requesting update.

* Add try catch in case telemetry methods throw.

* fix indent

---------

Co-authored-by: Brent Schmaltz <[email protected]>
Co-authored-by: id4s <[email protected]>
  • Loading branch information
3 people authored Jan 16, 2025
1 parent 9e91a64 commit 0108a96
Showing 1 changed file with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,41 @@ public virtual async Task<T> GetConfigurationAsync(CancellationToken cancel)
{
if (_refreshRequested)
{
// Log as manual because RequestRefresh was called
TelemetryClient.IncrementConfigurationRefreshRequestCounter(
MetadataAddress,
TelemetryConstants.Protocols.Manual);
_refreshRequested = false;

try
{
// Log as manual because RequestRefresh was called
TelemetryClient.IncrementConfigurationRefreshRequestCounter(
MetadataAddress,
TelemetryConstants.Protocols.Manual);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
{ }
#pragma warning restore CA1031 // Do not catch general exception types

UpdateCurrentConfiguration();
_refreshRequested = false;
}
else
else if (SyncAfter <= _timeProvider.GetUtcNow())
{
TelemetryClient.IncrementConfigurationRefreshRequestCounter(
MetadataAddress,
TelemetryConstants.Protocols.Automatic);
try
{
TelemetryClient.IncrementConfigurationRefreshRequestCounter(
MetadataAddress,
TelemetryConstants.Protocols.Automatic);
}
#pragma warning disable CA1031 // Do not catch general exception types
catch
{ }
#pragma warning restore CA1031 // Do not catch general exception types

_ = Task.Run(UpdateCurrentConfiguration, CancellationToken.None);
}
else
{
Interlocked.Exchange(ref _configurationRetrieverState, ConfigurationRetrieverIdle);
}
}
}

Expand Down

0 comments on commit 0108a96

Please sign in to comment.