Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
<PackageVersion Include="AWSSDK.Core" Version="4.0.0.2" />
<PackageVersion Include="AWSSDK.SQS" Version="4.0.0.1" />
<PackageVersion Include="AWSSDK.S3" Version="4.0.0.1" />
<PackageVersion Include="Elastic.OpenTelemetry" Version="1.1.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0"/>
<PackageVersion Include="KubernetesClient" Version="17.0.14" />
<PackageVersion Include="Elastic.Aspire.Hosting.Elasticsearch" Version="9.3.0" />
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="9.1.4" />
Expand Down Expand Up @@ -75,7 +77,6 @@
<PackageVersion Include="Microsoft.Extensions.ServiceDiscovery" Version="9.4.0" />
<PackageVersion Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.12.0" />
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.12.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.12.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Http" Version="1.12.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.12.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

<ItemGroup>
<PackageReference Include="Amazon.Lambda.AspNetCoreServer.Hosting"/>
<PackageReference Include="Elastic.OpenTelemetry" />
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
</ItemGroup>

</Project>
25 changes: 24 additions & 1 deletion src/api/Elastic.Documentation.Api.Lambda/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,40 @@
using Elastic.Documentation.Api.Core.Search;
using Elastic.Documentation.Api.Infrastructure;
using Elastic.Documentation.ServiceDefaults;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

var builder = WebApplication.CreateSlimBuilder(args);

builder.AddDocumentationServiceDefaults(ref args);

builder.Services.AddAWSLambdaHosting(LambdaEventSource.RestApi, new SourceGeneratorLambdaJsonSerializer<LambdaJsonSerializerContext>());
builder.AddElasticOpenTelemetry(edotBuilder =>
{
_ = edotBuilder
.WithElasticTracing(tracing =>
{
_ = tracing
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation();
})
.WithElasticLogging()
.WithElasticMetrics(metrics =>
{
_ = metrics
.AddAspNetCoreInstrumentation()
.AddHttpClientInstrumentation()
.AddProcessInstrumentation()
.AddRuntimeInstrumentation();
});
});

builder.Services.AddElasticDocsApiUsecases(Environment.GetEnvironmentVariable("ENVIRONMENT"));
builder.WebHost.UseKestrelHttpsConfiguration();

var app = builder.Build();

Console.WriteLine($"Environment: {app.Environment.EnvironmentName}");
var v1 = app.MapGroup("/docs/_api/v1");
v1.MapElasticDocsApiEndpoints();

Expand Down
15 changes: 15 additions & 0 deletions src/api/Elastic.Documentation.Api.Lambda/appsettings.edge.json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the name of this file be appsettings.edge.json? (no capital)

Not a blocker: but do you see a way to configure this outside of the application.

E.g. We want to change it to DEBUG because we need to debug something in production.

Or is this already possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use environment variables too - in this case control can be manual in the AWS web interface or through infra changes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Elastic": {
"OpenTelemetry": {
"LogLevel": "Debug",
"LogTargets": "stdout",
"SkipInstrumentationAssemblyScanning": true
}
}
}
Loading