I am trying to debug my network, and since the epoch times are quite large (4 hours) and eras (1 day), are waiting validators considered for election at the end of an epoch or at the end of an era?
Assuming you are using BABE/Aura and GRANDPA, epoch and era are completely separate conceptual entities. Epochs belong to BABE/Aura and are the chunks of time containing authoring slots. Sessions and Eras belong to GRANDPA and define when the validator set can change (on session boundary).
In practice, Session looks to BABE about when to change, so epochs and sessions change at the same time. Anyway, regarding when the election takes place...
pallet_staking config defines the number of sessions per era. But there are actually two types of era,
ActiveEra. Active is what most users are generally familiar with as it concerns the set of active validators and is what points/rewards are mapped to. However, the network also keeps track of a CurrentEra, which is the latest planned era. This means that the election can take place during some active era and the system can queue up all the election winners for the next era ahead of time (perhaps node operators would want an alert to make sure their nodes are online and synced ahead of them being in the active set).
The election takes place in the second to last session of an active era. Therefore,
CurrentEra = ActiveEra for the first 5 of 6 sessions, but,
CurrentEra = ActiveEra + 1 in the 6th session. In this session, validators can see if they've won and will be active in the next era. The Sidecar docs have a good diagram on the Staking Progress endpoint.