fix(auth): exception initial character after login + otel
This commit is contained in:
parent
2aedc9dae9
commit
4e9e5f4730
4 changed files with 51 additions and 101 deletions
|
@ -1,24 +1,19 @@
|
|||
repos:
|
||||
- repo: local
|
||||
hooks:
|
||||
- repo: local
|
||||
hooks:
|
||||
#Use dotnet format already installed on your machine
|
||||
- id: dotnet-format
|
||||
name: dotnet-format
|
||||
language: system
|
||||
entry: dotnet format --include
|
||||
types_or: [c#, vb]
|
||||
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
|
||||
rev: v1.6.26.11
|
||||
hooks:
|
||||
- id: actionlint
|
||||
additional_dependencies: [pyflakes>=3.0.1, shellcheck-py>=0.9.0.5]
|
||||
- repo: https://github.com/hadolint/hadolint
|
||||
rev: v2.12.0
|
||||
hooks:
|
||||
- id: hadolint-docker
|
||||
args: [--ignore, SC2086]
|
||||
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
|
||||
rev: v2.12.0
|
||||
hooks:
|
||||
- id: pretty-format-yaml
|
||||
args: [--autofix, --indent, '2']
|
||||
- id: dotnet-format
|
||||
name: dotnet-format
|
||||
language: system
|
||||
entry: dotnet format --include
|
||||
types_or: [c#, vb]
|
||||
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
|
||||
rev: v1.6.26.11
|
||||
hooks:
|
||||
- id: actionlint
|
||||
additional_dependencies: [pyflakes>=3.0.1, shellcheck-py>=0.9.0.5]
|
||||
- repo: https://github.com/hadolint/hadolint
|
||||
rev: v2.12.0
|
||||
hooks:
|
||||
- id: hadolint-docker
|
||||
args: [--ignore, SC2086]
|
||||
|
|
|
@ -31,7 +31,7 @@ public class CharacterCreationHandler : IPacketHandler<CharacterCreationPacket,
|
|||
CancellationToken cancellationToken)
|
||||
{
|
||||
var account =
|
||||
await _wonderkingContext.Accounts.FirstOrDefaultAsync(a => a.Id == session.AccountId, cancellationToken);
|
||||
await _wonderkingContext.Accounts.Include(a => a.Characters).FirstOrDefaultAsync(a => a.Id == session.AccountId, cancellationToken);
|
||||
|
||||
if (account is null)
|
||||
{
|
||||
|
|
|
@ -40,57 +40,37 @@ var loggerFactory = LoggerFactory.Create(loggingBuilder =>
|
|||
loggingBuilder.AddFile("logs/Continuity.AuthServer-{Date}.log", LogLevel.Trace);
|
||||
loggingBuilder.AddFile("logs/Continuity.AuthServer-{Date}.json.log", LogLevel.Trace, isJson: true);
|
||||
loggingBuilder.AddConsole();
|
||||
loggingBuilder.AddOpenTelemetry();
|
||||
});
|
||||
|
||||
var configuration = builder.Configuration;
|
||||
if (configuration.GetValue<bool>("Tracing:Enabled"))
|
||||
|
||||
builder.Logging.AddOpenTelemetry(logging =>
|
||||
{
|
||||
Action<ResourceBuilder> resourceBuilderAction = r => r
|
||||
.AddService("Continuity", serviceInstanceId: Environment.MachineName);
|
||||
logging.IncludeFormattedMessage = true;
|
||||
logging.IncludeScopes = true;
|
||||
});
|
||||
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.ConfigureResource(resourceBuilderAction)
|
||||
.WithTracing(tracing =>
|
||||
builder.Services.AddOpenTelemetry()
|
||||
.WithMetrics(metrics =>
|
||||
{
|
||||
metrics.AddRuntimeInstrumentation().AddProcessInstrumentation().AddMeter("Microsoft.AspNetCore.Hosting", nameof(Continuity.AuthServer))
|
||||
.ConfigureResource(resourceBuilder => resourceBuilder.AddService("Continuity", serviceNamespace: "Wonderking", serviceVersion: "0.0.1"));
|
||||
})
|
||||
.WithTracing(tracing =>
|
||||
{
|
||||
if (builder.Environment.IsDevelopment())
|
||||
{
|
||||
tracing.AddSource(nameof(Server));
|
||||
tracing.AddSource("MassTransit");
|
||||
tracing.AddEntityFrameworkCoreInstrumentation(options => options.SetDbStatementForText = true);
|
||||
tracing.AddNpgsql();
|
||||
})
|
||||
.WithMetrics(metrics =>
|
||||
{
|
||||
metrics.AddRuntimeInstrumentation();
|
||||
metrics.AddProcessInstrumentation();
|
||||
});
|
||||
tracing.SetSampler<AlwaysOnSampler>();
|
||||
}
|
||||
tracing.AddEntityFrameworkCoreInstrumentation(options => options.SetDbStatementForText = true).AddNpgsql();
|
||||
});
|
||||
|
||||
builder.Logging.AddOpenTelemetry(logging =>
|
||||
{
|
||||
var resourceBuilder = ResourceBuilder.CreateDefault();
|
||||
resourceBuilderAction(resourceBuilder);
|
||||
logging.SetResourceBuilder(resourceBuilder);
|
||||
logging.IncludeFormattedMessage = true;
|
||||
logging.IncludeScopes = true;
|
||||
});
|
||||
builder.Services.Configure<OpenTelemetryLoggerOptions>(logging =>
|
||||
{
|
||||
logging.AddOtlpExporter(options =>
|
||||
{
|
||||
options.Endpoint = new Uri(configuration["OTLP:Logging:Endpoint"] ?? string.Empty);
|
||||
});
|
||||
});
|
||||
builder.Services.ConfigureOpenTelemetryMeterProvider(metrics =>
|
||||
{
|
||||
metrics.AddOtlpExporter(options =>
|
||||
options.Endpoint = new Uri(configuration["OTLP:Metrics:Endpoint"] ?? string.Empty));
|
||||
});
|
||||
builder.Services.ConfigureOpenTelemetryTracerProvider(tracing =>
|
||||
{
|
||||
tracing.AddZipkinExporter(options =>
|
||||
options.Endpoint = new Uri(configuration["Zipkin:Endpoint"] ?? string.Empty));
|
||||
tracing.AddOtlpExporter(options =>
|
||||
options.Endpoint = new Uri(configuration["OTLP:Tracing:Endpoint"] ?? string.Empty));
|
||||
});
|
||||
}
|
||||
builder.Services.AddMetrics();
|
||||
|
||||
builder.Services.Configure<OpenTelemetryLoggerOptions>(logging => logging.AddOtlpExporter());
|
||||
builder.Services.ConfigureOpenTelemetryMeterProvider(meter => meter.AddOtlpExporter());
|
||||
builder.Services.ConfigureOpenTelemetryTracerProvider(tracer => tracer.AddOtlpExporter());
|
||||
|
||||
builder.Services.AddHealthChecks()
|
||||
.AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);
|
||||
|
@ -99,7 +79,7 @@ builder.Services.AddDbContextPool<WonderkingContext>(o =>
|
|||
{
|
||||
o.UseNpgsql(
|
||||
$"Host={configuration["DB:Host"]};Username={configuration["DB:Username"]};Password={configuration["DB:Password"]};Database={configuration["DB:Database"]};Port={configuration["DB:Port"]}")
|
||||
.EnableSensitiveDataLogging().UseLazyLoadingProxies().UseLoggerFactory(loggerFactory);
|
||||
.EnableSensitiveDataLogging().UseLoggerFactory(loggerFactory);
|
||||
});
|
||||
|
||||
builder.Services.AddSingleton<CharacterStatsMappingConfiguration>(
|
||||
|
|
|
@ -14,10 +14,8 @@ services:
|
|||
- DB:Password=continuity
|
||||
- Game:Data:Path=/app/data/
|
||||
- Tracing:Enabled=true
|
||||
- OTLP:Tracing:Endpoint=http://otel-collector:4317
|
||||
- OTLP:Logging:Endpoint=http://otel-collector:4317
|
||||
- OTLP:Metrics:Endpoint=http://otel-collector:4317
|
||||
- Zipkin:Endpoint=http://zipkin:9411/api/v2/spans
|
||||
- OTEL_EXPORTER_OTLP_ENDPOINT=http://aspire:18889
|
||||
- Logging:LogLevel:Default=Debug
|
||||
networks:
|
||||
- continuity
|
||||
ports:
|
||||
|
@ -43,47 +41,24 @@ services:
|
|||
- POSTGRES_PASSWORD=continuity
|
||||
networks:
|
||||
- continuity
|
||||
ports:
|
||||
- 5432:5432
|
||||
volumes:
|
||||
- db-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: [ CMD-SHELL, 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}' ]
|
||||
test: [CMD-SHELL, "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
|
||||
interval: 10s
|
||||
timeout: 3s
|
||||
retries: 3
|
||||
mem_limit: 1024m
|
||||
|
||||
jaeger:
|
||||
container_name: continuity-jaeger
|
||||
image: jaegertracing/all-in-one:1.53.0
|
||||
restart: always
|
||||
depends_on:
|
||||
- server
|
||||
aspire:
|
||||
image: mcr.microsoft.com/dotnet/aspire-dashboard:8.0.0
|
||||
networks:
|
||||
- continuity
|
||||
expose:
|
||||
- 14250
|
||||
- 14268
|
||||
- 14269
|
||||
ports:
|
||||
- 16686:16686
|
||||
environment:
|
||||
- COLLECTOR_OTLP_ENABLED=true
|
||||
- METRICS_STORAGE_TYPE=prometheus
|
||||
- PROMETHEUS_SERVER_URL=http://prometheus:9090
|
||||
- PROMETHEUS_QUERY_SUPPORT_SPANMETRICS_CONNECTOR=true
|
||||
- PROMETHEUS_QUERY_NORMALIZE_CALLS=true
|
||||
- PROMETHEUS_QUERY_NORMALIZE_DURATION=true
|
||||
|
||||
zipkin:
|
||||
container_name: continuity-zipkin
|
||||
image: openzipkin/zipkin:3.0.5
|
||||
restart: always
|
||||
- DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS=true
|
||||
- Dashboard:Frontend:AuthMode=Unsecured
|
||||
ports:
|
||||
- 9411:9411
|
||||
networks:
|
||||
- continuity
|
||||
- 18888:18888
|
||||
|
||||
networks:
|
||||
continuity:
|
||||
|
|
Loading…
Reference in a new issue