diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2026-01-25 21:05:33 +0100 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2026-01-25 21:06:01 +0100 |
| commit | f9b7af64550be1320acc84d60184e8c8ce873b94 (patch) | |
| tree | d43e995319b4a3856aa929848b9ad807afb1cf86 /src/Enmarcha.Backend/Controllers/ArrivalsController.cs | |
| parent | c89353dede64bd2c21c0a1ebd6b6de6282998326 (diff) | |
feat: Add OpenTelemetry instrumentation and configuration for enhanced telemetry tracking
Diffstat (limited to 'src/Enmarcha.Backend/Controllers/ArrivalsController.cs')
| -rw-r--r-- | src/Enmarcha.Backend/Controllers/ArrivalsController.cs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Enmarcha.Backend/Controllers/ArrivalsController.cs b/src/Enmarcha.Backend/Controllers/ArrivalsController.cs index a23c69c..eb147fc 100644 --- a/src/Enmarcha.Backend/Controllers/ArrivalsController.cs +++ b/src/Enmarcha.Backend/Controllers/ArrivalsController.cs @@ -46,6 +46,10 @@ public partial class ArrivalsController : ControllerBase [FromQuery] bool reduced ) { + using var activity = Telemetry.Source.StartActivity("GetArrivals"); + activity?.SetTag("stop.id", id); + activity?.SetTag("reduced", reduced); + var tz = TimeZoneInfo.FindSystemTimeZoneById("Europe/Madrid"); var nowLocal = TimeZoneInfo.ConvertTime(DateTime.UtcNow, tz); var todayLocal = nowLocal.Date; @@ -65,12 +69,14 @@ public partial class ArrivalsController : ControllerBase if (responseBody is not { IsSuccess: true } || responseBody.Data?.Stop == null) { + activity?.SetStatus(System.Diagnostics.ActivityStatusCode.Error, "Error fetching stop data from OTP"); LogErrorFetchingStopData(response.StatusCode, await response.Content.ReadAsStringAsync()); return StatusCode(500, "Error fetching stop data"); } var stop = responseBody.Data.Stop; _logger.LogInformation("Fetched {Count} arrivals for stop {StopName} ({StopId})", stop.Arrivals.Count, stop.Name, id); + activity?.SetTag("arrivals.count", stop.Arrivals.Count); List<Arrival> arrivals = []; foreach (var item in stop.Arrivals) |
