Add more logging and trace parameters
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Microsoft.AspNetCore.Http.HttpResults;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Diagnostics;
|
||||
using Vegasco.Server.Api.Cars;
|
||||
using Vegasco.Server.Api.Persistence;
|
||||
|
||||
@@ -49,8 +50,14 @@ public static class GetConsumptions
|
||||
private static async Task<Ok<ApiResponse>> Endpoint(
|
||||
[AsParameters] Request request,
|
||||
ApplicationDbContext dbContext,
|
||||
ILoggerFactory loggerFactory,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
ILogger logger = loggerFactory.CreateLogger(nameof(GetConsumptions));
|
||||
|
||||
logger.LogTrace("Received request to get consumptions with parameters: {@Request}", request);
|
||||
Activity? activity = Activity.Current;
|
||||
|
||||
Dictionary<CarId, List<Consumption>> consumptionsByCar = await dbContext.Consumptions
|
||||
.Include(x => x.Car)
|
||||
.GroupBy(x => x.CarId)
|
||||
@@ -83,6 +90,8 @@ public static class GetConsumptions
|
||||
literPer100Km));
|
||||
}
|
||||
}
|
||||
|
||||
activity?.SetTag("consumptionCount", responses.Count);
|
||||
|
||||
ApiResponse apiResponse = new()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user