Skip to content

Commit

Permalink
Merge release/7.x to main (#4715)
Browse files Browse the repository at this point in the history
  • Loading branch information
jander-msft committed Jun 23, 2023
2 parents 8cdfc32 + e5acdea commit 255d023
Show file tree
Hide file tree
Showing 87 changed files with 2,396 additions and 934 deletions.
3 changes: 2 additions & 1 deletion eng/AfterSolutionBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
<Import Project="$(RepoRoot)src\archives\AzureBlobStorage\ProjectsToPublish.props" />
<Import Project="$(RepoRoot)src\archives\S3Storage\ProjectsToPublish.props" />
<Import Project="$(RepoRoot)src\Microsoft.Diagnostics.Monitoring.StartupHook\ProjectsToPublish.props" />
<Import Project="$(RepoRoot)src\singlefile\dotnet-monitor\ProjectsToPublish.props" />

<!-- Only publish projects after build if opt-in and not skipped -->
<Target Name="PublishProjectsAfterBuild"
AfterTargets="Build"
Condition="'$(PublishProjectsAfterBuild)' == 'true' and '$(SkipPublishProjects)' != 'true'">
Condition="'$(PublishProjectsAfterBuild)' == 'true' and '$(CreateArchives)' != 'true' and '$(CreateSingleFileBundles)' != 'true' and '$(SkipPublishProjects)' != 'true'">
<CallTarget Targets="PublishProjects" />
</Target>

Expand Down
2 changes: 2 additions & 0 deletions eng/Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
Condition="'$(CreateArchives)' == 'true'" />
<Import Project="$(RepoRoot)src\archives\S3Storage\ProjectsToBuild.props"
Condition="'$(CreateArchives)' == 'true'" />
<Import Project="$(RepoRoot)src\singlefile\dotnet-monitor\ProjectsToBuild.props"
Condition="'$(CreateSingleFileBundles)' == 'true'" />
</Project>
1 change: 1 addition & 0 deletions eng/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<LatestTargetFramework>net8.0</LatestTargetFramework>
<LatestToolTargetFramework>$(LatestTargetFramework)</LatestToolTargetFramework>
<OlderToolTargetFramework>net6.0</OlderToolTargetFramework>
<ArtifactsNonShippingBundlesDir>$(ArtifactsDir)bundles\$(Configuration)\NonShipping\</ArtifactsNonShippingBundlesDir>
</PropertyGroup>
</Project>
1 change: 0 additions & 1 deletion eng/PublishProjects.targets
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project>

<PropertyGroup>
<SharedPublishProjectProperties>SelfContained=false</SharedPublishProjectProperties>
<SharedPublishProjectProperties>$(SharedPublishProjectProperties);UseAppHost=true</SharedPublishProjectProperties>
<SharedPublishProjectProperties>$(SharedPublishProjectProperties);PackAsTool=false</SharedPublishProjectProperties>
</PropertyGroup>
Expand Down
20 changes: 19 additions & 1 deletion eng/Publishing.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<PropertyGroup>
<PublishDependsOnTargets>$(PublishDependsOnTargets);CollectPackageArtifactFiles;CollectVersionArtifactFiles</PublishDependsOnTargets>
<PublishDependsOnTargets>$(PublishDependsOnTargets);CollectPackageArtifactFiles;CollectBundleArtifactFiles;CollectVersionArtifactFiles</PublishDependsOnTargets>
</PropertyGroup>

<ItemGroup>
Expand All @@ -18,6 +18,10 @@
<PackageFile Include="$(ArtifactsNonShippingPackagesDir)**/*.zip" IsShipping="false" />
</ItemGroup>

<ItemGroup>
<BundleFile Include="$(ArtifactsNonShippingBundlesDir)*" IsShipping="false" />
</ItemGroup>

<Target Name="CalculateBlobGroupAndBuildVersion">
<PropertyGroup>
<!--
Expand Down Expand Up @@ -200,6 +204,20 @@
</ItemGroup>
</Target>

<Target Name="CollectBundleArtifactFiles"
DependsOnTargets="CalculateBlobGroupAndBuildVersion">
<ItemGroup>
<ItemsToPushToBlobFeed Include="@(BundleFile)"
RemoveMetadata="IsShipping"
Condition="'$(_BuildVersion)' != ''">
<!-- Place blobs into versioned container so that stable versions (or lack of version) do not collide. -->
<RelativeBlobPath>diagnostics/monitor/$(_BuildVersion)/%(BundleFile.Filename)%(BundleFile.Extension)</RelativeBlobPath>
<ManifestArtifactData Condition="'%(BundleFile.IsShipping)' != 'true'">NonShipping=true</ManifestArtifactData>
<PublishFlatContainer>true</PublishFlatContainer>
</ItemsToPushToBlobFeed>
</ItemGroup>
</Target>

<Target Name="CollectVersionArtifactFiles"
DependsOnTargets="CalculateBlobGroupAndBuildVersion">
<PropertyGroup>
Expand Down
7 changes: 7 additions & 0 deletions eng/pipelines/jobs/build-archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
-skipmanaged
-skipnative
/p:SkipPublishProjects=true
/p:CreateSingleFileBundles=true
/p:ThirdPartyNoticesFilePath='$(Build.SourcesDirectory)/$(_TPNFile)'
postBuildSteps:
Expand All @@ -44,6 +45,12 @@ jobs:
inputs:
SourceFolder: '$(Build.SourcesDirectory)/artifacts/packages'
TargetFolder: '$(Build.ArtifactStagingDirectory)/artifacts/packages'

- task: CopyFiles@2
displayName: Gather Artifacts (bundles)
inputs:
SourceFolder: '$(Build.SourcesDirectory)/artifacts/bundles'
TargetFolder: '$(Build.ArtifactStagingDirectory)/artifacts/bundles'

- task: PublishBuildArtifacts@1
displayName: Publish Artifacts (Unified)
Expand Down
3 changes: 3 additions & 0 deletions src/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
<EmbeddedFiles Include="$(GeneratedAssemblyInfoFile)"/>
</ItemGroup>

<Target Name="GetDocumentationFile"
Returns="@(DocFileItem)" />

<!-- Creates artifact files related to the package that will be uploaded to blob storage during publish. -->
<Target Name="GenerateArchivePackageProjectFiles"
AfterTargets="_CreateArchive"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,13 @@
<comment>The description provided for the DumpTempFolder parameter on StorageOptions.</comment>
</data>
<data name="ErrorMessage_CredentialsMissing" xml:space="preserve">
<value>The {0} field, {1} field, or {2} field is required.</value>
<comment>Gets the format string for rejecting validation due to 3 missing fields where at least one is required.
3 Format Parameters:
<value>The {0} field, {1} field, {2} field, or {3} field is required.</value>
<comment>Gets the format string for rejecting validation due to 4 missing fields where at least one is required.
4 Format Parameters:
0. fieldNameOne: The name of the first field that is missing
1. fieldNameTwo: The name of the second field that is missing
2. fieldNameThree: The name of the third field that is missing</comment>
2. fieldNameThree: The name of the third field that is missing
3. fieldNameFour: The name of the fourth field that is missing</comment>
</data>
<data name="DisplayAttributeDescription_CollectLogsOptions_Format" xml:space="preserve">
<value>The format of the logs artifact.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ public void Start()

private static void ConfigurePipeline(ExceptionPipelineBuilder builder)
{
// Process current exception and its inner exceptions
builder.Add(next => new ExceptionDemultiplexerPipelineStep(next).Invoke);
// Prevent rethrows from being evaluated; only care about origination of exceptions.
builder.Add(next => new FilterRepeatExceptionPipelineStep(next).Invoke);
// Report exception through event source
builder.Add(next => new ExceptionEventsPipelineStep(next).Invoke);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public CurrentAppDomainExceptionSource()

private void CurrentDomain_FirstChanceException(object? sender, FirstChanceExceptionEventArgs e)
{
DateTime timestamp = DateTime.UtcNow;

if (_handlingException.Value)
{
// Exception handling is already in progress on this thread. The current exception is likely
Expand All @@ -38,7 +40,7 @@ private void CurrentDomain_FirstChanceException(object? sender, FirstChanceExcep
{
_handlingException.Value = true;

RaiseExceptionThrown(e.Exception);
RaiseExceptionThrown(e.Exception, timestamp);
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,47 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

[Event(ExceptionEvents.EventIds.ExceptionIdentifier)]
public void ExceptionIdentifier(
ulong ExceptionId,
[Event(ExceptionEvents.EventIds.ExceptionGroup)]
public void ExceptionGroup(
ulong ExceptionGroupId,
ulong ExceptionClassId,
ulong ThrowingMethodId,
int ILOffset)
{
Span<EventData> data = stackalloc EventData[4];

SetValue(ref data[ExceptionEvents.ExceptionIdentifierPayloads.ExceptionId], ExceptionId);
SetValue(ref data[ExceptionEvents.ExceptionIdentifierPayloads.ExceptionClassId], ExceptionClassId);
SetValue(ref data[ExceptionEvents.ExceptionIdentifierPayloads.ThrowingMethodId], ThrowingMethodId);
SetValue(ref data[ExceptionEvents.ExceptionIdentifierPayloads.ILOffset], ILOffset);
SetValue(ref data[ExceptionEvents.ExceptionGroupPayloads.ExceptionGroupId], ExceptionGroupId);
SetValue(ref data[ExceptionEvents.ExceptionGroupPayloads.ExceptionClassId], ExceptionClassId);
SetValue(ref data[ExceptionEvents.ExceptionGroupPayloads.ThrowingMethodId], ThrowingMethodId);
SetValue(ref data[ExceptionEvents.ExceptionGroupPayloads.ILOffset], ILOffset);

WriteEventCore(ExceptionEvents.EventIds.ExceptionIdentifier, data);
WriteEventCore(ExceptionEvents.EventIds.ExceptionGroup, data);

RestartFlushingEventTimer();
}

[Event(ExceptionEvents.EventIds.ExceptionInstance)]
public void ExceptionInstance(
ulong ExceptionId,
string? ExceptionMessage)
ulong ExceptionGroupId,
string? ExceptionMessage,
ulong[] StackFrameIds,
DateTime Timestamp,
ulong[] InnerExceptionIds)
{
Span<EventData> data = stackalloc EventData[2];
Span<EventData> data = stackalloc EventData[6];
using PinnedData namePinned = PinnedData.Create(ExceptionMessage);
Span<byte> stackFrameIdsSpan = stackalloc byte[GetArrayDataSize(StackFrameIds)];
FillArrayData(stackFrameIdsSpan, StackFrameIds);
Span<byte> innerExceptionIdsSpan = stackalloc byte[GetArrayDataSize(InnerExceptionIds)];
FillArrayData(innerExceptionIdsSpan, InnerExceptionIds);

SetValue(ref data[ExceptionEvents.ExceptionInstancePayloads.ExceptionId], ExceptionId);
SetValue(ref data[ExceptionEvents.ExceptionInstancePayloads.ExceptionGroupId], ExceptionGroupId);
SetValue(ref data[ExceptionEvents.ExceptionInstancePayloads.ExceptionMessage], namePinned);
SetValue(ref data[ExceptionEvents.ExceptionInstancePayloads.StackFrameIds], stackFrameIdsSpan);
SetValue(ref data[ExceptionEvents.ExceptionInstancePayloads.Timestamp], Timestamp.ToFileTimeUtc());
SetValue(ref data[ExceptionEvents.ExceptionInstancePayloads.InnerExceptionIds], innerExceptionIdsSpan);

WriteEventCore(ExceptionEvents.EventIds.ExceptionInstance, data);

Expand Down Expand Up @@ -111,19 +123,23 @@ public void FunctionDescription(
uint ClassToken,
ulong ModuleId,
string Name,
ulong[] TypeArgs)
ulong[] TypeArgs,
ulong[] ParameterTypes)
{
Span<EventData> data = stackalloc EventData[6];
Span<EventData> data = stackalloc EventData[7];
using PinnedData namePinned = PinnedData.Create(Name);
Span<byte> typeArgsSpan = stackalloc byte[GetArrayDataSize(TypeArgs)];
FillArrayData(typeArgsSpan, TypeArgs);
Span<byte> parameterTypesSpan = stackalloc byte[GetArrayDataSize(ParameterTypes)];
FillArrayData(parameterTypesSpan, ParameterTypes);

SetValue(ref data[NameIdentificationEvents.FunctionDescPayloads.FunctionId], FunctionId);
SetValue(ref data[NameIdentificationEvents.FunctionDescPayloads.ClassId], ClassId);
SetValue(ref data[NameIdentificationEvents.FunctionDescPayloads.ClassToken], ClassToken);
SetValue(ref data[NameIdentificationEvents.FunctionDescPayloads.ModuleId], ModuleId);
SetValue(ref data[NameIdentificationEvents.FunctionDescPayloads.Name], namePinned);
SetValue(ref data[NameIdentificationEvents.FunctionDescPayloads.TypeArgs], typeArgsSpan);
SetValue(ref data[NameIdentificationEvents.FunctionDescPayloads.ParameterTypes], parameterTypesSpan);

WriteEventCore(ExceptionEvents.EventIds.FunctionDescription, data);

Expand All @@ -146,6 +162,23 @@ public void ModuleDescription(
RestartFlushingEventTimer();
}

[Event(ExceptionEvents.EventIds.StackFrameDescription)]
public void StackFrameDescription(
ulong StackFrameId,
ulong FunctionId,
int ILOffset)
{
Span<EventData> data = stackalloc EventData[3];

SetValue(ref data[ExceptionEvents.StackFrameIdentifierPayloads.StackFrameId], StackFrameId);
SetValue(ref data[ExceptionEvents.StackFrameIdentifierPayloads.FunctionId], FunctionId);
SetValue(ref data[ExceptionEvents.StackFrameIdentifierPayloads.ILOffset], ILOffset);

WriteEventCore(ExceptionEvents.EventIds.StackFrameDescription, data);

RestartFlushingEventTimer();
}

[Event(ExceptionEvents.EventIds.TokenDescription)]
public void TokenDescription(
ulong ModuleId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Microsoft.Diagnostics.Monitoring.StartupHook.Exceptions.Eventing
{
internal sealed class ExceptionsEventSourceIdentifierCacheCallback :
ExceptionIdentifierCacheCallback
ExceptionGroupIdentifierCacheCallback
{
private readonly ExceptionsEventSource _source;

Expand All @@ -25,10 +25,10 @@ public override void OnClassData(ulong classId, ClassData data)
data.TypeArgs);
}

public override void OnExceptionIdentifier(ulong registrationId, ExceptionIdentifierData data)
public override void OnExceptionGroupData(ulong groupId, ExceptionGroupData data)
{
_source.ExceptionIdentifier(
registrationId,
_source.ExceptionGroup(
groupId,
data.ExceptionClassId,
data.ThrowingMethodId,
data.ILOffset);
Expand All @@ -42,7 +42,8 @@ public override void OnFunctionData(ulong functionId, FunctionData data)
data.ParentToken,
data.ModuleId,
data.Name,
data.TypeArgs);
data.TypeArgs,
data.ParameterTypes);
}

public override void OnModuleData(ulong moduleId, ModuleData data)
Expand All @@ -52,6 +53,14 @@ public override void OnModuleData(ulong moduleId, ModuleData data)
data.Name);
}

public override void OnStackFrameData(ulong frameId, StackFrameData data)
{
_source.StackFrameDescription(
frameId,
data.MethodId,
data.ILOffset);
}

public override void OnTokenData(ulong moduleId, uint typeToken, TokenData data)
{
_source.TokenDescription(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

namespace Microsoft.Diagnostics.Monitoring.StartupHook.Exceptions
{
internal sealed class ExceptionEventArgs : EventArgs
{
public ExceptionEventArgs(Exception exception, DateTime timestamp)
{
Exception = exception;
Timestamp = timestamp;
}

public Exception Exception { get; }

public DateTime Timestamp { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ namespace Microsoft.Diagnostics.Monitoring.StartupHook.Exceptions
/// </summary>
internal abstract class ExceptionSourceBase
{
protected void RaiseExceptionThrown(Exception ex)
protected void RaiseExceptionThrown(Exception ex, DateTime timestamp)
{
ExceptionThrown?.Invoke(this, ex);
ExceptionThrown?.Invoke(this, new ExceptionEventArgs(ex, timestamp));
}

/// <summary>
/// Event that is raised each time an exception is thrown.
/// </summary>
public event EventHandler<Exception>? ExceptionThrown;
public event EventHandler<ExceptionEventArgs>? ExceptionThrown;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Microsoft.Diagnostics.Monitoring.StartupHook.Exceptions.Identification
{
internal sealed class ExceptionIdentifierData
internal sealed class ExceptionGroupData
{
public ulong ExceptionClassId { get; set; }
public ulong ThrowingMethodId { get; set; }
Expand Down
Loading

0 comments on commit 255d023

Please sign in to comment.