This is a psalm attributed to King David, written thanking God for saving his life from what sounds like an illness, after he had been smug thinking that nothing ill would befall him. David sinned and messed up sometimes, but his love of the Lord was unmatched, and he was always faithful to God, in ceaseless in his continuing praise and prayer to God.
Psalm 29
I will extol you, O Lord, for you drew me clear and did not let my enemies rejoice over me.
O Lord, my God, I cried out to you and you healed me. O Lord, you brought me up from the nether world; you preserved me from among those going down into the pit. Sing praise to the Lord, you his faithful ones, and give thanks to his holy name. For his anger lasts but a moment; a lifetime, his good will. At nightfall, weeping enters in, but with the dawn, rejoicing.
Once, in my security, I said, "I shall never be disturbed." O Lord, in your good will you had endowed me with majesty and strength; but when you hid your face I was terrified.
To you, O Lord, I cried out; with the Lord I pleaded: "What gain would there be from my lifeblood, from my going down into the grave? Would dust give you thanks or proclaim your faithfulness? Hear, O Lord, and have pity on me; O Lord, be my helper."
You changed my mourning into dancing; you took off my sackcloth and clothed me with gladness, that my soul might sing praise to you without ceasing; O Lord, my God, forever will I give you thanks.