Skip to content
Open
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
53 changes: 53 additions & 0 deletions CMP.ServiceFabric.Logging.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,73 @@ VisualStudioVersion = 16.0.29411.108
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMP.ServiceFabric.Logging", "CMP.ServiceFabric.Logging\CMP.ServiceFabric.Logging.csproj", "{CB41048B-A0EF-4712-91D0-B2716FE76E72}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleSample", "samples\ConsoleSample\ConsoleSample.csproj", "{A75E5CC0-6614-4A3B-95FD-C58B7BAEC4CA}"
EndProject
Project("{A07B5EB6-E848-4116-A8D0-A826331D98C6}") = "Sample", "samples\Sample\Sample.sfproj", "{75DB17CC-CC97-4606-8136-773FF9760172}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfWeb", "samples\SfWeb\SfWeb.csproj", "{2E4FFB18-5AC5-4D86-802B-DE13105EAC54}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ServiceFabric", "ServiceFabric", "{27DCEE15-6A9C-4D05-A8AF-D428008322AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SfWorker", "samples\SfWorker\SfWorker.csproj", "{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CB41048B-A0EF-4712-91D0-B2716FE76E72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB41048B-A0EF-4712-91D0-B2716FE76E72}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB41048B-A0EF-4712-91D0-B2716FE76E72}.Debug|x64.ActiveCfg = Debug|Any CPU
{CB41048B-A0EF-4712-91D0-B2716FE76E72}.Debug|x64.Build.0 = Debug|Any CPU
{CB41048B-A0EF-4712-91D0-B2716FE76E72}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB41048B-A0EF-4712-91D0-B2716FE76E72}.Release|Any CPU.Build.0 = Release|Any CPU
{CB41048B-A0EF-4712-91D0-B2716FE76E72}.Release|x64.ActiveCfg = Release|Any CPU
{CB41048B-A0EF-4712-91D0-B2716FE76E72}.Release|x64.Build.0 = Release|Any CPU
{A75E5CC0-6614-4A3B-95FD-C58B7BAEC4CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A75E5CC0-6614-4A3B-95FD-C58B7BAEC4CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A75E5CC0-6614-4A3B-95FD-C58B7BAEC4CA}.Debug|x64.ActiveCfg = Debug|Any CPU
{A75E5CC0-6614-4A3B-95FD-C58B7BAEC4CA}.Debug|x64.Build.0 = Debug|Any CPU
{A75E5CC0-6614-4A3B-95FD-C58B7BAEC4CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A75E5CC0-6614-4A3B-95FD-C58B7BAEC4CA}.Release|Any CPU.Build.0 = Release|Any CPU
{A75E5CC0-6614-4A3B-95FD-C58B7BAEC4CA}.Release|x64.ActiveCfg = Release|Any CPU
{A75E5CC0-6614-4A3B-95FD-C58B7BAEC4CA}.Release|x64.Build.0 = Release|Any CPU
{75DB17CC-CC97-4606-8136-773FF9760172}.Debug|Any CPU.ActiveCfg = Debug|x64
{75DB17CC-CC97-4606-8136-773FF9760172}.Debug|x64.ActiveCfg = Debug|x64
{75DB17CC-CC97-4606-8136-773FF9760172}.Debug|x64.Build.0 = Debug|x64
{75DB17CC-CC97-4606-8136-773FF9760172}.Debug|x64.Deploy.0 = Debug|x64
{75DB17CC-CC97-4606-8136-773FF9760172}.Release|Any CPU.ActiveCfg = Release|x64
{75DB17CC-CC97-4606-8136-773FF9760172}.Release|x64.ActiveCfg = Release|x64
{75DB17CC-CC97-4606-8136-773FF9760172}.Release|x64.Build.0 = Release|x64
{75DB17CC-CC97-4606-8136-773FF9760172}.Release|x64.Deploy.0 = Release|x64
{2E4FFB18-5AC5-4D86-802B-DE13105EAC54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E4FFB18-5AC5-4D86-802B-DE13105EAC54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E4FFB18-5AC5-4D86-802B-DE13105EAC54}.Debug|x64.ActiveCfg = Debug|Any CPU
{2E4FFB18-5AC5-4D86-802B-DE13105EAC54}.Debug|x64.Build.0 = Debug|Any CPU
{2E4FFB18-5AC5-4D86-802B-DE13105EAC54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E4FFB18-5AC5-4D86-802B-DE13105EAC54}.Release|Any CPU.Build.0 = Release|Any CPU
{2E4FFB18-5AC5-4D86-802B-DE13105EAC54}.Release|x64.ActiveCfg = Release|Any CPU
{2E4FFB18-5AC5-4D86-802B-DE13105EAC54}.Release|x64.Build.0 = Release|Any CPU
{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622}.Debug|x64.ActiveCfg = Debug|Any CPU
{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622}.Debug|x64.Build.0 = Debug|Any CPU
{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622}.Release|Any CPU.Build.0 = Release|Any CPU
{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622}.Release|x64.ActiveCfg = Release|Any CPU
{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{75DB17CC-CC97-4606-8136-773FF9760172} = {27DCEE15-6A9C-4D05-A8AF-D428008322AC}
{2E4FFB18-5AC5-4D86-802B-DE13105EAC54} = {27DCEE15-6A9C-4D05-A8AF-D428008322AC}
{5CF26A45-55D9-4FA5-9BF6-365C6B3FA622} = {27DCEE15-6A9C-4D05-A8AF-D428008322AC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8C23C15D-BAED-427D-833E-EA3794ECC1B9}
EndGlobalSection
Expand Down
2 changes: 1 addition & 1 deletion CMP.ServiceFabric.Logging/CMP.ServiceFabric.Logging.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<VersionPrefix>0.1.5</VersionPrefix>
<VersionPrefix>0.1.6</VersionPrefix>
<VersionSuffix>alpha</VersionSuffix>
<PackageId>CMP.ServiceFabric.Logging</PackageId>
<Authors>CDON</Authors>
Expand Down
31 changes: 31 additions & 0 deletions CMP.ServiceFabric.Logging/SuccessfulDependencyFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;

namespace CMP.ServiceFabric.Logging
{
public class SuccessfulDependencyFilter : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }

public SuccessfulDependencyFilter(ITelemetryProcessor next)
{
this.Next = next;
}

public void Process(ITelemetry item)
{
if (!OKtoSend(item)) { return; }

this.Next.Process(item);
}

private bool OKtoSend(ITelemetry item)
{
var dependency = item as DependencyTelemetry;
if (dependency == null) return true;

return dependency.Success != true;
}
}
}
16 changes: 16 additions & 0 deletions samples/ConsoleSample/ConsoleSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\CMP.ServiceFabric.Logging\CMP.ServiceFabric.Logging.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.13.1" />
</ItemGroup>

</Project>
36 changes: 36 additions & 0 deletions samples/ConsoleSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Serilog;
using System;
using CMP.ServiceFabric.Logging;
using Microsoft.ApplicationInsights.Extensibility;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace ConsoleSample
{
class Program
{
static void Main(string[] args)
{
var instrumentationKey = args.First();

var serviceProvider = new ServiceCollection()
.AddApplicationInsightsTelemetryWorkerService(instrumentationKey)
.AddApplicationInsightsTelemetryProcessor<SuccessfulDependencyFilter>()
.BuildServiceProvider();

var telemetryConfiguration = serviceProvider.GetRequiredService<TelemetryConfiguration>();

Log.Logger = new LoggerConfiguration()
.DefaultCmp(telemetryConfiguration, "development")
.CreateLogger();

var coreLogger = telemetryConfiguration.ConfigureLogging(Log.Logger, "ConsoleSample");
//NOTE in SF: coreLogger = context.ConfigureLogging(telemetryConfiguration, Log.Logger, "ConsoleSample");

coreLogger.LogInformation("Hello world");
Console.WriteLine("Hello World! - press a key to end.");
Console.ReadLine();
}
}
}
39 changes: 39 additions & 0 deletions samples/Sample/ApplicationPackageRoot/ApplicationManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="SampleType" ApplicationTypeVersion="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="SfWorker_InstanceCount" DefaultValue="-1" />
<Parameter Name="SfWeb_ASPNETCORE_ENVIRONMENT" DefaultValue="" />
<Parameter Name="SfWeb_InstanceCount" DefaultValue="-1" />
</Parameters>
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion
should match the Name and Version attributes of the ServiceManifest element defined in the
ServiceManifest.xml file. -->
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="SfWorkerPkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
</ServiceManifestImport>
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="SfWebPkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
<EnvironmentOverrides CodePackageRef="code">
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[SfWeb_ASPNETCORE_ENVIRONMENT]" />
</EnvironmentOverrides>
</ServiceManifestImport>
<DefaultServices>
<!-- The section below creates instances of service types, when an instance of this
application type is created. You can also create one or more instances of service type using the
ServiceFabric PowerShell module.

The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
<Service Name="SfWorker" ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="SfWorkerType" InstanceCount="[SfWorker_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
<Service Name="SfWeb" ServicePackageActivationMode="ExclusiveProcess">
<StatelessService ServiceTypeName="SfWebType" InstanceCount="[SfWeb_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>
7 changes: 7 additions & 0 deletions samples/Sample/ApplicationParameters/Cloud.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/Sample" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="SfWorker_InstanceCount" Value="-1" />
<Parameter Name="SfWeb_InstanceCount" Value="-1" />
</Parameters>
</Application>
8 changes: 8 additions & 0 deletions samples/Sample/ApplicationParameters/Local.1Node.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/Sample" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="SfWorker_InstanceCount" Value="1" />
<Parameter Name="SfWeb_ASPNETCORE_ENVIRONMENT" Value="Development" />
<Parameter Name="SfWeb_InstanceCount" Value="1" />
</Parameters>
</Application>
8 changes: 8 additions & 0 deletions samples/Sample/ApplicationParameters/Local.5Node.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/Sample" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="SfWorker_InstanceCount" Value="1" />
<Parameter Name="SfWeb_ASPNETCORE_ENVIRONMENT" Value="Development" />
<Parameter Name="SfWeb_InstanceCount" Value="1" />
</Parameters>
</Application>
26 changes: 26 additions & 0 deletions samples/Sample/PublishProfiles/Cloud.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools">
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.

For a remote cluster, you would need to specify the appropriate parameters for that specific cluster.
For example: <ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000" />

Example showing parameters for a cluster that uses certificate security:
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000"
X509Credential="true"
ServerCertThumbprint="0123456789012345678901234567890123456789"
FindType="FindByThumbprint"
FindValue="9876543210987654321098765432109876543210"
StoreLocation="CurrentUser"
StoreName="My" />

Example showing parameters for a cluster that uses Azure Active Directory (AAD) security:
<ClusterConnectionParameters ConnectionEndpoint="mycluster.westus.cloudapp.azure.com:19000"
AzureActiveDirectory="true"
ServerCertThumbprint="0123456789012345678901234567890123456789" />
-->
<ClusterConnectionParameters ConnectionEndpoint="" />
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" />
<CopyPackageParameters CompressPackage="true" />
</PublishProfile>
11 changes: 11 additions & 0 deletions samples/Sample/PublishProfiles/Local.1Node.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools">
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.

For a local cluster, you would typically not use any parameters.
For example: <ClusterConnectionParameters />
-->
<ClusterConnectionParameters />
<ApplicationParameterFile Path="..\ApplicationParameters\Local.1Node.xml" />
</PublishProfile>
11 changes: 11 additions & 0 deletions samples/Sample/PublishProfiles/Local.5Node.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PublishProfile xmlns="http://schemas.microsoft.com/2015/05/fabrictools">
<!-- ClusterConnectionParameters allows you to specify the PowerShell parameters to use when connecting to the Service Fabric cluster.
Valid parameters are any that are accepted by the Connect-ServiceFabricCluster cmdlet.

For a local cluster, you would typically not use any parameters.
For example: <ClusterConnectionParameters />
-->
<ClusterConnectionParameters />
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" />
</PublishProfile>
50 changes: 50 additions & 0 deletions samples/Sample/Sample.sfproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?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')" />
<PropertyGroup Label="Globals">
<ProjectGuid>75db17cc-cc97-4606-8136-773ff9760172</ProjectGuid>
<ProjectVersion>2.5</ProjectVersion>
<MinToolsVersion>1.5</MinToolsVersion>
<SupportedMSBuildNuGetPackageVersion>1.6.9</SupportedMSBuildNuGetPackageVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" />
<None Include="ApplicationParameters\Cloud.xml" />
<None Include="ApplicationParameters\Local.1Node.xml" />
<None Include="ApplicationParameters\Local.5Node.xml" />
<None Include="PublishProfiles\Cloud.xml" />
<None Include="PublishProfiles\Local.1Node.xml" />
<None Include="PublishProfiles\Local.5Node.xml" />
<None Include="Scripts\Deploy-FabricApplication.ps1" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SfWeb\SfWeb.csproj">
<ServiceLaunchUrl>http://{MachineName}:{ServicePort}/</ServiceLaunchUrl>
</ProjectReference>
<ProjectReference Include="..\SfWorker\SfWorker.csproj" />
</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')" />
<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." />
</Target>
</Project>
Loading