From 7561ac7530f3d24ac08cbfb3ab410bda48daa2c5 Mon Sep 17 00:00:00 2001 From: amadzarak Date: Sat, 25 Apr 2026 18:08:24 -0400 Subject: [PATCH] OPC # 0001: Remove vault runtime data and sql export from tracking. Move Directory.Packages.props to root --- .github/copilot-instructions.md | 4 + .gitignore | 7 +- ControlPlane.Api/ControlPlane.Api.csproj | 8 +- .../ControlPlane.AppHost.csproj | 3 - ControlPlane.Core/ControlPlane.Core.csproj | 6 +- .../ControlPlane.ServiceDefaults.csproj | 19 ++++ ControlPlane.ServiceDefaults/Extensions.cs | 100 ++++++++++++++++++ .../ControlPlane.Worker.csproj | 5 +- ControlPlane.slnx | 2 +- Directory.Packages.props | 53 ---------- 10 files changed, 134 insertions(+), 73 deletions(-) create mode 100644 .github/copilot-instructions.md create mode 100644 ControlPlane.ServiceDefaults/ControlPlane.ServiceDefaults.csproj create mode 100644 ControlPlane.ServiceDefaults/Extensions.cs delete mode 100644 Directory.Packages.props diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000..b5c16fb --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,4 @@ +# Copilot Instructions + +## Project Guidelines +- Commit message format for OPC repo is: "OPC # XXXX: Description" (with a space between OPC and #, and space after #). Example: "OPC # 0001: Extract OPC into standalone repo". This convention comes from enterprise work jargon. \ No newline at end of file diff --git a/.gitignore b/.gitignore index 226a408..b541065 100644 --- a/.gitignore +++ b/.gitignore @@ -363,4 +363,9 @@ MigrationBackup/ FodyWeavers.xsd VaultData/ -ClientAssets/ \ No newline at end of file +ClientAssets/ + +# Vault runtime data - contains secrets, keyring, tokens etc. +infra/vault/data/ +infra/vault/data/init.json +opc_export.sql \ No newline at end of file diff --git a/ControlPlane.Api/ControlPlane.Api.csproj b/ControlPlane.Api/ControlPlane.Api.csproj index 3f91fda..066a305 100644 --- a/ControlPlane.Api/ControlPlane.Api.csproj +++ b/ControlPlane.Api/ControlPlane.Api.csproj @@ -1,10 +1,6 @@  - - net10.0 - enable - enable - + @@ -23,7 +19,7 @@ - + diff --git a/ControlPlane.AppHost/ControlPlane.AppHost.csproj b/ControlPlane.AppHost/ControlPlane.AppHost.csproj index ccb5065..c7c758c 100644 --- a/ControlPlane.AppHost/ControlPlane.AppHost.csproj +++ b/ControlPlane.AppHost/ControlPlane.AppHost.csproj @@ -2,9 +2,6 @@ Exe - net10.0 - enable - enable controlplane-apphost-$(MSBuildProjectName) diff --git a/ControlPlane.Core/ControlPlane.Core.csproj b/ControlPlane.Core/ControlPlane.Core.csproj index c6d0828..9fc81d7 100644 --- a/ControlPlane.Core/ControlPlane.Core.csproj +++ b/ControlPlane.Core/ControlPlane.Core.csproj @@ -1,10 +1,6 @@ - - net10.0 - enable - enable - + diff --git a/ControlPlane.ServiceDefaults/ControlPlane.ServiceDefaults.csproj b/ControlPlane.ServiceDefaults/ControlPlane.ServiceDefaults.csproj new file mode 100644 index 0000000..c567fa5 --- /dev/null +++ b/ControlPlane.ServiceDefaults/ControlPlane.ServiceDefaults.csproj @@ -0,0 +1,19 @@ + + + + true + + + + + + + + + + + + + + + diff --git a/ControlPlane.ServiceDefaults/Extensions.cs b/ControlPlane.ServiceDefaults/Extensions.cs new file mode 100644 index 0000000..1c92fb1 --- /dev/null +++ b/ControlPlane.ServiceDefaults/Extensions.cs @@ -0,0 +1,100 @@ +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; + +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 => + { + http.AddStandardResilienceHandler(); + http.AddServiceDiscovery(); + }); + + 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 => + tracing.Filter = context => + !context.Request.Path.StartsWithSegments(HealthEndpointPath) + && !context.Request.Path.StartsWithSegments(AlivenessEndpointPath) + ) + .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(); + } + + return builder; + } + + public static TBuilder AddDefaultHealthChecks(this TBuilder builder) where TBuilder : IHostApplicationBuilder + { + builder.Services.AddHealthChecks() + .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]); + + return builder; + } + + public static WebApplication MapDefaultEndpoints(this WebApplication app) + { + if (app.Environment.IsDevelopment()) + { + app.MapHealthChecks(HealthEndpointPath); + + app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions + { + Predicate = r => r.Tags.Contains("live") + }); + } + + return app; + } +} diff --git a/ControlPlane.Worker/ControlPlane.Worker.csproj b/ControlPlane.Worker/ControlPlane.Worker.csproj index f712858..839d0ec 100644 --- a/ControlPlane.Worker/ControlPlane.Worker.csproj +++ b/ControlPlane.Worker/ControlPlane.Worker.csproj @@ -1,9 +1,6 @@  - net10.0 - enable - enable controlplane-worker-secrets @@ -22,7 +19,7 @@ - + diff --git a/ControlPlane.slnx b/ControlPlane.slnx index 803be9d..9269d29 100644 --- a/ControlPlane.slnx +++ b/ControlPlane.slnx @@ -1,6 +1,6 @@ - + `n diff --git a/Directory.Packages.props b/Directory.Packages.props deleted file mode 100644 index 4705b7f..0000000 --- a/Directory.Packages.props +++ /dev/null @@ -1,53 +0,0 @@ - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file