If you actually complete the settlement and the creditor discharges (forgives the debt) in 2017 then the debt that was discharged is income in 2017. If you negotiate the deal in 2017 but don’t complete it (i.e. do not pay it) until 2018 then the discharge occurs in 2018 and becomes income for 2018.
Only debt that is actually discharged in bankruptcy is excluded from income under the bankruptcy rule. So if you complete a settlement with the creditor and get the debt discharged before bankruptcy then the debt does not get discharged in the bankruptcy because that debt does not exist any more at the time you file the bankruptcy. (Though if the trustee claims what you paid the creditor as a preference payment that would change things.) But if the debt is discharged in bankruptcy it is not included in taxable income. You may need to make other tax adjustments, though, as I noted in my earlier reply.
The computation is done as of the day the debt is discharged. Let me give you a simple example. Joe owes his bank $20,000 on a personal loan. He settles that debt with the bank for $5,000. Thus $15,000 is discharged. Prior to the discharge, his total assets were $50,000 and his total debts (including the personal loan to the bank) were $60,000. Thus, immediately prior to the discharge, he was insolvent as his debts exceeded his assets by $10,000. Immediately after the discharge, his total assets are $45,000 and his total debts are now $40,000. So immediately after the debt, he is no longer insolvent. He is solvent by $5,000 and that $5,000 would then be taxable income as the result of the debt discharge. The remaining $10,000 of discharged debt is not included in his income, but he may have other tax adjustments to make to compensate for that.
In some circumstances the expiration of the statute of limitations to sue on the debt itself counts a discharge of the debt and is included in your income. That would occur if the statute of limitation actually bars the creditor from suing to collect. There are some state statutes that work that way, and some circumstance in which federal law would have that same effect. In those circumstance it effects a discharge of the debt. Creditors do not often send Forms 1099 for that circumstance (often because they don't know they should), but even if no 1099 is received the taxpayer is required to include it in income anyway. More commonly, though, the statute of limitations does not bar the creditor from suing; it simply gives the debtor an affirmative defense to the claim. In that case, the SOL expiration may be an event of discharge at the time the court actually holds that the SOL applies and the creditor is prevented from pursuing his claim. In that case, if the creditor never sues then the debt may not get discharged by the SOL, but may get discharged when the creditor finally gives up on collecting it. In short, the specific facts matter as to exactly when the debt is effectively discharged in SOL situations.
The expiration of a judgment does preclude any further collection and would also amount to a discharge of debt for tax purposes. There are no court cases stating that, nor has the IRS expressly stated that, but it follows that would be the case given the effect of the lapse of the judgment, assuming of course that some other event has not already discharged the debt.

