Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs-builder.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
<File Path="config/legacy-url-mappings.yml" />
<File Path="config/navigation.yml" />
<File Path="config/products.yml" />
<File Path="config/synonyms.yml" />
<File Path="config/versions.yml" />
<File Path="config/search.yml" />
</Folder>
Expand Down
25 changes: 1 addition & 24 deletions src/Elastic.Documentation.ServiceDefaults/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public static class Extensions

public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
_ = builder
.ConfigureOpenTelemetry()
.AddDefaultHealthChecks();

_ = builder.Services
.AddServiceDiscovery()
.ConfigureHttpClientDefaults(http =>
Expand All @@ -39,7 +35,7 @@ public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder) where
return builder;
}

public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
public static TBuilder AddOpenTelemetryDefaults<TBuilder>(this TBuilder builder) where TBuilder : IHostApplicationBuilder
{
_ = builder.Logging.AddOpenTelemetry(logging =>
{
Expand Down Expand Up @@ -108,23 +104,4 @@ public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder) w

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\Elastic.Documentation.ServiceDefaults\Elastic.Documentation.ServiceDefaults.csproj" />
<ProjectReference Include="..\Elastic.Documentation.Api.Core\Elastic.Documentation.Api.Core.csproj"/>
<ProjectReference Include="..\Elastic.Documentation.Api.Infrastructure\Elastic.Documentation.Api.Infrastructure.csproj"/>
</ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions src/api/Elastic.Documentation.Api.Lambda/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
using Elastic.Documentation.Api.Core.Search;
using Elastic.Documentation.Api.Infrastructure;
using Elastic.Documentation.Api.Infrastructure.OpenTelemetry;
using Elastic.Documentation.Configuration.Assembler;
using Elastic.Documentation.ServiceDefaults;

try
{
var builder = WebApplication.CreateSlimBuilder(args);
_ = builder.AddDocumentationServiceDefaults(ref args, (s, p) =>
{
_ = s.AddSingleton(AssemblyConfiguration.Create(p));
});
// Add logging configuration for Lambda
_ = builder.AddDocsApiOpenTelemetry();

Expand All @@ -39,6 +45,9 @@
builder.Services.AddElasticDocsApiUsecases(environment);
var app = builder.Build();

if (app.Environment.IsDevelopment())
_ = app.UseDeveloperExceptionPage();

var v1 = app.MapGroup("/docs/_api/v1");
v1.MapElasticDocsApiEndpoints();
Console.WriteLine("API endpoints mapped");
Expand Down
3 changes: 2 additions & 1 deletion src/tooling/docs-builder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
{
_ = s.AddSingleton(AssemblyConfiguration.Create(p));
})
.AddDocumentationToolingDefaults();
.AddDocumentationToolingDefaults()
.AddOpenTelemetryDefaults();

var app = builder.ToConsoleAppBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,11 @@ public async Task OtlpProxyReturnsCollectorErrorStatusCode()

using var factory = ApiWebApplicationFactory.WithMockedServices(services =>
{
#pragma warning disable EXTEXP0001 // Experimental API - needed for test to bypass resilience handlers
_ = services.AddHttpClient(AdotOtlpGateway.HttpClientName)
.ConfigurePrimaryHttpMessageHandler(() => mockHandler);
.ConfigurePrimaryHttpMessageHandler(() => mockHandler)
.RemoveAllResilienceHandlers();
#pragma warning restore EXTEXP0001
});

var client = factory.CreateClient();
Expand All @@ -219,8 +222,10 @@ public async Task OtlpProxyReturnsCollectorErrorStatusCode()
// Act
using var response = await client.PostAsync("/docs/_api/v1/o/t", content, TestContext.Current.CancellationToken);

var responseContent = await response.Content.ReadAsStringAsync(TestContext.Current.CancellationToken);
// Assert - verify error responses are properly forwarded
response.StatusCode.Should().Be(HttpStatusCode.ServiceUnavailable);
response.StatusCode.Should().Be(HttpStatusCode.ServiceUnavailable, "{0}", responseContent);


// Cleanup mock response
mockResponse.Dispose();
Expand Down
Loading