mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-13 20:18:36 +08:00
- fix bug in seed flight for read database
- fix bug sqlserver health check - add OpenTelemetry Instrumentation GrpcNetClient
This commit is contained in:
parent
7b1fb70a2e
commit
d530af9eb3
@ -24,6 +24,7 @@
|
||||
<PackageReference Include="Grpc.Core.Testing" Version="2.46.5" />
|
||||
<PackageReference Include="Mongo2Go" Version="3.1.3" />
|
||||
<PackageReference Include="NSubstitute" Version="4.3.0" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.GrpcNetClient" Version="1.0.0-rc9.7" />
|
||||
<PackageReference Include="Polly" Version="7.2.3" />
|
||||
<PackageReference Include="protobuf-net.BuildTools" Version="3.0.115">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
@ -95,11 +96,11 @@
|
||||
<PackageReference Include="prometheus-net" Version="6.0.0" />
|
||||
<PackageReference Include="prometheus-net.AspNetCore" Version="6.0.0" />
|
||||
|
||||
<PackageReference Include="OpenTelemetry" Version="1.2.0-rc3" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.2.0-rc3" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9" />
|
||||
<PackageReference Include="OpenTelemetry" Version="1.4.0-beta.1" />
|
||||
<PackageReference Include="OpenTelemetry.Exporter.Jaeger" Version="1.4.0-beta.1" />
|
||||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.0.0-rc9.7" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.0.0-rc9.7" />
|
||||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="1.0.0-rc9.7" />
|
||||
|
||||
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.0.64">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
@ -24,13 +24,14 @@ public static class Extensions
|
||||
var logOptions = services.GetOptions<LogOptions>("LogOptions");
|
||||
|
||||
var healthChecksBuilder = services.AddHealthChecks()
|
||||
.AddSqlServer(sqlOptions.DefaultConnection)
|
||||
.AddRabbitMQ(rabbitConnectionString: $"amqp://{rabbitMqOptions.UserName}:{rabbitMqOptions.Password}@{rabbitMqOptions.HostName}")
|
||||
.AddElasticsearch(logOptions.Elastic.ElasticServiceUrl);
|
||||
|
||||
if (mongoOptions.ConnectionString is not null)
|
||||
healthChecksBuilder.AddMongoDb(mongoOptions.ConnectionString);
|
||||
|
||||
if (sqlOptions.DefaultConnection is not null)
|
||||
healthChecksBuilder.AddSqlServer(sqlOptions.DefaultConnection);
|
||||
|
||||
services.AddHealthChecksUI(setup =>
|
||||
{
|
||||
|
||||
@ -11,6 +11,7 @@ public static class Extensions
|
||||
public static IServiceCollection AddCustomOpenTelemetry(this IServiceCollection services)
|
||||
{
|
||||
services.AddOpenTelemetryTracing(builder => builder
|
||||
.AddGrpcClientInstrumentation()
|
||||
.AddMassTransitInstrumentation()
|
||||
.AddAspNetCoreInstrumentation()
|
||||
.AddHttpClientInstrumentation()
|
||||
|
||||
@ -13,6 +13,8 @@ using Flight.Seats.Models;
|
||||
using Flight.Seats.Models.Reads;
|
||||
using MapsterMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MongoDB.Driver;
|
||||
using MongoDB.Driver.Linq;
|
||||
|
||||
namespace Flight.Data.Seed;
|
||||
|
||||
@ -51,7 +53,9 @@ public class FlightDataSeeder : IDataSeeder
|
||||
|
||||
await _flightDbContext.Airports.AddRangeAsync(airports);
|
||||
await _flightDbContext.SaveChangesAsync();
|
||||
await _flightReadDbContext.Airport.InsertManyAsync(_mapper.Map<List<AirportReadModel>>(airports));
|
||||
|
||||
if (!await _flightReadDbContext.Airport.AsQueryable().AnyAsync())
|
||||
await _flightReadDbContext.Airport.InsertManyAsync(_mapper.Map<List<AirportReadModel>>(airports));
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +72,9 @@ public class FlightDataSeeder : IDataSeeder
|
||||
|
||||
await _flightDbContext.Aircraft.AddRangeAsync(aircrafts);
|
||||
await _flightDbContext.SaveChangesAsync();
|
||||
await _flightReadDbContext.Aircraft.InsertManyAsync(_mapper.Map<List<AircraftReadModel>>(aircrafts));
|
||||
|
||||
if (!await _flightReadDbContext.Aircraft.AsQueryable().AnyAsync())
|
||||
await _flightReadDbContext.Aircraft.InsertManyAsync(_mapper.Map<List<AircraftReadModel>>(aircrafts));
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +85,7 @@ public class FlightDataSeeder : IDataSeeder
|
||||
{
|
||||
var seats = new List<Seat>
|
||||
{
|
||||
Seat.Create(1 ,"12A", Seats.Enums.SeatType.Window, Seats.Enums.SeatClass.Economy, 1),
|
||||
Seat.Create(1, "12A", Seats.Enums.SeatType.Window, Seats.Enums.SeatClass.Economy, 1),
|
||||
Seat.Create(2, "12B", Seats.Enums.SeatType.Window, Seats.Enums.SeatClass.Economy, 1),
|
||||
Seat.Create(3, "12C", Seats.Enums.SeatType.Middle, Seats.Enums.SeatClass.Economy, 1),
|
||||
Seat.Create(4, "12D", Seats.Enums.SeatType.Middle, Seats.Enums.SeatClass.Economy, 1),
|
||||
@ -89,7 +95,9 @@ public class FlightDataSeeder : IDataSeeder
|
||||
|
||||
await _flightDbContext.Seats.AddRangeAsync(seats);
|
||||
await _flightDbContext.SaveChangesAsync();
|
||||
await _flightReadDbContext.Seat.InsertManyAsync(_mapper.Map<List<SeatReadModel>>(seats));
|
||||
|
||||
if (!await _flightReadDbContext.Seat.AsQueryable().AnyAsync())
|
||||
await _flightReadDbContext.Seat.InsertManyAsync(_mapper.Map<List<SeatReadModel>>(seats));
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,7 +115,9 @@ public class FlightDataSeeder : IDataSeeder
|
||||
};
|
||||
await _flightDbContext.Flights.AddRangeAsync(flights);
|
||||
await _flightDbContext.SaveChangesAsync();
|
||||
await _flightReadDbContext.Flight.InsertManyAsync(_mapper.Map<List<FlightReadModel>>(flights));
|
||||
|
||||
if (!await _flightReadDbContext.Flight.AsQueryable().AnyAsync())
|
||||
await _flightReadDbContext.Flight.InsertManyAsync(_mapper.Map<List<FlightReadModel>>(flights));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ using FluentValidation;
|
||||
using Hellang.Middleware.ProblemDetails;
|
||||
using Identity;
|
||||
using Identity.Data;
|
||||
using Identity.Data.Seed;
|
||||
using Identity.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc.ApiExplorer;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@ -7,7 +7,7 @@ using Identity.Identity.Constants;
|
||||
using Identity.Identity.Models;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
namespace Identity.Data;
|
||||
namespace Identity.Data.Seed;
|
||||
|
||||
public class IdentityDataSeeder : IDataSeeder
|
||||
{
|
||||
@ -16,7 +16,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Data\Configurations" />
|
||||
<Folder Include="Data\Migrations" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user