Skip to content
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
30 changes: 30 additions & 0 deletions .github/workflows/examples-sanity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Syntax: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
# .NET CLI: https://docs.microsoft.com/dotnet/core/tools/
# Description: The purpose of this build is to verify that our example projects compile.

name: Examples Sanity Build

on:
push:
branches: [ main, develop ]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have main branch?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good catch. I’ll fix this

pull_request:
branches: [ main, develop ]

jobs:
build-test:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x

- name: Install dependencies
run: dotnet restore ./examples/Examples.sln

- name: Build
run: dotnet build ./examples/Examples.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace WebApp.AspNetCore
namespace AspNetCoreWebApp
{
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace WebApp.AspNetCore
namespace AspNetCoreWebApp
{
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AspNetCoreHostingModel - this may not be needed..

</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.8.0-beta3" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<ProjectReference Include="..\..\NETCORE\src\Microsoft.ApplicationInsights.WorkerService\Microsoft.ApplicationInsights.WorkerService.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="5.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using System.Threading.Tasks;
using BackgroundTasksWithHostedService.HostedServices;
using BackgroundTasksWithHostedService.HostedServices;

using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

using System.Threading.Tasks;

namespace BackgroundTasksWithHostedService
{
public class Program
Expand Down Expand Up @@ -60,5 +64,31 @@ public static async Task Main(string[] args)
await host.WaitForShutdownAsync();
}
}

internal class MyCustomTelemetryInitializer : ITelemetryInitializer
{
public void Initialize(ITelemetry telemetry)
{
// Replace with actual properties.
(telemetry as ISupportProperties).Properties["MyCustomKey"] = "MyCustomValue";
}
}

internal class MyCustomTelemetryProcessor : ITelemetryProcessor
{
ITelemetryProcessor next;

public MyCustomTelemetryProcessor(ITelemetryProcessor next)
{
this.next = next;
}

public void Process(ITelemetry item)
{
// Example processor - not filtering out anything.
// This should be replaced with actual logic.
this.next.Process(item);
}
}
}
}
12 changes: 12 additions & 0 deletions examples/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\NETCORE\src\Microsoft.ApplicationInsights.WorkerService\Microsoft.ApplicationInsights.WorkerService.csproj" />
</ItemGroup>

</Project>
51 changes: 13 additions & 38 deletions examples/Examples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Web", "..\WEB\Src\Web\Web\W
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SDKs", "SDKs", "{C5024E50-3350-479B-8628-620B299B9061}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApp.AspNetCore", "WebApp.AspNetCore\WebApp.AspNetCore.csproj", "{5DB76934-58D9-45BD-91A9-E1D78F4AE17D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCoreWebApp", "AspNetCoreWebApp\AspNetCoreWebApp.csproj", "{5DB76934-58D9-45BD-91A9-E1D78F4AE17D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BackgroundTasksWithHostedService", "BackgroundTasksWithHostedService\BackgroundTasksWithHostedService.csproj", "{9E35EFBE-F478-4DEB-9327-C712272B77CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{DD21C077-1345-459C-8704-9BCD6F312029}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkerService", "WorkerService\WorkerService.csproj", "{3DA486F4-10E3-432D-9916-2C1EE15029C7}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Expand Down Expand Up @@ -82,81 +88,50 @@ Global
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E3D160E8-7F8C-416F-946F-6FDFC6787461}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3D160E8-7F8C-416F-946F-6FDFC6787461}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3D160E8-7F8C-416F-946F-6FDFC6787461}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3D160E8-7F8C-416F-946F-6FDFC6787461}.Release|Any CPU.Build.0 = Release|Any CPU
{C30A7EB8-A86C-49EE-927E-7D9E03572E82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C30A7EB8-A86C-49EE-927E-7D9E03572E82}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C30A7EB8-A86C-49EE-927E-7D9E03572E82}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C30A7EB8-A86C-49EE-927E-7D9E03572E82}.Release|Any CPU.Build.0 = Release|Any CPU
{96A6E04E-CEDA-4C30-8ECA-48113382AFBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96A6E04E-CEDA-4C30-8ECA-48113382AFBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96A6E04E-CEDA-4C30-8ECA-48113382AFBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96A6E04E-CEDA-4C30-8ECA-48113382AFBA}.Release|Any CPU.Build.0 = Release|Any CPU
{13335EB8-3936-407A-9363-1C428318BEA8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13335EB8-3936-407A-9363-1C428318BEA8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13335EB8-3936-407A-9363-1C428318BEA8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13335EB8-3936-407A-9363-1C428318BEA8}.Release|Any CPU.Build.0 = Release|Any CPU
{DEEAF599-83F9-4A05-ADD6-F612CDABE570}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DEEAF599-83F9-4A05-ADD6-F612CDABE570}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DEEAF599-83F9-4A05-ADD6-F612CDABE570}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DEEAF599-83F9-4A05-ADD6-F612CDABE570}.Release|Any CPU.Build.0 = Release|Any CPU
{9DC5C5E5-FC37-4E54-81FD-AA42BB934E9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9DC5C5E5-FC37-4E54-81FD-AA42BB934E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9DC5C5E5-FC37-4E54-81FD-AA42BB934E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9DC5C5E5-FC37-4E54-81FD-AA42BB934E9B}.Release|Any CPU.Build.0 = Release|Any CPU
{7B5D95EE-50EE-4222-A03C-FAE5905B3DFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B5D95EE-50EE-4222-A03C-FAE5905B3DFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B5D95EE-50EE-4222-A03C-FAE5905B3DFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B5D95EE-50EE-4222-A03C-FAE5905B3DFD}.Release|Any CPU.Build.0 = Release|Any CPU
{2E283031-425B-421F-9E81-34ABFEFAB618}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E283031-425B-421F-9E81-34ABFEFAB618}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E283031-425B-421F-9E81-34ABFEFAB618}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E283031-425B-421F-9E81-34ABFEFAB618}.Release|Any CPU.Build.0 = Release|Any CPU
{1B0F54BF-078A-421C-9708-2D817D4BCE30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B0F54BF-078A-421C-9708-2D817D4BCE30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B0F54BF-078A-421C-9708-2D817D4BCE30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B0F54BF-078A-421C-9708-2D817D4BCE30}.Release|Any CPU.Build.0 = Release|Any CPU
{52B3C054-C686-4BB8-A4B7-9E8D6C49491F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52B3C054-C686-4BB8-A4B7-9E8D6C49491F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52B3C054-C686-4BB8-A4B7-9E8D6C49491F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52B3C054-C686-4BB8-A4B7-9E8D6C49491F}.Release|Any CPU.Build.0 = Release|Any CPU
{67291093-4B5F-4CA5-A811-B8A1DCBE3F1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{67291093-4B5F-4CA5-A811-B8A1DCBE3F1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{67291093-4B5F-4CA5-A811-B8A1DCBE3F1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{67291093-4B5F-4CA5-A811-B8A1DCBE3F1F}.Release|Any CPU.Build.0 = Release|Any CPU
{3774003C-91FD-4D79-99C7-9BEAC5B9A48E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3774003C-91FD-4D79-99C7-9BEAC5B9A48E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3774003C-91FD-4D79-99C7-9BEAC5B9A48E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3774003C-91FD-4D79-99C7-9BEAC5B9A48E}.Release|Any CPU.Build.0 = Release|Any CPU
{63B8FDA7-2FF5-4A20-8DE7-EBB036012A54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63B8FDA7-2FF5-4A20-8DE7-EBB036012A54}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63B8FDA7-2FF5-4A20-8DE7-EBB036012A54}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63B8FDA7-2FF5-4A20-8DE7-EBB036012A54}.Release|Any CPU.Build.0 = Release|Any CPU
{2612AC44-5FF3-4533-B5A5-E5DBF96F5C83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2612AC44-5FF3-4533-B5A5-E5DBF96F5C83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2612AC44-5FF3-4533-B5A5-E5DBF96F5C83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2612AC44-5FF3-4533-B5A5-E5DBF96F5C83}.Release|Any CPU.Build.0 = Release|Any CPU
{AC399F09-B465-4CFD-8D82-F1D1C5C9347E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC399F09-B465-4CFD-8D82-F1D1C5C9347E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC399F09-B465-4CFD-8D82-F1D1C5C9347E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC399F09-B465-4CFD-8D82-F1D1C5C9347E}.Release|Any CPU.Build.0 = Release|Any CPU
{3CAB7F66-3CC4-4B46-9B0D-765C460FE2BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3CAB7F66-3CC4-4B46-9B0D-765C460FE2BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CAB7F66-3CC4-4B46-9B0D-765C460FE2BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CAB7F66-3CC4-4B46-9B0D-765C460FE2BF}.Release|Any CPU.Build.0 = Release|Any CPU
{6062A897-6E55-44C9-BA7A-E1C42946EE51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6062A897-6E55-44C9-BA7A-E1C42946EE51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6062A897-6E55-44C9-BA7A-E1C42946EE51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6062A897-6E55-44C9-BA7A-E1C42946EE51}.Release|Any CPU.Build.0 = Release|Any CPU
{5DB76934-58D9-45BD-91A9-E1D78F4AE17D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5DB76934-58D9-45BD-91A9-E1D78F4AE17D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5DB76934-58D9-45BD-91A9-E1D78F4AE17D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5DB76934-58D9-45BD-91A9-E1D78F4AE17D}.Release|Any CPU.Build.0 = Release|Any CPU
{9E35EFBE-F478-4DEB-9327-C712272B77CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9E35EFBE-F478-4DEB-9327-C712272B77CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD21C077-1345-459C-8704-9BCD6F312029}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD21C077-1345-459C-8704-9BCD6F312029}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DA486F4-10E3-432D-9916-2C1EE15029C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DA486F4-10E3-432D-9916-2C1EE15029C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace WorkerServiceSampleWithApplicationInsights
namespace WorkerService
{
public class Program
{
Expand Down Expand Up @@ -37,5 +36,31 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
// instrumentation key is read automatically from appsettings.json
services.AddApplicationInsightsTelemetryWorkerService();
});

internal class MyCustomTelemetryInitializer : ITelemetryInitializer
{
public void Initialize(ITelemetry telemetry)
{
// Replace with actual properties.
(telemetry as ISupportProperties).Properties["MyCustomKey"] = "MyCustomValue";
}
}

internal class MyCustomTelemetryProcessor : ITelemetryProcessor
{
ITelemetryProcessor next;

public MyCustomTelemetryProcessor(ITelemetryProcessor next)
{
this.next = next;
}

public void Process(ITelemetry item)
{
// Example processor - not filtering out anything.
// This should be replaced with actual logic.
this.next.Process(item);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace WorkerServiceSampleWithApplicationInsights
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

namespace WorkerService
{
public class Worker : BackgroundService
{
Expand Down
15 changes: 15 additions & 0 deletions examples/WorkerService/WorkerService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>dotnet-WorkerServiceSampleWithApplicationInsights-E563FF63-73E2-4449-909F-BD093B43F6EF</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\NETCORE\src\Microsoft.ApplicationInsights.WorkerService\Microsoft.ApplicationInsights.WorkerService.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
</ItemGroup>
</Project>

This file was deleted.

This file was deleted.

Loading