Merging perf and perf.shared projects (#1841)

* Merging perf and perf.shared projects

* Removing ExcludeFromStyle tag; updating files based on StyleCop warnings
This commit is contained in:
Eddy Nakamura 2020-05-01 14:35:51 -03:00 коммит произвёл GitHub
Родитель 9637b12f97
Коммит 13217865d1
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
68 изменённых файлов: 178 добавлений и 284 удалений

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

@ -97,8 +97,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventCounterCollector.Tests
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Filtering.Shared", "WEB\Src\PerformanceCollector\Filtering.Shared\Filtering.Shared.shproj", "{568AEB4F-BA4C-47A5-9FA3-68F06CD11FED}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Perf.Shared", "WEB\Src\PerformanceCollector\Perf.Shared\Perf.Shared.shproj", "{A78F50D4-F518-4DCB-878B-526FD54CCA35}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Perf.Shared.NetFull", "WEB\Src\PerformanceCollector\Perf.Shared.NetFull\Perf.Shared.NetFull.shproj", "{0196259C-3582-4F4E-A01F-A8F9AE83B0F3}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Perf.Shared.NetStandard", "WEB\Src\PerformanceCollector\Perf.Shared.NetStandard\Perf.Shared.NetStandard.shproj", "{D13C3EC7-B300-4158-9054-216156B203BE}"
@ -202,8 +200,6 @@ Global
WEB\Src\PerformanceCollector\Filtering.Shared\Filtering.Shared.projitems*{9dc5c5e5-fc37-4e54-81fd-aa42bb934e9b}*SharedItemsImports = 5
WEB\Src\PerformanceCollector\Perf.Shared.NetFull\Perf.Shared.NetFull.projitems*{9dc5c5e5-fc37-4e54-81fd-aa42bb934e9b}*SharedItemsImports = 5
WEB\Src\PerformanceCollector\Perf.Shared.NetStandard20Net45\Perf.Shared.NetStandard20Net45.projitems*{9dc5c5e5-fc37-4e54-81fd-aa42bb934e9b}*SharedItemsImports = 5
WEB\Src\PerformanceCollector\Perf.Shared\Perf.Shared.projitems*{9dc5c5e5-fc37-4e54-81fd-aa42bb934e9b}*SharedItemsImports = 5
WEB\Src\PerformanceCollector\Perf.Shared\Perf.Shared.projitems*{a78f50d4-f518-4dcb-878b-526fd54cca35}*SharedItemsImports = 13
WEB\Src\PerformanceCollector\Perf.Shared.NetStandard20\Perf.Shared.NetStandard20.projitems*{a8ba3bd0-19ce-488d-b2bd-0b9b677f4e03}*SharedItemsImports = 13
LOGGING\src\EventSource.Shared\EventSource.Shared\EventSource.Shared.projitems*{a964de6d-9750-4013-8be2-79c2afc056e5}*SharedItemsImports = 13
NETCORE\src\Shared\Shared.projitems*{ac399f09-b465-4cfd-8d82-f1d1c5c9347e}*SharedItemsImports = 5
@ -429,7 +425,6 @@ Global
{ACE58393-3419-4FCA-87CC-C33EB756C7E4} = {005BD823-60AF-406E-AC20-842D7653FE60}
{BECFC6B1-E04E-431C-A4D9-6F330F7DE22D} = {DFCBB4ED-976C-4239-BCAF-8AA21E684E8C}
{568AEB4F-BA4C-47A5-9FA3-68F06CD11FED} = {3EDBC945-E531-4CEE-A038-A6AE1EF9AA96}
{A78F50D4-F518-4DCB-878B-526FD54CCA35} = {3EDBC945-E531-4CEE-A038-A6AE1EF9AA96}
{0196259C-3582-4F4E-A01F-A8F9AE83B0F3} = {3EDBC945-E531-4CEE-A038-A6AE1EF9AA96}
{D13C3EC7-B300-4158-9054-216156B203BE} = {3EDBC945-E531-4CEE-A038-A6AE1EF9AA96}
{30A45441-0849-48FE-AD37-5D29D0E3068A} = {3EDBC945-E531-4CEE-A038-A6AE1EF9AA96}

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

@ -35,8 +35,6 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Common.Web", "Common\Common
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HostingStartup", "HostingStartup", "{701D2D4F-B581-45A2-AF29-4F34EC5F047B}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Perf.Shared", "PerformanceCollector\Perf.Shared\Perf.Shared.shproj", "{A78F50D4-F518-4DCB-878B-526FD54CCA35}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Filtering.Shared", "PerformanceCollector\Filtering.Shared\Filtering.Shared.shproj", "{568AEB4F-BA4C-47A5-9FA3-68F06CD11FED}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HostingStartup", "HostingStartup\HostingStartup\HostingStartup.csproj", "{80F0481A-66C7-4442-96D3-5FD841132C4B}"
@ -87,7 +85,6 @@ Global
PerformanceCollector\Filtering.Shared\Filtering.Shared.projitems*{00bf736c-b562-4251-9836-ef80282956af}*SharedItemsImports = 5
PerformanceCollector\Perf.Shared.NetFull\Perf.Shared.NetFull.projitems*{00bf736c-b562-4251-9836-ef80282956af}*SharedItemsImports = 5
PerformanceCollector\Perf.Shared.NetStandard20Net45\Perf.Shared.NetStandard20Net45.projitems*{00bf736c-b562-4251-9836-ef80282956af}*SharedItemsImports = 5
PerformanceCollector\Perf.Shared\Perf.Shared.projitems*{00bf736c-b562-4251-9836-ef80282956af}*SharedItemsImports = 5
PerformanceCollector\Perf.Shared.NetFull\Perf.Shared.NetFull.projitems*{0196259c-3582-4f4e-a01f-a8f9ae83b0f3}*SharedItemsImports = 13
PerformanceCollector\Perf.Shared.NetStandard20Net45\Perf.Shared.NetStandard20Net45.projitems*{054c25dc-e545-4712-95c4-81f30cf65ce8}*SharedItemsImports = 13
TestFramework\Shared\TestFramework.Shared.projitems*{1231d63b-e7fa-4ba7-9916-fa7325db936d}*SharedItemsImports = 5
@ -103,7 +100,6 @@ Global
TestFramework\Shared\TestFramework.Shared.projitems*{9718f051-147f-4f5f-9ff3-c926430efcf7}*SharedItemsImports = 13
DependencyCollector\Shared.Tests\DependencyCollector.Shared.Tests.projitems*{9853a2a5-fd6c-4743-927e-0bfe807ad21c}*SharedItemsImports = 5
TestFramework\Shared\TestFramework.Shared.projitems*{9853a2a5-fd6c-4743-927e-0bfe807ad21c}*SharedItemsImports = 5
PerformanceCollector\Perf.Shared\Perf.Shared.projitems*{a78f50d4-f518-4dcb-878b-526fd54cca35}*SharedItemsImports = 13
PerformanceCollector\Perf.Shared.NetStandard20\Perf.Shared.NetStandard20.projitems*{a8ba3bd0-19ce-488d-b2bd-0b9b677f4e03}*SharedItemsImports = 13
DependencyCollector\Shared.Tests\DependencyCollector.Shared.Tests.projitems*{ace58393-3419-4fca-87cc-c33eb756c7e4}*SharedItemsImports = 13
TestFramework\Shared\TestFramework.Shared.projitems*{caf98d8b-9202-4cc3-83ec-c384d8eea792}*SharedItemsImports = 5
@ -247,7 +243,6 @@ Global
{ACE58393-3419-4FCA-87CC-C33EB756C7E4} = {DF56FBAD-8745-404B-94A1-E83BFC4AD7CB}
{9718F051-147F-4F5F-9FF3-C926430EFCF7} = {8CA9F9C9-DA39-4159-86F3-C52F1636715E}
{C6B569BC-6F19-42C9-A951-DA611BB0F4BE} = {A318CC6C-51C8-4BD6-BC85-2B4F35123BE7}
{A78F50D4-F518-4DCB-878B-526FD54CCA35} = {A318CC6C-51C8-4BD6-BC85-2B4F35123BE7}
{568AEB4F-BA4C-47A5-9FA3-68F06CD11FED} = {A318CC6C-51C8-4BD6-BC85-2B4F35123BE7}
{80F0481A-66C7-4442-96D3-5FD841132C4B} = {701D2D4F-B581-45A2-AF29-4F34EC5F047B}
{94127FD9-E516-4891-98D4-EF7523117F32} = {D87119AF-CD35-46F2-84A6-ED54CC42027E}

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

@ -1,82 +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>a78f50d4-f518-4dcb-878b-526fd54cca35</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)AssemblyInfo.cs" />
<Compile Include="$(MSBuildThisFileDirectory)GlobalSuppressions.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\IPerformanceCollector.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\PerformanceCollectorEventSource.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\PerformanceCounterData.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\PerformanceCounterStructure.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\PerformanceCounterUtility.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\Clock.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\IQuickPulseModuleScheduler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\IQuickPulseModuleSchedulerHandle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\QuickPulseCollectionTimeSlotManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\QuickPulseCounter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\QuickPulseDefaults.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\QuickPulseQuotaTracker.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\QuickPulseTaskModuleScheduler.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\QuickPulseThreadState.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Helpers\QuickPulseTimings.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\IQuickPulseDataAccumulatorManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\IQuickPulseServiceClient.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Process\IQuickPulsePerfLib.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Process\IQuickPulseProcessProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Process\IQuickPulseTopCpuCollector.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Process\PerfLib\CategorySample.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Process\PerfLib\CounterDefinitionSample.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Process\PerfLib\PerfLib.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Process\QuickPulseProcess.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Process\QuickPulseProcessProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\QuickPulseCollectionStateManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\QuickPulseConstants.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\QuickPulseDataAccumulator.cs">
<ExcludeFromStyleCop>True</ExcludeFromStyleCop>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\QuickPulseDataAccumulatorManager.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\QuickPulseDataSample.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\QuickPulseEventSource.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\MetricPoint.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\MonitoringDataPoint.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\ProcessCpuData.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\TelemetryDocument\DependencyTelemetryDocument.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\TelemetryDocument\EventTelemetryDocument.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\TelemetryDocument\ExceptionTelemetryDocument.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\TelemetryDocument\ITelemetryDocument.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\TelemetryDocument\RequestTelemetryDocument.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\TelemetryDocument\TelemetryDocumentType.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\QuickPulse\Service contract\TelemetryDocument\TraceTelemetryDocument.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\Timer\Timer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\Timer\TimerInterface.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\AzureWebEnvironmentVariables.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\CacheHelper.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\CounterFactory.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\CPUPercenageGauge.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\ICachedEnvironmentVariableAccess.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\ICounterValue.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\NormalizedCPUPercentageGauge.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\PerformanceCounterImplementation.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\RateCounterGauge.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\RatioCounterGauge.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\RawCounterGauge.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\SumUpCountersGauge.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Implementation\WebAppPerformanceCollector\WebAppPerformanceCollector.cs" />
<Compile Include="$(MSBuildThisFileDirectory)IQuickPulseTelemetryProcessor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PerformanceCollectorModule.cs" />
<Compile Include="$(MSBuildThisFileDirectory)PerformanceCounterCollectionRequest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)QuickPulseTelemetryModule.cs">
<ExcludeFromStyleCop>True</ExcludeFromStyleCop>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)QuickPulseTelemetryProcessor.cs">
<ExcludeFromStyleCop>True</ExcludeFromStyleCop>
</Compile>
</ItemGroup>
</Project>

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

@ -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>a78f50d4-f518-4dcb-878b-526fd54cca35</ProjectGuid>
<MinimumVisualStudioVersion>15.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="Perf.Shared.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>

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

@ -6,10 +6,10 @@
internal interface IQuickPulseTelemetryProcessor
{
Uri ServiceEndpoint { get; set; }
void StartCollection(IQuickPulseDataAccumulatorManager accumulatorManager, Uri serviceEndpoint, TelemetryConfiguration configuration, bool disableFullTelemetryItems = false);
void StopCollection();
Uri ServiceEndpoint { get; set; }
}
}

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

@ -11,7 +11,7 @@
/// </summary>
/// <remarks>This is performance-critical DTO that needs to be quickly accessed in a thread-safe manner.</remarks>
internal class QuickPulseDataAccumulator
{
{
public DateTimeOffset? StartTimestamp = null;
public DateTimeOffset? EndTimestamp = null;
@ -35,12 +35,12 @@
public bool GlobalDocumentQuotaReached;
/// <summary>
/// 2^19 - 1.
/// MaxCount = 2^19 - 1.
/// </summary>
private const long MaxCount = 524287;
/// <summary>
/// 2^44 - 1.
/// MaxDuration = 2^44 - 1.
/// </summary>
private const long MaxDuration = 17592186044415;
@ -48,7 +48,19 @@
{
this.CollectionConfigurationAccumulator = new CollectionConfigurationAccumulator(collectionConfiguration);
}
public long AIRequestCount => QuickPulseDataAccumulator.DecodeCountAndDuration(this.AIRequestCountAndDurationInTicks).Item1;
public long AIRequestDurationInTicks => QuickPulseDataAccumulator.DecodeCountAndDuration(this.AIRequestCountAndDurationInTicks).Item2;
public long AIDependencyCallCount => QuickPulseDataAccumulator.DecodeCountAndDuration(this.AIDependencyCallCountAndDurationInTicks).Item1;
public long AIDependencyCallDurationInTicks => QuickPulseDataAccumulator.DecodeCountAndDuration(this.AIDependencyCallCountAndDurationInTicks).Item2;
public ConcurrentStack<ITelemetryDocument> TelemetryDocuments { get; set; } = new ConcurrentStack<ITelemetryDocument>();
public CollectionConfigurationAccumulator CollectionConfigurationAccumulator { get; private set; }
public static long EncodeCountAndDuration(long count, long duration)
{
if (count > MaxCount || duration > MaxDuration)
@ -64,17 +76,5 @@
{
return Tuple.Create(countAndDuration >> 44, countAndDuration & MaxDuration);
}
public long AIRequestCount => QuickPulseDataAccumulator.DecodeCountAndDuration(this.AIRequestCountAndDurationInTicks).Item1;
public long AIRequestDurationInTicks => QuickPulseDataAccumulator.DecodeCountAndDuration(this.AIRequestCountAndDurationInTicks).Item2;
public long AIDependencyCallCount => QuickPulseDataAccumulator.DecodeCountAndDuration(this.AIDependencyCallCountAndDurationInTicks).Item1;
public long AIDependencyCallDurationInTicks => QuickPulseDataAccumulator.DecodeCountAndDuration(this.AIDependencyCallCountAndDurationInTicks).Item2;
public ConcurrentStack<ITelemetryDocument> TelemetryDocuments { get; set; } = new ConcurrentStack<ITelemetryDocument>();
public CollectionConfigurationAccumulator CollectionConfigurationAccumulator { get; private set; }
}
}

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

@ -82,7 +82,6 @@
</ItemGroup>
<Import Project="..\Filtering.Shared\Filtering.Shared.projitems" Label="Shared" />
<Import Project="..\Perf.Shared\Perf.Shared.projitems" Label="Shared" />
<Import Project="..\..\Common\Common.projitems" Label="Shared" />
<Import Project="..\Perf.Shared.NetFull\Perf.Shared.NetFull.projitems" Label="Shared" Condition="'$(TargetFramework)' == 'net45'" />
<Import Project="..\Perf.Shared.NetStandard20Net45\Perf.Shared.NetStandard20Net45.projitems" Label="Shared" Condition="'$(TargetFramework)' == 'net45' OR '$(TargetFramework)' == 'netstandard2.0'" />

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

@ -27,9 +27,9 @@
public sealed class QuickPulseTelemetryModule : ITelemetryModule, IDisposable
{
#if NETSTANDARD1_6 || NETSTANDARD2_0
internal static IQuickPulseModuleScheduler moduleScheduler = QuickPulseTaskModuleScheduler.Instance;
internal static IQuickPulseModuleScheduler ModuleScheduler = QuickPulseTaskModuleScheduler.Instance;
#else
internal static IQuickPulseModuleScheduler moduleScheduler = QuickPulseThreadModuleScheduler.Instance;
internal static IQuickPulseModuleScheduler ModuleScheduler = QuickPulseThreadModuleScheduler.Instance;
#endif
internal readonly LinkedList<IQuickPulseTelemetryProcessor> TelemetryProcessors = new LinkedList<IQuickPulseTelemetryProcessor>();
@ -181,7 +181,7 @@
this.timeProvider = this.timeProvider ?? new Clock();
this.topCpuCollector = this.topCpuCollector
?? new QuickPulseTopCpuCollector(this.timeProvider, new QuickPulseProcessProvider(PerfLib.GetPerfLib()));
this.timings = timings ?? QuickPulseTimings.Default;
this.timings = this.timings ?? QuickPulseTimings.Default;
CollectionConfigurationError[] errors;
this.collectionConfiguration = new CollectionConfiguration(
@ -259,6 +259,41 @@
}
}
private static string GetInstanceName(TelemetryConfiguration configuration)
{
// we need to initialize an item to get instance information
var fakeItem = new EventTelemetry();
try
{
new TelemetryClient(configuration).Initialize(fakeItem);
}
catch (Exception)
{
// we don't care what happened there
}
return string.IsNullOrWhiteSpace(fakeItem.Context?.Cloud?.RoleInstance) ? Environment.MachineName : fakeItem.Context.Cloud.RoleInstance;
}
private static string GetStreamId()
{
return Guid.NewGuid().ToStringInvariant("N");
}
private static QuickPulseDataSample CreateDataSample(
QuickPulseDataAccumulator accumulator,
IEnumerable<Tuple<PerformanceCounterData, double>> perfData,
IEnumerable<Tuple<string, int>> topCpuData,
bool topCpuDataAccessDenied)
{
return new QuickPulseDataSample(
accumulator,
perfData.ToDictionary(tuple => tuple.Item1.ReportAs, tuple => tuple),
topCpuData,
topCpuDataAccessDenied);
}
private void UpdatePerformanceCollector(IEnumerable<Tuple<string, string>> performanceCountersToCollect, out CollectionConfigurationError[] errors)
{
// all counters that need to be collected according to the new configuration - remove duplicates
@ -321,7 +356,7 @@
string.Format(CultureInfo.InvariantCulture, "Unexpected error processing counter '{0}': {1}", counter, e.Message),
e,
Tuple.Create("MetricId", counter.Item1)));
QuickPulseEventSource.Log.CounterRegistrationFailedEvent(e.Message, counter.Item2);
QuickPulseEventSource.Log.CounterRegistrationFailedEvent(e.Message, counter.Item2);
}
}
@ -331,9 +366,9 @@
private void CreateStateThread()
{
this.stateThread = QuickPulseTelemetryModule.moduleScheduler.Execute(this.StateThreadWorker);
this.stateThread = QuickPulseTelemetryModule.ModuleScheduler.Execute(this.StateThreadWorker);
}
private void InitializeServiceClient(TelemetryConfiguration configuration)
{
if (this.ServiceClient != null)
@ -376,7 +411,7 @@
serviceEndpointUri,
instanceName,
streamId,
ServerId,
this.ServerId,
assemblyVersion,
this.timeProvider,
isWebApp,
@ -397,41 +432,6 @@
assemblyVersion));
}
private static string GetInstanceName(TelemetryConfiguration configuration)
{
// we need to initialize an item to get instance information
var fakeItem = new EventTelemetry();
try
{
new TelemetryClient(configuration).Initialize(fakeItem);
}
catch (Exception)
{
// we don't care what happened there
}
return string.IsNullOrWhiteSpace(fakeItem.Context?.Cloud?.RoleInstance) ? Environment.MachineName : fakeItem.Context.Cloud.RoleInstance;
}
private static string GetStreamId()
{
return Guid.NewGuid().ToStringInvariant("N");
}
private static QuickPulseDataSample CreateDataSample(
QuickPulseDataAccumulator accumulator,
IEnumerable<Tuple<PerformanceCounterData, double>> perfData,
IEnumerable<Tuple<string, int>> topCpuData,
bool topCpuDataAccessDenied)
{
return new QuickPulseDataSample(
accumulator,
perfData.ToDictionary(tuple => tuple.Item1.ReportAs, tuple => tuple),
topCpuData,
topCpuDataAccessDenied);
}
private void StateThreadWorker(CancellationToken cancellationToken)
{
SdkInternalOperationsMonitor.Enter();
@ -628,7 +628,7 @@
private void CreateCollectionThread()
{
this.collectionThread = QuickPulseTelemetryModule.moduleScheduler.Execute(this.CollectionThreadWorker);
this.collectionThread = QuickPulseTelemetryModule.ModuleScheduler.Execute(this.CollectionThreadWorker);
}
private void EndCollectionThread()

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

@ -22,11 +22,6 @@
/// </summary>
public class QuickPulseTelemetryProcessor : ITelemetryProcessor, ITelemetryModule, IQuickPulseTelemetryProcessor
{
/// <summary>
/// An overall, cross-stream quota tracker.
/// </summary>
private readonly QuickPulseQuotaTracker globalQuotaTracker;
/// <summary>
/// 1.0 - initial release.
/// 1.1 - added DocumentStreamId, EventTelemetryDocument, TraceTelemetryDocument.
@ -45,19 +40,12 @@
private const string ExceptionMessageSeparator = " <--- ";
private IQuickPulseDataAccumulatorManager dataAccumulatorManager = null;
/// <summary>
/// Gets or sets an endpoint that is compared against telemetry to remove our requests from customer telemetry.
/// An overall, cross-stream quota tracker.
/// </summary>
/// <remarks>
/// This is set from the QuickPulseTelemetryModule.
/// </remarks>
Uri IQuickPulseTelemetryProcessor.ServiceEndpoint
{
get { return this.serviceEndpoint; }
set { this.serviceEndpoint = value; }
}
private readonly QuickPulseQuotaTracker globalQuotaTracker;
private IQuickPulseDataAccumulatorManager dataAccumulatorManager = null;
private Uri serviceEndpoint = QuickPulseDefaults.QuickPulseServiceEndpoint;
@ -101,6 +89,18 @@
initialGlobalTelemetryQuota ?? InitialGlobalTelemetryQuota);
}
/// <summary>
/// Gets or sets an endpoint that is compared against telemetry to remove our requests from customer telemetry.
/// </summary>
/// <remarks>
/// This is set from the QuickPulseTelemetryModule.
/// </remarks>
Uri IQuickPulseTelemetryProcessor.ServiceEndpoint
{
get { return this.serviceEndpoint; }
set { this.serviceEndpoint = value; }
}
/// <summary>
/// Gets or sets a value indicating whether request properties
/// which were disabled via "RequestTrackingTelemetryModule.DisableTrackingProperties" should be evaluated.
@ -195,46 +195,6 @@
}
}
private ITelemetryDocument ConvertRequestToTelemetryDocument(RequestTelemetry requestTelemetry)
{
var url = requestTelemetry.Url;
#if NET45
if (this.EvaluateDisabledTrackingProperties && url == null)
{
try
{
// some of the requestTelemetry properties might be deferred by using RequestTrackingTelemetryModule.DisableTrackingProperties.
// evaluate them now
// note: RequestTrackingUtilities.UpdateRequestTelemetryFromRequest is not used here, since not all fields need to be populated
var request = System.Web.HttpContext.Current?.Request;
url = request?.Unvalidated.Url;
}
catch (Exception e)
{
QuickPulseEventSource.Log.UnknownErrorEvent(e.ToInvariantString());
}
}
#endif
ITelemetryDocument telemetryDocument = new RequestTelemetryDocument()
{
Id = Guid.NewGuid(),
Version = TelemetryDocumentContractVersion,
Timestamp = requestTelemetry.Timestamp,
OperationId = TruncateValue(requestTelemetry.Context?.Operation?.Id),
Name = TruncateValue(requestTelemetry.Name),
Success = requestTelemetry.Success,
Duration = requestTelemetry.Duration,
ResponseCode = requestTelemetry.ResponseCode,
Url = url,
Properties = GetProperties(requestTelemetry),
};
SetCommonTelemetryDocumentData(telemetryDocument, requestTelemetry);
return telemetryDocument;
}
private static ITelemetryDocument ConvertDependencyToTelemetryDocument(DependencyTelemetry dependencyTelemetry)
{
ITelemetryDocument telemetryDocument = new DependencyTelemetryDocument()
@ -372,38 +332,6 @@
}
}
private static KeyValuePair<string, string>[] GetProperties(ISupportProperties telemetry, string specialPropertyName = null)
{
Dictionary<string, string> properties = null;
if (telemetry.Properties != null && telemetry.Properties.Count > 0)
{
properties = new Dictionary<string, string>(MaxPropertyCount + 1);
foreach (var prop in
telemetry.Properties.Where(p => !string.Equals(p.Key, specialPropertyName, StringComparison.Ordinal)).Take(MaxPropertyCount))
{
string truncatedKey = TruncateValue(prop.Key);
if (!properties.ContainsKey(truncatedKey))
{
properties.Add(truncatedKey, TruncateValue(prop.Value));
}
}
if (specialPropertyName != null)
{
string specialPropertyValue;
if (telemetry.Properties.TryGetValue(specialPropertyName, out specialPropertyValue))
{
properties.Add(TruncateValue(specialPropertyName), TruncateValue(specialPropertyValue));
}
}
}
return properties != null ? properties.ToArray() : null;
}
private static bool IsRequestSuccessful(RequestTelemetry request)
{
string responseCode = request.ResponseCode;
@ -438,6 +366,67 @@
return value;
}
private static KeyValuePair<string, string>[] GetProperties(ISupportProperties telemetry, string specialPropertyName = null)
{
Dictionary<string, string> properties = null;
if (telemetry.Properties != null && telemetry.Properties.Count > 0)
{
properties = new Dictionary<string, string>(MaxPropertyCount + 1);
foreach (var prop in
telemetry.Properties.Where(p => !string.Equals(p.Key, specialPropertyName, StringComparison.Ordinal)).Take(MaxPropertyCount))
{
string truncatedKey = TruncateValue(prop.Key);
if (!properties.ContainsKey(truncatedKey))
{
properties.Add(truncatedKey, TruncateValue(prop.Value));
}
}
if (specialPropertyName != null)
{
string specialPropertyValue;
if (telemetry.Properties.TryGetValue(specialPropertyName, out specialPropertyValue))
{
properties.Add(TruncateValue(specialPropertyName), TruncateValue(specialPropertyValue));
}
}
}
return properties != null ? properties.ToArray() : null;
}
private static void ProcessMetrics<TTelemetry>(
CollectionConfigurationAccumulator configurationAccumulatorLocal,
IEnumerable<CalculatedMetric<TTelemetry>> metrics,
TTelemetry telemetry,
out CollectionConfigurationError[] filteringErrors,
ref string projectionError)
{
filteringErrors = ArrayExtensions.Empty<CollectionConfigurationError>();
foreach (CalculatedMetric<TTelemetry> metric in metrics)
{
if (metric.CheckFilters(telemetry, out filteringErrors))
{
// the telemetry document has passed the filters, count it in and project
try
{
double projection = metric.Project(telemetry);
configurationAccumulatorLocal.MetricAccumulators[metric.Id].AddValue(projection);
}
catch (Exception e)
{
// most likely the projection did not result in a value parsable by double.Parse()
projectionError = e.ToString();
}
}
}
}
private void ProcessTelemetry(ITelemetry telemetry)
{
// only process items that are going to the instrumentation key that our module is initialized with
@ -610,6 +599,46 @@
}
}
private ITelemetryDocument ConvertRequestToTelemetryDocument(RequestTelemetry requestTelemetry)
{
var url = requestTelemetry.Url;
#if NET45
if (this.EvaluateDisabledTrackingProperties && url == null)
{
try
{
// some of the requestTelemetry properties might be deferred by using RequestTrackingTelemetryModule.DisableTrackingProperties.
// evaluate them now
// note: RequestTrackingUtilities.UpdateRequestTelemetryFromRequest is not used here, since not all fields need to be populated
var request = System.Web.HttpContext.Current?.Request;
url = request?.Unvalidated.Url;
}
catch (Exception e)
{
QuickPulseEventSource.Log.UnknownErrorEvent(e.ToInvariantString());
}
}
#endif
ITelemetryDocument telemetryDocument = new RequestTelemetryDocument()
{
Id = Guid.NewGuid(),
Version = TelemetryDocumentContractVersion,
Timestamp = requestTelemetry.Timestamp,
OperationId = TruncateValue(requestTelemetry.Context?.Operation?.Id),
Name = TruncateValue(requestTelemetry.Name),
Success = requestTelemetry.Success,
Duration = requestTelemetry.Duration,
ResponseCode = requestTelemetry.ResponseCode,
Url = url,
Properties = GetProperties(requestTelemetry),
};
SetCommonTelemetryDocumentData(telemetryDocument, requestTelemetry);
return telemetryDocument;
}
private ITelemetryDocument CreateTelemetryDocument<TTelemetry>(
TTelemetry telemetry,
IEnumerable<DocumentStream> documentStreams,
@ -644,35 +673,6 @@
return telemetryDocument;
}
private static void ProcessMetrics<TTelemetry>(
CollectionConfigurationAccumulator configurationAccumulatorLocal,
IEnumerable<CalculatedMetric<TTelemetry>> metrics,
TTelemetry telemetry,
out CollectionConfigurationError[] filteringErrors,
ref string projectionError)
{
filteringErrors = ArrayExtensions.Empty<CollectionConfigurationError>();
foreach (CalculatedMetric<TTelemetry> metric in metrics)
{
if (metric.CheckFilters(telemetry, out filteringErrors))
{
// the telemetry document has passed the filters, count it in and project
try
{
double projection = metric.Project(telemetry);
configurationAccumulatorLocal.MetricAccumulators[metric.Id].AddValue(projection);
}
catch (Exception e)
{
// most likely the projection did not result in a value parsable by double.Parse()
projectionError = e.ToString();
}
}
}
}
private void UpdateExceptionAggregates()
{
Interlocked.Increment(ref this.dataAccumulatorManager.CurrentDataAccumulator.AIExceptionCount);