Skip to content

Commit 59c8735

Browse files
SergeyKanzhelevLiudmila Molkova
authored andcommitted
Convert to modern csproj files and a bit of clean up (#38)
1 parent 7b9d807 commit 59c8735

28 files changed

+255
-1379
lines changed

Build.cmd

Lines changed: 0 additions & 28 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
Contributing
2-
======
1+
# Contributing
32

4-
Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) in the Home repo.
3+
Information on contributing to this repo is in the [Contributing
4+
Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in
5+
the Home repo.
6+
7+
## Build and test
8+
9+
1. Open project in Visual Studio 2017+.
10+
2. Build and compile run unit tests right from Visual Studio.
11+
12+
Command line:
13+
14+
```
15+
dotnet build .\Microsoft.AspNet.TelemetryCorrelation.sln
16+
dotnet test .\Microsoft.AspNet.TelemetryCorrelation.sln
17+
dotnet pack .\Microsoft.AspNet.TelemetryCorrelation.sln
18+
```
19+
20+
## Manual testing
21+
22+
Follow readme to install http module to your application.
23+
24+
Set `set PublicRelease=True` before build to produce delay-signed
25+
assembly with the public key matching released version of assembly.

Microsoft.AspNet.TelemetryCorrelation.msbuild

Lines changed: 0 additions & 43 deletions
This file was deleted.

Microsoft.AspNet.TelemetryCorrelation.sln

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.TelemetryC
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.TelemetryCorrelation.Tests", "test\Microsoft.AspNet.TelemetryCorrelation.Tests\Microsoft.AspNet.TelemetryCorrelation.Tests.csproj", "{9FAE5C43-F56C-4D87-A23C-6D2D57B4ABED}"
1313
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{504D7010-38CC-4B07-BC57-D7030209D631}"
15+
ProjectSection(SolutionItems) = preProject
16+
README.md = README.md
17+
EndProjectSection
18+
EndProject
1419
Global
1520
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1621
Debug|Any CPU = Debug|Any CPU
@@ -33,4 +38,7 @@ Global
3338
{4C8E592C-C532-4CF2-80EF-3BDD0D788D12} = {CE6B50B2-34AE-44C9-940A-4E48C3E1B3BC}
3439
{9FAE5C43-F56C-4D87-A23C-6D2D57B4ABED} = {258D5057-81B9-40EC-A872-D21E27452749}
3540
EndGlobalSection
41+
GlobalSection(ExtensibilityGlobals) = postSolution
42+
SolutionGuid = {6E28F11C-A0D8-461B-B71F-70F348C1BB53}
43+
EndGlobalSection
3644
EndGlobal

README.md

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,59 @@
11
# Telemetry correlation http module
22

3-
Telemetry correlation http module enables cross tier telemetry tracking.
3+
[![NuGet](https://img.shields.io/nuget/v/Microsoft.AspNet.TelemetryCorrelation.svg)](Microsoft.AspNet.TelemetryCorrelation)
44

5-
- Reads http headers
6-
- Start/Stops Activity for the http request
7-
- Ensure the Activity ambient state is transferred thru the IIS callbacks
5+
Telemetry correlation http module enables cross tier telemetry tracking.
6+
7+
## Usage
8+
9+
1. Install NuGet for your app.
10+
2. Enable diagnostics source listener using code below. Note, some
11+
telemetry vendors like Azure Application Insights will enable it
12+
automatically.
13+
14+
``` csharp
15+
public class NoopDiagnosticsListener : IObserver<KeyValuePair<string, object>>
16+
{
17+
public void OnCompleted() { }
18+
19+
public void OnError(Exception error) { }
20+
21+
public void OnNext(KeyValuePair<string, object> evnt)
22+
{
23+
}
24+
}
825

9-
See http protocol [specifications](https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md) for details.
26+
public class NoopSubscriber : IObserver<DiagnosticListener>
27+
{
28+
public void OnCompleted() { }
29+
30+
public void OnError(Exception error) { }
31+
32+
public void OnNext(DiagnosticListener listener)
33+
{
34+
if (listener.Name == "Microsoft.AspNet.TelemetryCorrelation" || listener.Name == "System.Net.Http" )
35+
{
36+
listener.Subscribe(new NoopDiagnosticsListener());
37+
}
38+
}
39+
}
40+
```
41+
3. Double check that http module was registered in `web.config` for your
42+
app.
43+
44+
Once enabled - this http module will:
45+
46+
- Reads correlation http headers
47+
- Start/Stops Activity for the http request
48+
- Ensure the Activity ambient state is transferred thru the IIS
49+
callbacks
1050

51+
See http protocol [specifications][http-protocol-specification] for
52+
details.
1153

12-
This http module is used by Application Insights. See [documentation](https://docs.microsoft.com/azure/application-insights/application-insights-correlation) and [code](https://github.com/Microsoft/ApplicationInsights-dotnet-server).
54+
This http module is used by Application Insights. See
55+
[documentation][usage-in-ai-code-docs] and [code][usage-in-ai-code].
1356

57+
[http-protocol-specification]: https://github.com/dotnet/corefx/blob/master/src/System.Diagnostics.DiagnosticSource/src/HttpCorrelationProtocol.md
58+
[usage-in-ai-docs]: https://docs.microsoft.com/azure/application-insights/application-insights-correlation
59+
[usage-in-ai-code]: https://github.com/Microsoft/ApplicationInsights-dotnet-server

src/Microsoft.AspNet.TelemetryCorrelation/ActivityExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public static bool Extract(this Activity activity, NameValueCollection requestHe
6767
if (baggages != null)
6868
{
6969
int correlationContextLength = -1;
70+
7071
// there may be several Correlation-Context header
7172
foreach (var item in baggages)
7273
{
Lines changed: 59 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,94 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4-
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Microsoft.AspNet.TelemetryCorrelation.sln))\tools\Microsoft.AspNet.TelemetryCorrelation.settings.targets" />
1+
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk">
2+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory),Microsoft.AspNet.TelemetryCorrelation.sln))\tools\Microsoft.AspNet.TelemetryCorrelation.settings.props" />
53
<PropertyGroup>
6-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
84
<ProjectGuid>{4C8E592C-C532-4CF2-80EF-3BDD0D788D12}</ProjectGuid>
95
<OutputType>Library</OutputType>
106
<AppDesignerFolder>Properties</AppDesignerFolder>
117
<RootNamespace>Microsoft.AspNet.TelemetryCorrelation</RootNamespace>
128
<AssemblyName>Microsoft.AspNet.TelemetryCorrelation</AssemblyName>
13-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
9+
<TargetFrameworks>net45</TargetFrameworks>
1410
<FileAlignment>512</FileAlignment>
1511
<SignAssembly>true</SignAssembly>
16-
<DelaySign>true</DelaySign>
17-
<AssemblyOriginatorKeyFile>$(RepositoryRoot)tools\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
18-
<SccProjectName>SAK</SccProjectName>
19-
<SccLocalPath>SAK</SccLocalPath>
20-
<SccAuxPath>SAK</SccAuxPath>
21-
<SccProvider>SAK</SccProvider>
2212
<DocumentationFile>$(OutputPath)$(AssemblyName).xml</DocumentationFile>
2313
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
24-
<RestorePackages>true</RestorePackages>
25-
<TargetFrameworkProfile />
26-
<NuGetPackageImportStamp>
27-
</NuGetPackageImportStamp>
28-
</PropertyGroup>
29-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
14+
<CodeAnalysisRuleSet>Microsoft.AspNet.TelemetryCorrelation.ruleset</CodeAnalysisRuleSet>
15+
<RunCodeAnalysis>true</RunCodeAnalysis>
16+
<ErrorReport>prompt</ErrorReport>
17+
<WarningLevel>4</WarningLevel>
3018
<DebugSymbols>true</DebugSymbols>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(PublicRelease)' == 'True' ">
21+
<DelaySign>true</DelaySign>
22+
<AssemblyOriginatorKeyFile>$(RepositoryRoot)tools\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
23+
<DefineConstants>$(DefineConstants);PUBLIC_RELEASE</DefineConstants>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(PublicRelease)' != 'True' ">
26+
<DelaySign>false</DelaySign>
27+
<AssemblyOriginatorKeyFile>$(RepositoryRoot)tools\Debug.snk</AssemblyOriginatorKeyFile>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
3130
<DebugType>full</DebugType>
3231
<Optimize>false</Optimize>
33-
<DefineConstants>DEBUG;TRACE</DefineConstants>
34-
<ErrorReport>prompt</ErrorReport>
35-
<WarningLevel>4</WarningLevel>
36-
<CodeAnalysisRuleSet>Microsoft.AspNet.TelemetryCorrelation.ruleset</CodeAnalysisRuleSet>
37-
<RunCodeAnalysis>true</RunCodeAnalysis>
32+
<DefineConstants>$(DefineConstants);DEBUG;TRACE</DefineConstants>
3833
</PropertyGroup>
39-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
34+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
4035
<DebugType>pdbonly</DebugType>
4136
<Optimize>true</Optimize>
42-
<DefineConstants>TRACE</DefineConstants>
43-
<ErrorReport>prompt</ErrorReport>
44-
<WarningLevel>4</WarningLevel>
45-
<CodeAnalysisRuleSet>Microsoft.AspNet.TelemetryCorrelation.ruleset</CodeAnalysisRuleSet>
46-
<RunCodeAnalysis>true</RunCodeAnalysis>
37+
<DefineConstants>$(DefineConstants);TRACE</DefineConstants>
4738
</PropertyGroup>
4839
<PropertyGroup>
49-
<DebugSymbols>true</DebugSymbols>
40+
<Company>Microsoft Corporation</Company>
41+
<!--https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets-->
42+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
43+
<IncludeSymbols>True</IncludeSymbols>
44+
<!--PackageOutputPath>Defined in Directory.Build.props</PackageOutputPath-->
45+
<PackageId>Microsoft.AspNet.TelemetryCorrelation</PackageId>
46+
<!--PackageVersion is defined in from VersionPrefix and VersionSuffix -->
47+
<!--PackageVersion></PackageVersion-->
48+
<Authors>Microsoft,aspnet</Authors>
49+
<Title>Microsoft Asp.Net telemetry correlation</Title>
50+
<Description>A module that instruments incoming request with System.Diagnostics.Activity and notifies listeners with DiagnosticsSource.</Description>
51+
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
52+
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
53+
<PackageLicenseUrl>http://www.microsoft.com/web/webpi/eula/net_library_eula_ENU.htm</PackageLicenseUrl>
54+
<PackageProjectUrl>http://www.asp.net/</PackageProjectUrl>
55+
<PackageIconUrl>http://go.microsoft.com/fwlink/?LinkID=288859</PackageIconUrl>
56+
<PackageTags>Diagnostics DiagnosticSource Correlation Activity ASP.NET</PackageTags>
57+
<RepositoryUrl>https://github.com/aspnet/Microsoft.AspNet.TelemetryCorrelation/</RepositoryUrl>
58+
<RepositoryType>Git</RepositoryType>
59+
<PackageType>Dependency</PackageType>
60+
<ContentTargetFolders>content</ContentTargetFolders>
5061
</PropertyGroup>
5162
<ItemGroup>
5263
<Reference Include="System" />
53-
<Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
54-
<HintPath>..\..\packages\System.Diagnostics.DiagnosticSource.4.5.0\lib\net45\System.Diagnostics.DiagnosticSource.dll</HintPath>
55-
</Reference>
5664
<Reference Include="System.Web" />
5765
<Reference Include="System.Xml.Linq" />
5866
<Reference Include="System.Data.DataSetExtensions" />
5967
<Reference Include="Microsoft.CSharp" />
6068
<Reference Include="System.Net.Http" />
6169
<Reference Include="System.Xml" />
62-
</ItemGroup>
63-
<ItemGroup>
64-
<Compile Include="ActivityExtensions.cs" />
65-
<Compile Include="ActivityHelper.cs" />
66-
<Compile Include="TelemetryCorrelationHttpModule.cs" />
67-
<Compile Include="AspNetTelemetryCorrelationEventSource.cs" />
68-
<Compile Include="Properties\AssemblyInfo.cs" />
70+
<!--
71+
<PackageReference Include="Desktop.Analyzers" Version="1.1.0">
72+
<PrivateAssets>All</PrivateAssets>
73+
</PackageReference>
74+
-->
75+
<PackageReference Include="StyleCop.Analyzers" Version="1.0.2">
76+
<PrivateAssets>All</PrivateAssets>
77+
</PackageReference>
78+
<PackageReference Include="MicroBuild.Core" Version="0.3.0">
79+
<PrivateAssets>All</PrivateAssets>
80+
</PackageReference>
81+
<PackageReference Include="Microsoft.Diagnostics.Tracing.EventRegister" Version="1.1.28" Condition="$(OS) == 'Windows_NT'">
82+
<PrivateAssets>All</PrivateAssets>
83+
</PackageReference>
84+
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
6985
</ItemGroup>
7086
<ItemGroup>
7187
<None Include="Microsoft.AspNet.TelemetryCorrelation.ruleset" />
72-
<None Include="packages.config"/>
73-
</ItemGroup>
74-
<ItemGroup>
7588
<None Include="35MSSharedLib1024.snk" />
7689
</ItemGroup>
7790
<ItemGroup>
78-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
79-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
80-
<Analyzer Include="..\..\packages\StyleCop.Analyzers.1.0.0\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
91+
<Content Include="web.config.install.xdt"/>
92+
<Content Include="web.config.uninstall.xdt"/>
8193
</ItemGroup>
82-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
83-
<Import Project="..\..\packages\Microsoft.Diagnostics.Tracing.EventRegister.1.1.28\build\Microsoft.Diagnostics.Tracing.EventRegister.targets" Condition="Exists('..\..\packages\Microsoft.Diagnostics.Tracing.EventRegister.1.1.28\build\Microsoft.Diagnostics.Tracing.EventRegister.targets')" />
84-
85-
86-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
87-
<PropertyGroup>
88-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
89-
</PropertyGroup>
90-
<Error Condition="!Exists('..\..\packages\Microsoft.Diagnostics.Tracing.EventRegister.1.1.28\build\Microsoft.Diagnostics.Tracing.EventRegister.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Diagnostics.Tracing.EventRegister.1.1.28\build\Microsoft.Diagnostics.Tracing.EventRegister.targets'))" />
91-
<Error Condition="!Exists('..\..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.props'))" />
92-
<Error Condition="!Exists('..\..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.targets'))" />
93-
</Target>
94-
<Import Project="..\..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.targets" Condition="Exists('..\..\packages\MicroBuild.Core.0.3.0\build\MicroBuild.Core.targets')" />
95-
<Target Name="AddToSign" AfterTargets="AfterBuild">
96-
<ItemGroup>
97-
<FilesToSign Include="$(TargetPath)" Condition="'$(SignAssembly)' == 'true'">
98-
<Authenticode>Microsoft</Authenticode>
99-
<StrongName>MsSharedLib72</StrongName>
100-
</FilesToSign>
101-
</ItemGroup>
102-
103-
<Message Text="FilesToSign: %(FilesToSign.Identity); %(FilesToSign.Authenticode); %(FilesToSign.StrongName)" Importance="high"/>
104-
</Target>
10594
</Project>
Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
1-
using System.Reflection;
2-
using System.Runtime.CompilerServices;
1+
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

5-
// General Information about an assembly is controlled through the following
6-
// set of attributes. Change these attribute values to modify the information
7-
// associated with an assembly.
8-
[assembly: AssemblyTitle("Microsoft.AspNet.TelemetryCorrelation")]
9-
[assembly: AssemblyDescription("")]
10-
[assembly: AssemblyConfiguration("")]
11-
[assembly: AssemblyCompany("Microsoft Corporation")]
12-
[assembly: AssemblyProduct("Microsoft.AspNet.TelemetryCorrelation")]
13-
[assembly: AssemblyCopyright("\x00a9 Microsoft Corporation. All rights reserved.")]
14-
[assembly: AssemblyTrademark("")]
15-
[assembly: AssemblyCulture("")]
16-
174
// Setting ComVisible to false makes the types in this assembly not visible
185
// to COM components. If you need to access a type in this assembly from
196
// COM, set the ComVisible attribute to true on that type.
@@ -22,4 +9,8 @@
229
// The following GUID is for the ID of the typelib if this project is exposed to COM
2310
[assembly: Guid("4c8e592c-c532-4cf2-80ef-3bdd0d788d12")]
2411

25-
[assembly: InternalsVisibleTo("Microsoft.AspNet.TelemetryCorrelation.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
12+
#if PUBLIC_RELEASE
13+
[assembly: InternalsVisibleTo("Microsoft.AspNet.TelemetryCorrelation.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
14+
#else
15+
[assembly: InternalsVisibleTo("Microsoft.AspNet.TelemetryCorrelation.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100319b35b21a993df850846602dae9e86d8fbb0528a0ad488ecd6414db798996534381825f94f90d8b16b72a51c4e7e07cf66ff3293c1046c045fafc354cfcc15fc177c748111e4a8c5a34d3940e7f3789dd58a928add6160d6f9cc219680253dcea88a034e7d472de51d4989c7783e19343839273e0e63a43b99ab338149dd59f")]
16+
#endif

0 commit comments

Comments
 (0)