-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc2e18e
commit af2d85b
Showing
4 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/Microservices/Common/ClassifiedAds.Infrastructure/Web/Endpoints/GcInforEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace ClassifiedAds.Infrastructure.Web.Endpoints; | ||
|
||
/// <summary> | ||
/// https://learn.microsoft.com/en-us/dotnet/api/system.gc | ||
/// </summary> | ||
public static class GcInforEndpoint | ||
{ | ||
public static void MapGcInforEndpoint(this IEndpointRouteBuilder builder, string path = "/gcinfor") | ||
{ | ||
builder.MapGet(path, () => | ||
{ | ||
var gcMemoryInfo = GC.GetGCMemoryInfo(); | ||
return Results.Ok(new | ||
{ | ||
Timestamp = DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss.fff zzz", CultureInfo.InvariantCulture), | ||
MachineName = Environment.MachineName, | ||
ProcessId = Environment.ProcessId, | ||
TotalMemory = GC.GetTotalMemory(false), | ||
Gen0Collections = GC.CollectionCount(0), | ||
Gen1Collections = GC.CollectionCount(1), | ||
Gen2Collections = GC.CollectionCount(2), | ||
TotalPauseDuration = GC.GetTotalPauseDuration(), | ||
GCMemoryInfo = new | ||
{ | ||
gcMemoryInfo.HighMemoryLoadThresholdBytes, | ||
gcMemoryInfo.MemoryLoadBytes, | ||
gcMemoryInfo.HeapSizeBytes, | ||
gcMemoryInfo.FragmentedBytes, | ||
gcMemoryInfo.PauseTimePercentage, | ||
gcMemoryInfo.PinnedObjectsCount | ||
} | ||
}); | ||
}); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/ModularMonolith/ClassifiedAds.Infrastructure/Web/Endpoints/GcInforEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace ClassifiedAds.Infrastructure.Web.Endpoints; | ||
|
||
/// <summary> | ||
/// https://learn.microsoft.com/en-us/dotnet/api/system.gc | ||
/// </summary> | ||
public static class GcInforEndpoint | ||
{ | ||
public static void MapGcInforEndpoint(this IEndpointRouteBuilder builder, string path = "/gcinfor") | ||
{ | ||
builder.MapGet(path, () => | ||
{ | ||
var gcMemoryInfo = GC.GetGCMemoryInfo(); | ||
return Results.Ok(new | ||
{ | ||
Timestamp = DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss.fff zzz", CultureInfo.InvariantCulture), | ||
MachineName = Environment.MachineName, | ||
ProcessId = Environment.ProcessId, | ||
TotalMemory = GC.GetTotalMemory(false), | ||
Gen0Collections = GC.CollectionCount(0), | ||
Gen1Collections = GC.CollectionCount(1), | ||
Gen2Collections = GC.CollectionCount(2), | ||
TotalPauseDuration = GC.GetTotalPauseDuration(), | ||
GCMemoryInfo = new | ||
{ | ||
gcMemoryInfo.HighMemoryLoadThresholdBytes, | ||
gcMemoryInfo.MemoryLoadBytes, | ||
gcMemoryInfo.HeapSizeBytes, | ||
gcMemoryInfo.FragmentedBytes, | ||
gcMemoryInfo.PauseTimePercentage, | ||
gcMemoryInfo.PinnedObjectsCount | ||
} | ||
}); | ||
}); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/Monolith/ClassifiedAds.Infrastructure/Web/Endpoints/GcInforEndpoint.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Routing; | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace ClassifiedAds.Infrastructure.Web.Endpoints; | ||
|
||
/// <summary> | ||
/// https://learn.microsoft.com/en-us/dotnet/api/system.gc | ||
/// </summary> | ||
public static class GcInforEndpoint | ||
{ | ||
public static void MapGcInforEndpoint(this IEndpointRouteBuilder builder, string path = "/gcinfor") | ||
{ | ||
builder.MapGet(path, () => | ||
{ | ||
var gcMemoryInfo = GC.GetGCMemoryInfo(); | ||
return Results.Ok(new | ||
{ | ||
Timestamp = DateTimeOffset.Now.ToString("yyyy-MM-dd HH:mm:ss.fff zzz", CultureInfo.InvariantCulture), | ||
MachineName = Environment.MachineName, | ||
ProcessId = Environment.ProcessId, | ||
TotalMemory = GC.GetTotalMemory(false), | ||
Gen0Collections = GC.CollectionCount(0), | ||
Gen1Collections = GC.CollectionCount(1), | ||
Gen2Collections = GC.CollectionCount(2), | ||
TotalPauseDuration = GC.GetTotalPauseDuration(), | ||
GCMemoryInfo = new | ||
{ | ||
gcMemoryInfo.HighMemoryLoadThresholdBytes, | ||
gcMemoryInfo.MemoryLoadBytes, | ||
gcMemoryInfo.HeapSizeBytes, | ||
gcMemoryInfo.FragmentedBytes, | ||
gcMemoryInfo.PauseTimePercentage, | ||
gcMemoryInfo.PinnedObjectsCount | ||
} | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,5 +285,6 @@ | |
|
||
app.MapProcessInforEndpoint(); | ||
app.MapThreadPoolInforEndpoint(); | ||
app.MapGcInforEndpoint(); | ||
|
||
app.Run(); |