Skip to content

Commit

Permalink
Octokit check github version config
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidhant Bhatia committed Dec 12, 2024
1 parent 0880b2c commit 6b57b4f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
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);
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

0 comments on commit 6b57b4f

Please sign in to comment.