Skip to content

fix server-mode telemetry double-counting and stale scoped state #134

Description

@0xaboomar

Follow up from #131 PR

Server-mode double-counting in trackVehicleTelemetry. In server-mode the per-agency loop calls this once per live agency over the same merged RT feed. VehicleReportCount is a Counter, so every vehicle gets Inc() N times per tick on an N-agency server — rate() comes out N× too high. Relatedly, vehicleLastSeen.Set(server.ServerKey(), ...) records every vehicle under every agency's key, so gtfs_rt_tracked_vehicles_count reports the whole server's fleet for each agency. countVehiclePositions and trackInvalidVehiclesAndStoppedOutOfBounds have the same shape (each agency reports server-wide totals).

This is the same underlying issue as your TODO(scoped-store) in config/scoping.go and the bbox NOTE in storeStaticForServer — the merged-bundle storage shape loses the agency↔feed relationship. It needs a design decision rather than a review-time patch, so I left it alone. The counter inflation is the part I'd prioritise, since gauges self-correct on the next scrape but a counter never does.

Stale keys are never pruned. staticStore, boundingBoxStore and RealtimeStore accumulate entries per serverKey and nothing removes them when an agency disappears from agency.txt or from the remote config. discoverAgenciesForServer will keep returning the departed agency indefinitely. Slow leak, not urgent, but worth a follow-up issue.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions