diff --git a/SlipItIn.AppHost/AppHost.cs b/SlipItIn.AppHost/AppHost.cs new file mode 100644 index 0000000..f591e7f --- /dev/null +++ b/SlipItIn.AppHost/AppHost.cs @@ -0,0 +1,5 @@ +var builder = DistributedApplication.CreateBuilder(args); + +builder.AddProject("slipitin"); + +builder.Build().Run(); diff --git a/SlipItIn.AppHost/Properties/launchSettings.json b/SlipItIn.AppHost/Properties/launchSettings.json new file mode 100644 index 0000000..1386db3 --- /dev/null +++ b/SlipItIn.AppHost/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:17039;http://localhost:15202", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21166", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "https://localhost:23040", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22037" + } + }, + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15202", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19020", + "ASPIRE_DASHBOARD_MCP_ENDPOINT_URL": "http://localhost:18171", + "ASPIRE_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20124" + } + } + } +} diff --git a/SlipItIn.AppHost/SlipItIn.AppHost.csproj b/SlipItIn.AppHost/SlipItIn.AppHost.csproj new file mode 100644 index 0000000..a687062 --- /dev/null +++ b/SlipItIn.AppHost/SlipItIn.AppHost.csproj @@ -0,0 +1,21 @@ + + + + Exe + net10.0 + enable + enable + ca019835-4f70-4807-86e3-3a4ff7bb0df3 + + + + + + + + + TargetFramework=net10.0 + + + + diff --git a/SlipItIn.AppHost/appsettings.Development.json b/SlipItIn.AppHost/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/SlipItIn.AppHost/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/SlipItIn.AppHost/appsettings.json b/SlipItIn.AppHost/appsettings.json new file mode 100644 index 0000000..31c092a --- /dev/null +++ b/SlipItIn.AppHost/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/SlipItIn.ServiceDefaults/Extensions.cs b/SlipItIn.ServiceDefaults/Extensions.cs new file mode 100644 index 0000000..b72c875 --- /dev/null +++ b/SlipItIn.ServiceDefaults/Extensions.cs @@ -0,0 +1,127 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Diagnostics.HealthChecks; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Diagnostics.HealthChecks; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.ServiceDiscovery; +using OpenTelemetry; +using OpenTelemetry.Metrics; +using OpenTelemetry.Trace; + +namespace Microsoft.Extensions.Hosting; + +// Adds common Aspire services: service discovery, resilience, health checks, and OpenTelemetry. +// This project should be referenced by each service project in your solution. +// To learn more about using this project, see https://aka.ms/dotnet/aspire/service-defaults +public static class Extensions +{ + private const string HealthEndpointPath = "/health"; + private const string AlivenessEndpointPath = "/alive"; + + public static TBuilder AddServiceDefaults(this TBuilder builder) where TBuilder : IHostApplicationBuilder + { + 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(); + }); + + // Uncomment the following to restrict the allowed schemes for service discovery. + // builder.Services.Configure(options => + // { + // options.AllowedSchemes = ["https"]; + // }); + + return builder; + } + + public static TBuilder ConfigureOpenTelemetry(this TBuilder builder) where TBuilder : IHostApplicationBuilder + { + builder.Logging.AddOpenTelemetry(logging => + { + logging.IncludeFormattedMessage = true; + logging.IncludeScopes = true; + }); + + builder.Services.AddOpenTelemetry() + .WithMetrics(metrics => + { + metrics.AddAspNetCoreInstrumentation() + .AddHttpClientInstrumentation() + .AddRuntimeInstrumentation(); + }) + .WithTracing(tracing => + { + tracing.AddSource(builder.Environment.ApplicationName) + .AddAspNetCoreInstrumentation(tracing => + // Exclude health check requests from tracing + tracing.Filter = context => + !context.Request.Path.StartsWithSegments(HealthEndpointPath) + && !context.Request.Path.StartsWithSegments(AlivenessEndpointPath) + ) + // Uncomment the following line to enable gRPC instrumentation (requires the OpenTelemetry.Instrumentation.GrpcNetClient package) + //.AddGrpcClientInstrumentation() + .AddHttpClientInstrumentation(); + }); + + builder.AddOpenTelemetryExporters(); + + return builder; + } + + private static TBuilder AddOpenTelemetryExporters(this TBuilder builder) where TBuilder : IHostApplicationBuilder + { + var useOtlpExporter = !string.IsNullOrWhiteSpace(builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]); + + if (useOtlpExporter) + { + builder.Services.AddOpenTelemetry().UseOtlpExporter(); + } + + // Uncomment the following lines to enable the Azure Monitor exporter (requires the Azure.Monitor.OpenTelemetry.AspNetCore package) + //if (!string.IsNullOrEmpty(builder.Configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"])) + //{ + // builder.Services.AddOpenTelemetry() + // .UseAzureMonitor(); + //} + + return builder; + } + + public static TBuilder AddDefaultHealthChecks(this TBuilder builder) where TBuilder : IHostApplicationBuilder + { + 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) + { + // Adding health checks endpoints to applications in non-development environments has security implications. + // See https://aka.ms/dotnet/aspire/healthchecks for details before enabling these endpoints in non-development environments. + if (app.Environment.IsDevelopment()) + { + // All health checks must pass for app to be considered ready to accept traffic after starting + app.MapHealthChecks(HealthEndpointPath); + + // Only health checks tagged with the "live" tag must pass for app to be considered alive + app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions + { + Predicate = r => r.Tags.Contains("live") + }); + } + + return app; + } +} diff --git a/SlipItIn.ServiceDefaults/SlipItIn.ServiceDefaults.csproj b/SlipItIn.ServiceDefaults/SlipItIn.ServiceDefaults.csproj new file mode 100644 index 0000000..e83ec88 --- /dev/null +++ b/SlipItIn.ServiceDefaults/SlipItIn.ServiceDefaults.csproj @@ -0,0 +1,22 @@ + + + + net10.0 + enable + enable + true + + + + + + + + + + + + + + + diff --git a/SlipItIn.slnx b/SlipItIn.slnx new file mode 100644 index 0000000..9e45a46 --- /dev/null +++ b/SlipItIn.slnx @@ -0,0 +1,7 @@ + + + + + + + diff --git a/SlipItIn/App.xaml b/SlipItIn/App.xaml new file mode 100644 index 0000000..be70f37 --- /dev/null +++ b/SlipItIn/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/SlipItIn/App.xaml.cs b/SlipItIn/App.xaml.cs new file mode 100644 index 0000000..2c5d9dd --- /dev/null +++ b/SlipItIn/App.xaml.cs @@ -0,0 +1,16 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace SlipItIn; + +public partial class App : Application +{ + public App() + { + InitializeComponent(); + } + + protected override Window CreateWindow(IActivationState? activationState) + { + return new Window(new AppShell()); + } +} \ No newline at end of file diff --git a/SlipItIn/AppShell.xaml b/SlipItIn/AppShell.xaml new file mode 100644 index 0000000..12da11a --- /dev/null +++ b/SlipItIn/AppShell.xaml @@ -0,0 +1,14 @@ + + + + + + diff --git a/SlipItIn/AppShell.xaml.cs b/SlipItIn/AppShell.xaml.cs new file mode 100644 index 0000000..a985cd7 --- /dev/null +++ b/SlipItIn/AppShell.xaml.cs @@ -0,0 +1,9 @@ +namespace SlipItIn; + +public partial class AppShell : Shell +{ + public AppShell() + { + InitializeComponent(); + } +} diff --git a/SlipItIn/MainPage.xaml b/SlipItIn/MainPage.xaml new file mode 100644 index 0000000..9747740 --- /dev/null +++ b/SlipItIn/MainPage.xaml @@ -0,0 +1,36 @@ + + + + + + + +