-
Notifications
You must be signed in to change notification settings - Fork 0
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
4154c34
commit 3b2ba43
Showing
32 changed files
with
661 additions
and
34 deletions.
There are no files selected for viewing
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
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
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
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,17 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = false | ||
[*.cs] | ||
|
||
# CS1591: Missing XML comment for publicly visible type or member | ||
dotnet_diagnostic.CS1591.severity = suggestion | ||
|
||
# IDE0058: Expression value is never used | ||
dotnet_diagnostic.IDE0058.severity = suggestion | ||
|
||
# IDE0053: Use expression body for lambda expression | ||
dotnet_diagnostic.IDE0053.severity = suggestion | ||
|
||
# CA1303: Do not pass literals as localized parameters | ||
dotnet_diagnostic.CA1303.severity = silent |
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,41 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsAspireHost>true</IsAspireHost> | ||
<UserSecretsId>1782dd51-972e-4551-9599-7612b341f347</UserSecretsId> | ||
<RootNamespace>NeverEnds</RootNamespace> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Aspire.Hosting.AppHost" /> | ||
<PackageReference Include="Aspire.Hosting.Redis" /> | ||
<PackageReference Include="Aspire.Hosting.PostgreSQL" /> | ||
<PackageReference Include="Aspire.Hosting.SqlServer" /> | ||
<PackageReference Include="Aspire.Hosting.RabbitMQ" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\WebApplication1\WebApplication1.csproj" /> | ||
<ProjectReference Include="..\WebApplication2\WebApplication2.csproj" /> | ||
<ProjectReference Include="..\..\..\src\Nall.Aspire.Hosting.DependsOn.All\Nall.Aspire.Hosting.DependsOn.All.csproj" IsAspireProjectResource="false" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Microsoft.Extensions.Configuration" /> | ||
<Using Include="Microsoft.Extensions.DependencyInjection" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="appsettings.Development.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="appsettings.json"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
|
||
</Project> |
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,15 @@ | ||
var builder = DistributedApplication.CreateBuilder(args); | ||
|
||
builder.Services.Configure<DependsOnOptions>( | ||
builder.Configuration.GetRequiredSection("DependsOnOptions") | ||
); | ||
|
||
var api0 = builder | ||
.AddProject<Projects.WebApplication2>("api0") | ||
.WithHealthCheck(); | ||
|
||
builder | ||
.AddProject<Projects.WebApplication1>("api") | ||
.WaitFor(api0); | ||
|
||
builder.Build().Run(); |
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,29 @@ | ||
{ | ||
"$schema": "https://json.schemastore.org/launchsettings.json", | ||
"profiles": { | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:17054;http://localhost:15173", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"DOTNET_ENVIRONMENT": "Development", | ||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21160", | ||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22080" | ||
} | ||
}, | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:15173", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development", | ||
"DOTNET_ENVIRONMENT": "Development", | ||
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19022", | ||
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20008" | ||
} | ||
} | ||
} | ||
} |
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,21 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning", | ||
"Aspire.Hosting": "Debug", | ||
"Nall.Aspire": "Debug" | ||
} | ||
}, | ||
"DependsOnOptions": { | ||
"Retry": { | ||
"MaxRetryAttempts": 10, | ||
"BackoffType": 1, | ||
"Delay": "00:00:5", | ||
"MaxDelay": "00:00:10" | ||
}, | ||
"Timeout": { | ||
"Timeout": "00:00:15" | ||
} | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Information", | ||
"Microsoft.AspNetCore": "Warning", | ||
"Aspire.Hosting.Dcp": "Warning" | ||
} | ||
} | ||
} |
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,27 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | ||
<CentralPackageTransitivePinningEnabled>false</CentralPackageTransitivePinningEnabled> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageVersion Include="Aspire.Hosting.AppHost" Version="8.0.1" /> | ||
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="8.0.1" /> | ||
<PackageVersion Include="Aspire.Hosting.RabbitMQ" Version="8.0.1" /> | ||
<PackageVersion Include="Aspire.Hosting.Redis" Version="8.0.1" /> | ||
<PackageVersion Include="Aspire.Hosting.SqlServer" Version="8.0.1" /> | ||
<PackageVersion Include="Aspire.Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.1" /> | ||
<PackageVersion Include="Aspire.Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.1" /> | ||
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.3.0" /> | ||
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="8.0.1" /> | ||
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.8.0" /> | ||
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.8.0" /> | ||
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.8.1" /> | ||
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.8.1" /> | ||
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.8.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup Label="Redundant"> | ||
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" /> | ||
<PackageVersion Include="MinVer" Version="5.0.0" /> | ||
</ItemGroup> | ||
</Project> |
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,40 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ServiceDefaults", "ServiceDefaults\ServiceDefaults.csproj", "{AF8A4ED9-06C4-452D-AEAA-618EF254AD24}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppHost", "AppHost\AppHost.csproj", "{FF4B7FB8-9AF9-4130-8969-A955CC9DB642}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication1", "WebApplication1\WebApplication1.csproj", "{98FE5FA9-5F02-46D8-A269-5C373DC72AA0}" | ||
EndProject | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication2", "WebApplication2\WebApplication2.csproj", "{07CE898D-0F4C-4DCB-9650-4E7F3CC0C615}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{AF8A4ED9-06C4-452D-AEAA-618EF254AD24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{AF8A4ED9-06C4-452D-AEAA-618EF254AD24}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{AF8A4ED9-06C4-452D-AEAA-618EF254AD24}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{AF8A4ED9-06C4-452D-AEAA-618EF254AD24}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{FF4B7FB8-9AF9-4130-8969-A955CC9DB642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{FF4B7FB8-9AF9-4130-8969-A955CC9DB642}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{FF4B7FB8-9AF9-4130-8969-A955CC9DB642}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{FF4B7FB8-9AF9-4130-8969-A955CC9DB642}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{98FE5FA9-5F02-46D8-A269-5C373DC72AA0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{98FE5FA9-5F02-46D8-A269-5C373DC72AA0}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{98FE5FA9-5F02-46D8-A269-5C373DC72AA0}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{98FE5FA9-5F02-46D8-A269-5C373DC72AA0}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{07CE898D-0F4C-4DCB-9650-4E7F3CC0C615}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{07CE898D-0F4C-4DCB-9650-4E7F3CC0C615}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{07CE898D-0F4C-4DCB-9650-4E7F3CC0C615}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{07CE898D-0F4C-4DCB-9650-4E7F3CC0C615}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
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,113 @@ | ||
namespace Microsoft.Extensions.Hosting; | ||
|
||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Diagnostics.HealthChecks; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Diagnostics.HealthChecks; | ||
using Microsoft.Extensions.Logging; | ||
using OpenTelemetry; | ||
using OpenTelemetry.Metrics; | ||
using OpenTelemetry.Trace; | ||
|
||
public static class Extensions | ||
{ | ||
public static IHostApplicationBuilder AddServiceDefaults( | ||
this IHostApplicationBuilder builder | ||
) | ||
{ | ||
builder.ConfigureOpenTelemetry(); | ||
|
||
builder.AddDefaultHealthChecks(); | ||
|
||
builder.Services.AddServiceDiscovery(); | ||
|
||
builder.Services.ConfigureHttpClientDefaults(http => | ||
{ | ||
// Turn on resilience by default | ||
http.AddStandardResilienceHandler(); | ||
|
||
// Turn on service discovery by default | ||
http.AddServiceDiscovery(); | ||
}); | ||
|
||
return builder; | ||
} | ||
|
||
public static IHostApplicationBuilder ConfigureOpenTelemetry( | ||
this IHostApplicationBuilder builder | ||
) | ||
{ | ||
builder.Logging.AddOpenTelemetry(logging => | ||
{ | ||
logging.IncludeFormattedMessage = true; | ||
logging.IncludeScopes = true; | ||
}); | ||
|
||
builder | ||
.Services.AddOpenTelemetry() | ||
.WithMetrics(metrics => | ||
{ | ||
metrics | ||
.AddAspNetCoreInstrumentation() | ||
.AddHttpClientInstrumentation() | ||
.AddRuntimeInstrumentation(); | ||
}) | ||
.WithTracing(tracing => | ||
{ | ||
tracing | ||
.AddAspNetCoreInstrumentation() | ||
// Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) | ||
//.AddGrpcClientInstrumentation() | ||
.AddHttpClientInstrumentation(); | ||
}); | ||
|
||
builder.AddOpenTelemetryExporters(); | ||
|
||
return builder; | ||
} | ||
|
||
private static IHostApplicationBuilder AddOpenTelemetryExporters( | ||
this IHostApplicationBuilder builder | ||
) | ||
{ | ||
var useOtlpExporter = !string.IsNullOrWhiteSpace( | ||
builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"] | ||
); | ||
|
||
if (useOtlpExporter) | ||
{ | ||
builder.Services.AddOpenTelemetry().UseOtlpExporter(); | ||
} | ||
|
||
return builder; | ||
} | ||
|
||
public static IHostApplicationBuilder AddDefaultHealthChecks( | ||
this IHostApplicationBuilder builder | ||
) | ||
{ | ||
builder | ||
.Services.AddHealthChecks() | ||
// Add a default liveness check to ensure app is responsive | ||
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); | ||
|
||
return builder; | ||
} | ||
|
||
public static WebApplication MapDefaultEndpoints(this WebApplication app) | ||
{ | ||
if (app.Environment.IsDevelopment()) | ||
{ | ||
// All health checks must pass for app to be considered ready to accept traffic after starting | ||
app.MapHealthChecks("/health"); | ||
|
||
// Only health checks tagged with the "live" tag must pass for app to be considered alive | ||
app.MapHealthChecks( | ||
"/alive", | ||
new HealthCheckOptions { Predicate = r => r.Tags.Contains("live") } | ||
); | ||
} | ||
|
||
return app; | ||
} | ||
} |
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,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsAspireSharedProject>true</IsAspireSharedProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
|
||
<PackageReference Include="Microsoft.Extensions.Http.Resilience" /> | ||
<PackageReference Include="Microsoft.Extensions.ServiceDiscovery" /> | ||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" /> | ||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" /> | ||
<PackageReference Include="OpenTelemetry.Instrumentation.Runtime" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.