private async Task FetchRemoteSettingsAsync()

in src/ServiceProfiler.EventPipe.Otel/Microsoft.ApplicationInsights.Profiler.Shared/Orchestrations/RemoteSettingsServiceBase.cs [65:106]


    private async Task FetchRemoteSettingsAsync(CancellationToken cancellationToken)
    {
        using IDisposable internalZoneHandler = EnterInternalZone();
        try
        {
            _logger.LogTrace("Fetching remote settings.");
            SettingsContract newContract = await _frontendClient.GetProfilerSettingsAsync(cancellationToken).ConfigureAwait(false);
            if (newContract != null)
            {
                _logger.LogTrace("Remote settings fetched.");
                // New settings coming.
                OnSettingsUpdated(newContract);
            }
            else
            {
                _logger.LogTrace("No settings contract fetched.");
            }
        }
        catch (InstrumentationKeyInvalidException ikie)
        {
            _logger.LogError(ikie.Message);
            _logger.LogTrace(ikie.ToString());
        }
        catch (Exception ex) when (string.Equals(ex.Message, "Invalid instrumentation key format or instrumentation key has been revoked.", StringComparison.Ordinal))
        {
            _logger.LogError(ex.Message);
            _logger.LogTrace(ex.ToString());
        }
#pragma warning disable CA1031 // Only to allow for getting the value for the next iteration. The exception will be logged.
        catch (Exception ex)
#pragma warning restore CA1031 // Only to allow for getting the value for the next iteration. The exception will be logged.
        {
            // Move on for the next iteration.
            _logger.LogDebug("Unexpected error contacting service profiler service endpoint for settings. Details: {details}", ex);
            _logger.LogTrace("Error with trace: {error}", ex.ToString());
        }
        finally
        {
            // Either way, initialization is done.
            _taskCompletionSource.TrySetResult(true);
        }
    }