A Commentary, Critical, Practical, and Explanatory on the Old and New Testaments, by Robert Jamieson, A.R. Fausset and David Brown  at sacred-texts.com
psa 138:1David thanks God for His benefits, and anticipating a wider extension of God's glory by His means, assures himself of His continued presence and faithfulness. (Psa 138:1-8)
I will praise thee with my whole heart--(Compare Psa 9:1).
before the gods--whether angels (Psa 8:5); or princes (Exo 21:6; Psa 82:6); or idols (Psa 97:7); denotes a readiness to worship the true God alone, and a contempt of all other objects of worship.
psa 138:2(Compare Psa 5:7).
thy word above all thy name--that is, God's promise (Sa2 7:12-16), sustained by His mercy and truth, exceeded all other manifestations of Himself as subject of praise.
psa 138:3That promise, as an answer to his prayers in distress, revived and strengthened his faith; and, as the basis of other revelations of the Messiah, it will be the occasion of praise by all who hear and receive it (Psa 68:29, Psa 68:31; Isa 4:3).
psa 138:5for great is the glory--or, "when the glory shall be great," in God's fulfilling His purposes of redemption.
psa 138:6On this general principle of God's government (Isa 2:11; Isa 57:15; Isa 66:2), he relies for God's favor in saving him, and overthrowing his enemies.
knoweth afar off--their ways and deserts (Psa 1:6).
psa 138:8God will fulfil His promise.