Skip to content

Commit

Permalink
Merge pull request #100 from microsoft/develop
Browse files Browse the repository at this point in the history
FO 3.1.0
  • Loading branch information
GitTorre authored Dec 11, 2020
2 parents e2a1224 + d4a7907 commit 9ac52a6
Show file tree
Hide file tree
Showing 105 changed files with 1,309 additions and 763 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,6 @@ ASALocalRun/
# MFractors (Xamarin productivity tool) working folder
.mfractor/

Cloud*.xml
**/PublishProfiles/Cloud.xml
/FabricObserver/observer_logs
/FabricObserver/PackageRoot/Data/Plugins/SampleNewObserver.dll
14 changes: 7 additions & 7 deletions ClusterObserverApp/ClusterObserverApp.sfproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.9\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.9\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" />
<Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" />
<PropertyGroup Label="Globals">
<ProjectGuid>bd5d216f-5f89-4cc4-92fd-d6fdec5a19ad</ProjectGuid>
<ProjectVersion>2.5</ProjectVersion>
<MinToolsVersion>1.5</MinToolsVersion>
<SupportedMSBuildNuGetPackageVersion>1.6.9</SupportedMSBuildNuGetPackageVersion>
<SupportedMSBuildNuGetPackageVersion>1.7.3</SupportedMSBuildNuGetPackageVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
Expand All @@ -29,19 +29,19 @@
<None Include="Scripts\Deploy-FabricApplication.ps1" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
<ProjectReference Include="..\ClusterObserver\ClusterObserver.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClusterObserver\ClusterObserver.csproj" />
<Content Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<PropertyGroup>
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath>
</PropertyGroup>
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" />
<Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.9\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.9\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" />
<Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" />
<Target Name="ValidateMSBuildFiles" BeforeTargets="PrepareForBuild">
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.9\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.9\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.9\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.9\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.7.3\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
</Target>
</Project>
2 changes: 1 addition & 1 deletion ClusterObserverApp/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.6.9" targetFramework="net472" />
<package id="Microsoft.VisualStudio.Azure.Fabric.MSBuild" version="1.7.3" />
</packages>
104 changes: 69 additions & 35 deletions Documentation/Design.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ by calling ObserverManager's StopObservers() function.

This is the abstract base class for all Observers. It provides several concrete method and property implementations
that are widely used by deriving types, not the least of which is ProcessResourceDataReportHealth(), which is called from all
observers' ReportAsync function.
built-in observers that generate numeric data as part of their resource usage observations. Any public member of ObserverBase is available
to any plugin implementation. Please see [Plugins readme](/Documentation/Plugins.md) for detailed information about building FabricObserver plugins,
which are implemented as .NET Standard 2.0 libraries and consume FabricObserver's API surface (just as built-in observers do), which is housed in a NET Standard 2.0 library, FabricObserver.Extensibility.dll.

***Design***

Expand All @@ -34,21 +36,45 @@ derived by all Observer types)

public interface IObserver : IDisposable
{
string ObserverName { get; }
string ObserverName
{
get;
}

string NodeName { get; set; }
string NodeName
{
get; set;
}

Logger ObserverLogger { get; set; }
Logger ObserverLogger
{
get; set;
}

DateTime LastRunDateTime { get; set; }
DateTime LastRunDateTime
{
get; set;
}

TimeSpan RunInterval { get; set; }
TimeSpan RunInterval
{
get; set;
}

bool IsEnabled { get; set; }
bool IsEnabled
{
get; set;
}

bool HasActiveFabricErrorOrWarning { get; set; }
bool HasActiveFabricErrorOrWarning
{
get; set;
}

bool IsUnhealthy { get; set; }
bool IsUnhealthy
{
get; set;
}

ConfigSettings ConfigurationSettings
{
Expand All @@ -70,9 +96,14 @@ derived by all Observer types)
Task ReportAsync(CancellationToken token);
}

public abstract class ObserverBase : IObserverBase<StatelessServiceContext>
public abstract class ObserverBase : IObserver
{
// Impl...
...
protected ObserverBase(FabricClient fabricClient, StatelessServiceContext statelessServiceContext)
{
...
}
...
}
```

Expand Down Expand Up @@ -119,35 +150,38 @@ optionally providing an integer value that represents some timeout or computed r


Let's look at the simple design of an Observer:
```c#
using System;
using System.Fabric;
using System.Fabric.Health;
using System.IO;
using System.Threading.Tasks;
``` C#

using System.Threading;
using FabricObserver.Utilities;
using System.Threading.Tasks;
using FabricObserver.Observers.Utilities;
using FabricObserver.Observers.Utilities.Telemetry;

namespace FabricObserver
namespace FabricObserver.Observers
{
pubic class SomeObserver : ObserverBase
{
public SomeObserver() { }

public override async Task ObserveAsync(CancellationToken token)
{
// Observe then call ReportAsync.
}

public override async Task ReportAsync(CancellationToken token)
{
// Prepare observational data to send to ObserverBase's ProcessResourceDataReportHealth function.
}
}
public class SampleNewObserver : ObserverBase
{
public SomeObserver(FabricClient fabricClient, StatelessServiceContext context)
: base(fabricClient, context)
{
//... Your impl.
}

public override async Task ObserveAsync(CancellationToken token)
{
//... Your impl.
}

public override async Task ReportAsync(CancellationToken token)
{
//... Your impl.
}
}
}
```
```


**Data Design**
**Data Design**

Each observer is tasked with recording one or more metrics that are
relevant to local Machine or application service health. Each metric will be stored in an
Expand Down
13 changes: 9 additions & 4 deletions Documentation/Plugins.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
## How to implement an observer plugin using our extensibility model*
## How to implement an observer plugin using FO's extensibility model

Please see the [SampleObserver project](/SampleObserverPlugin) for a complete sample observer plugin implementation with code comments and readme. This document is a simple
overview of how to get started with building an observer plugin.

**NOTE: FabricObserver version 3.1.0 introduces a refactored plugin implementation that will break existing plugins. The changes required by plugin authors are trivial, however. Please see the [SampleObserver project](/SampleObserverPlugin) for a complete sample observer plugin implementation with code comments and readme with examples of the new format.**

This document is a simple overview of how to get started with building an observer plugin. Also, for a more advanced sample, please see [ContainerObserver](https://github.com/gittorre/containerobserver).

#### Steps

FabricObserver is a .NET Core 3.1 application. A FabricObserver plugin is a .NET Standard 2.0 library that consumes FabricObserver's public API, which is housed inside a .NET Standard 2.0 library, FabricObserver.Extensibility.dll.
Your plugin must be built as a .NET Standard 2.0 library.

- Install [.Net Core 3.1](https://dotnet.microsoft.com/download/dotnet-core/3.1).
- Navigate to top level directory (where FabricObserver.sln lives, for example) then,

Expand All @@ -20,7 +25,7 @@ You can build them yourself by simply running these scripts, in this order:
- ./Build-NugetPackages.ps1


Create a new .NET Core 3.1 library project, install the nupkg you need for your target OS (Linux (Ubuntu) or Windows):
Create a new .NET Standard 2.0 library project, install the nupkg you need for your target OS (Linux (Ubuntu) or Windows):

Framework-dependent = Requires that .NET Core 3.1 is already installed on target machine.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
// ------------------------------------------------------------

using Microsoft.Extensions.DependencyInjection;
using System.Fabric;

namespace FabricObserver
{
public interface IFabricObserverStartup
{
void ConfigureServices(IServiceCollection services);
void ConfigureServices(IServiceCollection services, FabricClient fabricClient, StatelessServiceContext context);
}
}
30 changes: 30 additions & 0 deletions FabricObserver.Extensibility/FabricObserver.Extensibility.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Platforms>AnyCPU;x64</Platforms>
<RootNamespace>FabricObserver</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.ServiceFabric" Version="7.1.428" />
<PackageReference Include="Microsoft.ServiceFabric.Data" Version="4.1.428" />
<PackageReference Include="Microsoft.ServiceFabric.Data.Extensions" Version="4.1.428" />
<PackageReference Include="Microsoft.ServiceFabric.Data.Interfaces" Version="4.1.428" />
<PackageReference Include="Microsoft.ServiceFabric.Diagnostics.Internal" Version="4.1.428" />
<PackageReference Include="Microsoft.ServiceFabric.Services" Version="4.1.428" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog" Version="4.7.2" />
<PackageReference Include="System.Management" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TelemetryLib\TelemetryLib.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

namespace FabricObserver.Observers.Interfaces
{
/// <summary>
/// Base Observer interface implemented by ObserverBase, the base type of all Observers.
/// </summary>
public interface IObserver : IDisposable
{
string ObserverName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,34 @@
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------

using System.Fabric;
using System.Fabric.Description;
using FabricObserver.Observers.Utilities;

namespace FabricObserver.Observers.MachineInfoModel
{
public static class ConfigSettings
public class ConfigSettings
{
public static string ConfigPackagePath =>
ObserverManager.FabricServiceContext.CodePackageActivationContext.
public string ConfigPackagePath =>
this.serviceContext.CodePackageActivationContext.
GetConfigurationPackageObject(ObserverConstants.ObserverConfigurationPackageName)?.Path;

public static string AppObserverConfigFileName
public string AppObserverConfigFileName
{
get; set;
}

public static string NetworkObserverConfigFileName
public string NetworkObserverConfigFileName
{
get; set;
}

public static void Initialize(
public ConfigSettings(StatelessServiceContext context)
{
this.serviceContext = context;
}

public void Initialize(
ConfigurationSettings configSettings,
string configurationSectionName,
string dataFileName)
Expand Down Expand Up @@ -52,7 +58,7 @@ public static void Initialize(
}
}

internal static void UpdateCommonConfigurationSettings(
internal void UpdateCommonConfigurationSettings(
ConfigurationSettings newConfigurationSettings,
string configurationSectionName,
string dataFileName)
Expand Down Expand Up @@ -81,6 +87,8 @@ internal static void UpdateCommonConfigurationSettings(
}
}

private static ConfigurationSettings configurationSettings;
private ConfigurationSettings configurationSettings;
private StatelessServiceContext serviceContext;
}
}

Loading

0 comments on commit 9ac52a6

Please sign in to comment.