diff --git a/src/SimCube.Aspire/Features/Otlp/OtlpLiterals.cs b/src/SimCube.Aspire/Features/Otlp/OtlpLiterals.cs index 77d0949..ac87652 100644 --- a/src/SimCube.Aspire/Features/Otlp/OtlpLiterals.cs +++ b/src/SimCube.Aspire/Features/Otlp/OtlpLiterals.cs @@ -6,4 +6,5 @@ public static class OtlpLiterals public const string Headers = "OTEL_EXPORTER_OTLP_HEADERS"; public const string ResourceAttributes = "OTEL_RESOURCE_ATTRIBUTES"; public const string ServiceName = "OTEL_SERVICE_NAME"; -} + public const string ExposeHealthChecks = "OTEL_EXPOSE_HEALTHCHECKS"; +} \ No newline at end of file diff --git a/src/SimCube.Aspire/Features/Otlp/OtlpServiceExtensions.cs b/src/SimCube.Aspire/Features/Otlp/OtlpServiceExtensions.cs index d174a94..6c668fc 100644 --- a/src/SimCube.Aspire/Features/Otlp/OtlpServiceExtensions.cs +++ b/src/SimCube.Aspire/Features/Otlp/OtlpServiceExtensions.cs @@ -56,6 +56,21 @@ public static LoggerConfiguration GetLoggerConfiguration(this IConfiguration con return config; } + + public static void MapDefaultEndpoints(this WebApplication app) + { + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("OTEL_EXPOSE_HEALTHCHECKS"))) + { + return; + } + + app.MapHealthChecks("/health"); + + app.MapHealthChecks("/alive", new() + { + Predicate = r => r.Tags.Contains("live") + }); + } private static void ConfigureSerilog(this IHostApplicationBuilder builder) {