Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Octokit check github version config #306

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public sealed class ObserverConstants
public const string EnableFabricObserverOperationalTelemetry = "EnableFabricObserverOperationalTelemetry";
public const string AsyncClusterOperationTimeoutSeconds = "ClusterOperationTimeoutSeconds";
public const string ObserverFailureHealthStateLevelParameter = "ObserverFailureHealthStateLevel";
public const string CheckGithubVersion = "CheckGithubVersion";

// The name of the package that contains this Observer's configuration
public const string ObserverConfigurationPackageName = "Config";
Expand Down
12 changes: 8 additions & 4 deletions FabricObserver/Observers/ObserverManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,15 @@ public async Task StartObserversAsync()
}
}

// Check for new version once a day.
if (!(shutdownSignaled || runAsyncToken.IsCancellationRequested) && DateTime.UtcNow.Subtract(LastVersionCheckDateTime) >= NewReleaseCheckInterval)
_ = bool.TryParse(GetConfigSettingValue(ObserverConstants.CheckGithubVersion, null), out bool checkGithubVersion);
sidhant012 marked this conversation as resolved.
Show resolved Hide resolved
if (checkGithubVersion)
{
await CheckGithubForNewVersionAsync();
LastVersionCheckDateTime = DateTime.UtcNow;
// Check for new version once a day.
if (!(shutdownSignaled || runAsyncToken.IsCancellationRequested) && DateTime.UtcNow.Subtract(LastVersionCheckDateTime) >= NewReleaseCheckInterval)
{
await CheckGithubForNewVersionAsync();
LastVersionCheckDateTime = DateTime.UtcNow;
}
}

// Time to tale a nap before running observers again. 30 seconds is the minimum sleep time.
Expand Down
3 changes: 3 additions & 0 deletions FabricObserver/PackageRoot/Config/Settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
<!-- Required: Diagnostic Telemetry. Azure ApplicationInsights and Azure LogAnalytics support is already implemented,
but you can implement whatever provider you want. See IObserverTelemetry interface. -->
<Parameter Name="EnableTelemetryProvider" Value="" MustOverride="true" />

<!-- Optional: Octokit Github Version check. If set to true FO will emit a health event if there is a new version of FO available -->
<Parameter Name="CheckGithubVersion" Value="" MustOverride="true" />

<!-- Telemetry - ApplicationInsights/LogAnalytics. NOTE: Values must now be set in ApplicationManifest.xml. This is a *breaking change* in version 3.2.15. -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
This is primarily useful for scenarios where you have multiple instances of FO running on a node and you want to ensure that each instance writes
ETW event data to different named sinks. This is more of an advanced scenario. In general, just leave this blank. -->
<Parameter Name="ObserverManagerETWProviderName" DefaultValue="" />
<!-- Set this parameter to true if you want FO to emit a health event letting you know if there is a new version of FO available. Otherwise, set this to false. -->
<Parameter Name="ObserverManagerCheckGithubVersion" DefaultValue="true" />
<!-- If you want FO to transmit telemetry data events to ApplicationInsights or LogAnalytics, for example, then enable this setting. Otherwise, set this to false. -->
<!-- Observer Telemetry -->
<Parameter Name="ObserverManagerEnableTelemetryProvider" DefaultValue="true" />
Expand Down Expand Up @@ -429,6 +431,7 @@
<Parameter Name="ObserverFailureHealthStateLevel" Value="[ObserverManagerObserverFailureHealthStateLevel]" />
<Parameter Name="ObserverLogPath" Value="[ObserverLogPath]" />
<Parameter Name="TelemetryProvider" Value="[TelemetryProvider]" />
<Parameter Name="CheckGithubVersion" Value="[ObserverManagerCheckGithubVersion]" />
<!-- Application Insights -->
<Parameter Name="AppInsightsConnectionString" Value="[AppInsightsConnectionString]" />
<!-- LogAnalytics -->
Expand Down
Loading