Which events count as credit events is set in the contract. For a CDS on a company, bankruptcy and failure to pay are the most common events, and whether restructuring is included depends on the standard contract. A CDS on a country lists failure to pay, repudiation/moratorium, and restructuring. Whether an event has occurred is decided by the Credit Derivatives Determinations Committee (DC).
The default terms in bond and loan contracts are generally not the same as the credit event terms of a CDS. A loan can therefore suffer a loss without a credit event being recognized, and the CDS hedge may then not work.