mirror of
https://github.com/spacebarchat/server.git
synced 2026-10-23 10:53:01 +00:00
Various C# continuations
This commit is contained in:
1 parent
472d1159b1
commit
1dd3825ea0
9 files changed
+237
-19
No files matched your search
@@ -1,7 +1,10 @@
|
||||
using System.Diagnostics.Metrics;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using ArcaneLibs.Extensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using OpenTelemetry.Metrics;
|
||||
using OpenTelemetry.Resources;
|
||||
using Spacebar.Interop.Authentication;
|
||||
using Spacebar.Interop.Authentication.AspNetCore;
|
||||
using Spacebar.Models.Db.Contexts;
|
||||
@@ -12,11 +15,28 @@ if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("APPSETTINGS_P
|
||||
builder.Configuration.AddJsonFile(Environment.GetEnvironmentVariable("APPSETTINGS_PATH")!);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.ConfigureResource(resource=> {
|
||||
resource.AddService(serviceName: builder.Environment.ApplicationName, serviceNamespace: builder.Environment.ApplicationName);
|
||||
})
|
||||
.WithMetrics(builder =>
|
||||
{
|
||||
builder.AddPrometheusExporter();
|
||||
|
||||
builder.AddMeter("Microsoft.AspNetCore.Hosting", "Microsoft.AspNetCore.Server.Kestrel", "System.Runtime", "Microsoft.Extensions.Diagnostics.ResourceMonitoring", "Microsoft.AspNetCore.Routing", "Microsoft.AspNetCore.Diagnostics", "Microsoft.AspNetCore.RateLimiting", "Microsoft.AspNetCore.HeaderParsing", "Microsoft.AspNetCore.Server.Kestrel");
|
||||
builder.AddView("http.server.request.duration",
|
||||
new ExplicitBucketHistogramConfiguration
|
||||
{
|
||||
Boundaries = [0.0, 0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 10]
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.AddControllers(options => {
|
||||
builder.Services.AddControllers(options =>
|
||||
{
|
||||
options.MaxValidationDepth = null;
|
||||
// options.MaxIAsyncEnumerableBufferLimit = 1;
|
||||
}).AddJsonOptions(options => {
|
||||
}).AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.Never;
|
||||
options.JsonSerializerOptions.WriteIndented = true;
|
||||
options.JsonSerializerOptions.MaxDepth = 100;
|
||||
@@ -25,7 +45,8 @@ builder.Services.AddControllers(options => {
|
||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
builder.Services.AddDbContextPool<SpacebarDbContext>(options => {
|
||||
builder.Services.AddDbContextPool<SpacebarDbContext>(options =>
|
||||
{
|
||||
options
|
||||
.UseNpgsql(builder.Configuration.GetConnectionString("Spacebar"))
|
||||
.EnableDetailedErrors();
|
||||
@@ -37,8 +58,11 @@ builder.Services.AddScoped<SpacebarAspNetAuthenticationService>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.MapPrometheusScrapingEndpoint();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (app.Environment.IsDevelopment()) {
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
app.MapOpenApi();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DataMappings\Spacebar.DataMappings.Generic\Spacebar.DataMappings.Generic.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.16.0-beta.1" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.16.0" />
|
||||
<PackageReference Include="Spacebar.DataMappings.Generic" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
<ProjectReference Include="..\Interop\Spacebar.Interop.Authentication.AspNetCore\Spacebar.Interop.Authentication.AspNetCore.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/>
|
||||
<PackageReference Include="Spacebar.Interop.Authentication.AspNetCore" Version="*-preview*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/>
|
||||
|
||||
Reference in new issue
Block a user