Skip to content

fix: Improve GTFS metrics reliability and test accuracy#52

Merged
BrandonTrigueros merged 2 commits intofeature/gtfs-prometheus-metricsfrom
copilot/sub-pr-49-another-one
Dec 27, 2025
Merged

fix: Improve GTFS metrics reliability and test accuracy#52
BrandonTrigueros merged 2 commits intofeature/gtfs-prometheus-metricsfrom
copilot/sub-pr-49-another-one

Conversation

Copy link

Copilot AI commented Dec 27, 2025

Addresses code review feedback from PR #49 to fix metrics accuracy and error handling gaps in GTFS processing tasks.

Changes

  • Error handling: Wrapped table import loop in try-except to capture CSV parsing and database insertion failures, preventing silent errors
  • Metrics accuracy: Moved GTFS_SCHEDULE_UPDATES_TOTAL increment from before import to after successful completion - counter no longer increments on failed imports
  • Test correctness: Fixed test_schedule_updates_counter to use provider label instead of incorrect feed_id label

Example

Before:

GTFS_SCHEDULE_UPDATES_TOTAL.labels(provider=company).inc()  # Line 82 - increments before import
for table_name in tables.keys():
    # ... import logic with no error handling

After:

try:
    for table_name in tables.keys():
        # ... import logic
    GTFS_SCHEDULE_UPDATES_TOTAL.labels(provider=company).inc()  # Line 122 - after success
except Exception as e:
    GTFS_PROCESSING_ERRORS_TOTAL.labels(task="get_schedule", provider=company).inc()
    logging.error(f"Error importing schedule data: {e}")
    return "Error importing schedule data"

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

… labels

Co-authored-by: BrandonTrigueros <101825840+BrandonTrigueros@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Prometheus metrics for GTFS processing monitoring fix: Improve GTFS metrics reliability and test accuracy Dec 27, 2025
@BrandonTrigueros BrandonTrigueros marked this pull request as ready for review December 27, 2025 19:49
@BrandonTrigueros BrandonTrigueros merged commit 6dc0b36 into feature/gtfs-prometheus-metrics Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants