Faith
The first half of the Psalm speaks of how the writer is suffering. Even in the midst of the suffering, verse 10 tells us the writer still has faith in God. Then the Psalm changes to thanking God for all He has done. Faith can turn our suffering into thanks. The circumstances haven’t changed, but our view changes from focusing on the problems to focusing on God.