InternalsVisibleTo Microsoft.AI.ServerTelemetryChannel

This commit is contained in:
Rajkumar Rangaraj 2021-04-13 18:23:12 -07:00
Родитель c9d95e701e
Коммит 76a735b836
12 изменённых файлов: 3 добавлений и 144 удалений

Просмотреть файл

@ -36,17 +36,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ApplicationInsigh
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelemetryChannel", "src\ServerTelemetryChannel\TelemetryChannel.csproj", "{3273D899-D9B3-44FE-B3AB-578E18B2EF90}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Common.Base", "src\Common\Common\Common.Base.shproj", "{936AF739-4297-4016-9D70-4280042709BE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.ApplicationInsights.Tests", "Test\Microsoft.ApplicationInsights.Test\Microsoft.ApplicationInsights.Tests\Microsoft.ApplicationInsights.Tests.csproj", "{EF007559-EA01-4D4A-9BEB-8CC661797BE5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TelemetryChannel.Tests", "Test\ServerTelemetryChannel.Test\TelemetryChannel.Tests\TelemetryChannel.Tests.csproj", "{7AB3D817-9CAC-45A7-BA4D-25FA4D690DA4}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Common\Common\Common.projitems*{3273d899-d9b3-44fe-b3ab-578e18b2ef90}*SharedItemsImports = 5
src\Common\Common\Common.projitems*{936af739-4297-4016-9d70-4280042709be}*SharedItemsImports = 13
src\Common\Common\Common.projitems*{e9ecee96-dd50-42f6-9f33-0978cdfa15ed}*SharedItemsImports = 5
Test\TestFramework\Shared\TestFramework.Shared.projitems*{f76c6cbd-29b0-4564-bdcb-c969f8fec136}*SharedItemsImports = 13
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution

Просмотреть файл

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>936af739-4297-4016-9d70-4280042709be</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Common.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

Просмотреть файл

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>936af739-4297-4016-9d70-4280042709be</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Microsoft.ApplicationInsights.Common</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Extensions\DateTimeExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Extensions\ExceptionExtensions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)InterlockedThrottle.cs" />
</ItemGroup>
</Project>

Просмотреть файл

@ -34,6 +34,5 @@
<AdditionalFiles Include="$(PublicApiRoot)\$(AssemblyName).dll\$(TargetFramework)\PublicAPI.Shipped.txt" />
<AdditionalFiles Include="$(PublicApiRoot)\$(AssemblyName).dll\$(TargetFramework)\PublicAPI.Unshipped.txt" />
</ItemGroup>
<Import Project="..\Common\Common\Common.projitems" Label="Shared" />
</Project>

Просмотреть файл

@ -8,6 +8,7 @@ using System.Runtime.InteropServices;
[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.TelemetryChannel.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.AspNetCore.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("Microsoft.ApplicationInsights.WorkerService.Tests, PublicKey=" + AssemblyInfo.PublicKey)]
[assembly: InternalsVisibleTo("Microsoft.AI.ServerTelemetryChannel, PublicKey=" + AssemblyInfo.PublicKey)]
// Assembly dynamically generated by Moq in unit tests
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=" + AssemblyInfo.MoqPublicKey)]

Просмотреть файл

@ -10,16 +10,3 @@ using System.Runtime.InteropServices;
// Assembly dynamically generated by Moq in unit tests
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=" + AssemblyInfo.MoqPublicKey)]
internal static class AssemblyInfo
{
#if PUBLIC_RELEASE
// Public key; assemblies are delay signed.
public const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9";
#else
// Internal key; assemblies are public signed.
public const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100319b35b21a993df850846602dae9e86d8fbb0528a0ad488ecd6414db798996534381825f94f90d8b16b72a51c4e7e07cf66ff3293c1046c045fafc354cfcc15fc177c748111e4a8c5a34d3940e7f3789dd58a928add6160d6f9cc219680253dcea88a034e7d472de51d4989c7783e19343839273e0e63a43b99ab338149dd59f";
#endif
public const string MoqPublicKey = "0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7";
}

Просмотреть файл

@ -1,94 +0,0 @@
namespace Microsoft.ApplicationInsights
{
using System;
using System.Diagnostics;
#if NET452 || NET46
using System.Diagnostics.CodeAnalysis;
using System.Threading;
#endif
internal class PreciseTimestamp
{
/// <summary>
/// Multiplier to convert Stopwatch ticks to TimeSpan ticks.
/// </summary>
internal static readonly double StopwatchTicksToTimeSpanTicks = (double)TimeSpan.TicksPerSecond / Stopwatch.Frequency;
#if NET452 || NET46
private static readonly Timer SyncTimeUpdater;
private static TimeSync timeSync = new TimeSync();
[SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline", Justification = "Enforcing static fields initialization.")]
static PreciseTimestamp()
{
SyncTimeUpdater = InitializeSyncTimer();
}
#endif
/// <summary>
/// Returns high resolution (1 DateTime tick) current UTC DateTime.
/// </summary>
public static DateTimeOffset GetUtcNow()
{
#if NET452 || NET46
// DateTime.UtcNow accuracy on .NET Framework is ~16ms, this method
// uses combination of Stopwatch and DateTime to calculate accurate UtcNow.
var tmp = timeSync;
// Timer ticks need to be converted to DateTime ticks
long dateTimeTicksDiff = (long)((Stopwatch.GetTimestamp() - tmp.SyncStopwatchTicks) * StopwatchTicksToTimeSpanTicks);
// DateTime.AddSeconds (or Milliseconds) rounds value to 1 ms, use AddTicks to prevent it
return tmp.SyncUtcNow.AddTicks(dateTimeTicksDiff);
#else
return DateTimeOffset.UtcNow;
#endif
}
#if NET452 || NET46
private static void Sync()
{
// wait for DateTime.UtcNow update to the next granular value
Thread.Sleep(1);
timeSync = new TimeSync();
}
private static Timer InitializeSyncTimer()
{
Timer timer;
// Don't capture the current ExecutionContext and its AsyncLocals onto the timer causing them to live forever
bool restoreFlow = false;
try
{
if (!ExecutionContext.IsFlowSuppressed())
{
ExecutionContext.SuppressFlow();
restoreFlow = true;
}
// fire timer every 2 hours, Stopwatch is not very precise over long periods of time,
// so we need to correct it from time to time
// https://docs.microsoft.com/en-us/windows/desktop/SysInfo/acquiring-high-resolution-time-stamps
timer = new Timer(s => { Sync(); }, null, 0, 7200000);
}
finally
{
// Restore the current ExecutionContext
if (restoreFlow)
{
ExecutionContext.RestoreFlow();
}
}
return timer;
}
private class TimeSync
{
public readonly DateTimeOffset SyncUtcNow = DateTimeOffset.UtcNow;
public readonly long SyncStopwatchTicks = Stopwatch.GetTimestamp();
}
#endif
}
}

Просмотреть файл

@ -9,6 +9,7 @@
using Microsoft.ApplicationInsights.Common;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation;
using TelemetryBuffer = Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.Implementation.TelemetryBuffer;
/// <summary>
/// Represents a communication channel for sending telemetry to Application Insights via HTTP/S.

Просмотреть файл

@ -44,5 +44,4 @@
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.7.0" />
</ItemGroup>
<Import Project="..\Common\Common\Common.projitems" Label="Shared" />
</Project>