Skip to content

Commit

Permalink
Merge pull request #3 from guitarrapc/feature/sourcelink
Browse files Browse the repository at this point in the history
feat: add source link
  • Loading branch information
guitarrapc authored Jan 20, 2025
2 parents aca80e6 + 57e5ba9 commit 7bbe4ec
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 38 deletions.
13 changes: 13 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<Project>
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<WarningsAsErrors>$(WarningsAsErrors);Nullable</WarningsAsErrors>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet -->
<PackageVersion>$(Version)</PackageVersion>
Expand All @@ -12,5 +18,12 @@
<PackageTags>Profiler, Profiling, Perfomance</PackageTags>
<NeutralLanguage>en</NeutralLanguage>
<PackageLicenseExpression>MIT</PackageLicenseExpression>

<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="all"/>
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.1" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="xunit" Version="2.9.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.1" />
<PackageVersion Include="ZLogger" Version="2.5.10" />
<PackageVersion Include="ZString" Version="2.6.0" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- NuGet -->
<Description>.NET CLR Profiler to monitor Thread, GC statistics. Datadog adaptor to send metrics.</Description>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="DogStatsD-CSharp-Client" />
Expand All @@ -12,4 +15,4 @@
<ItemGroup>
<ProjectReference Include="..\ClrProfiler\ClrProfiler.csproj" />
</ItemGroup>
</Project>
</Project>
3 changes: 3 additions & 0 deletions src/ClrProfiler/ClrProfiler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- NuGet -->
<Description>.NET CLR Profiler to monitor Thread, GC statistics</Description>
</PropertyGroup>

</Project>
63 changes: 33 additions & 30 deletions src/ClrProfiler/EventListeners/GCEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,39 @@ public GCEventListener(Func<GCEventStatistics, Task> onEventEmit, Action<Excepti
_channel = Channel.CreateBounded<GCEventStatistics>(channelOption);
}

/// GC Flow
///Foreground (Blocking) GC flow (all Gen 0/1 GCs and full blocking GCs)
///* GCSuspendEE_V1
///* GCSuspendEEEnd_V1 <– suspension is done
///* GCStart_V1
///* GCEnd_V1 <– actual GC is done
///* GCRestartEEBegin_V1
///* GCRestartEEEnd_V1 <– resumption is done.
///
///Background GC flow (Gen 2)
///* GCSuspendEE_V1
///* GCSuspendEEEnd_V1
///* GCStart_V1 <– Background GC starts
///* GCRestartEEBegin_V1
///* GCRestartEEEnd_V1 <– done with the initial suspension
///* GCSuspendEE_V1
///* GCSuspendEEEnd_V1
///* GCRestartEEBegin_V1
///* GCRestartEEEnd_V1 <– done with Background GC’s own suspension
///* GCSuspendEE_V1
///* GCSuspendEEEnd_V1 <– suspension for Foreground GC is done
///* GCStart_V1
///* GCEnd_V1 <– Foreground GC is done
///* GCRestartEEBegin_V1
///* GCRestartEEEnd_V1 <– resumption for Foreground GC is done
///* GCEnd_V1 <– Background GC ends
///<remarks>
/// ref: https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals?redirectedfrom=MSDN#background_garbage_collection
/// ref: https://mattwarren.org/2016/06/20/Visualising-the-dotNET-Garbage-Collector/
///</remarks>
// GC Flow
// Foreground (Blocking) GC flow (all Gen 0/1 GCs and full blocking GCs)
// * GCSuspendEE_V1
// * GCSuspendEEEnd_V1 <– suspension is done
// * GCStart_V1
// * GCEnd_V1 <– actual GC is done
// * GCRestartEEBegin_V1
// * GCRestartEEEnd_V1 <– resumption is done.
//
// Background GC flow (Gen 2)
// * GCSuspendEE_V1
// * GCSuspendEEEnd_V1
// * GCStart_V1 <– Background GC starts
// * GCRestartEEBegin_V1
// * GCRestartEEEnd_V1 <– done with the initial suspension
// * GCSuspendEE_V1
// * GCSuspendEEEnd_V1
// * GCRestartEEBegin_V1
// * GCRestartEEEnd_V1 <– done with Background GC’s own suspension
// * GCSuspendEE_V1
// * GCSuspendEEEnd_V1 <– suspension for Foreground GC is done
// * GCStart_V1
// * GCEnd_V1 <– Foreground GC is done
// * GCRestartEEBegin_V1
// * GCRestartEEEnd_V1 <– resumption for Foreground GC is done
// * GCEnd_V1 <– Background GC ends
/// <summary>
/// GC Event Handler
/// </summary>
/// <see>
/// https://docs.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals?redirectedfrom=MSDN#background_garbage_collection
/// https://mattwarren.org/2016/06/20/Visualising-the-dotNET-Garbage-Collector/
/// </see>
public override void EventCreatedHandler(EventWrittenEventArgs eventData)
{
try
Expand Down
2 changes: 1 addition & 1 deletion src/ClrProfiler/EventListeners/ThreadPoolEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace ClrProfiler.EventListeners;

/// <summary>
/// EventListener to collect Thread events. <see cref="ThreadStatistics"/>.
/// EventListener to collect Thread events. <see cref="ThreadInfoStatistics"/>.
/// </summary>
/// <remarks>payload: https://docs.microsoft.com/en-us/dotnet/framework/performance/thread-pool-etw-events </remarks>
public class ThreadPoolEventListener : ProfileEventListenerBase, IChannelReader
Expand Down
2 changes: 2 additions & 0 deletions src/ClrProfiler/TimerListeners/GCInfoTimerListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class GCInfoTimerListener : TimerListenerBase, IDisposable, IChannelReade
/// <summary>
/// Constructor
/// </summary>
/// <param name="onEventEmit">Trigger when Event emitted</param>
/// <param name="onEventError">Trigger when Event has error</param>
/// <param name="dueTime">The amount of time delay before timer starts.</param>
/// <param name="intervalPeriod">The time inteval between the invocation of timer.</param>
public GCInfoTimerListener(Func<GCInfoStatistics, Task> onEventEmit, Action<Exception> onEventError, TimeSpan dueTime, TimeSpan intervalPeriod)
Expand Down
2 changes: 2 additions & 0 deletions src/ClrProfiler/TimerListeners/ProcessInfoTimerListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class ProcessInfoTimerListener : TimerListenerBase, IDisposable, IChannel
/// <summary>
/// Constructor
/// </summary>
/// <param name="onEventEmit">Trigger when Event emitted</param>
/// <param name="onEventError">Trigger when Event has error</param>
/// <param name="dueTime">The amount of time delay before timer starts.</param>
/// <param name="intervalPeriod">The time inteval between the invocation of timer.</param>
public ProcessInfoTimerListener(Func<ProcessInfoStatistics, Task> onEventEmit, Action<Exception> onEventError, TimeSpan dueTime, TimeSpan intervalPeriod)
Expand Down
2 changes: 2 additions & 0 deletions src/ClrProfiler/TimerListeners/ThreadInfoTimerListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ThreadInfoTimerListener : TimerListenerBase, IDisposable, IChannelR
/// <summary>
/// Constructor
/// </summary>
/// <param name="onEventEmit">Trigger when Event emitted</param>
/// <param name="onEventError">Trigger when Event has error</param>
/// <param name="dueTime">The amount of time delay before timer starts.</param>
/// <param name="intervalPeriod">The time inteval between the invocation of timer.</param>
public ThreadInfoTimerListener(Func<ThreadInfoStatistics, Task> onEventEmit, Action<Exception> onEventError, TimeSpan dueTime, TimeSpan intervalPeriod)
Expand Down
10 changes: 5 additions & 5 deletions src/SandboxConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
};
var serverTask = Task.Run(async () => await server.ListenAsync(cts.Token), cts.Token);

// Use Datadog
var tracker = UseDatadogTracker(loggerFactory, host, port);

// Use Logger Instead
//var tracker = UseLoggerTracker(loggerFactory);
// Enable Tracker
var useDatadog = true;
var tracker = useDatadog
? UseDatadogTracker(loggerFactory, host, port)
: UseLoggerTracker(loggerFactory);

// Allocate and GC
logger.LogInformation("Press Ctrl+C to cancel execution.");
Expand Down

0 comments on commit 7bbe4ec

Please sign in to comment.