This Psalm is unusual. The Living Bible paraphrase confirms my opinion: It is a conversation between David and God. It begins with David crying out for God to hear his prayer
1Answer me when I call to you,
my righteous God.
Give me relief from my distress;
have mercy on me and hear my prayer.
In the next section God calls the people, and apparently David, to account for their neglect of praise and worship.
How long will you love delusions and seek false gods[b]?[c]
3 Know that the Lord has set apart his faithful servant for himself;
the Lord hears when I call to him.
In Verse 4 he refers to how the quality of sleep is affected by the spiritual condition.
when you are on your beds,
search your hearts and be silent.
In verse 5 I can't tell whether it is David or God that calls us to offer "righteous sacrifices," but in either case we are counseled to "trust in the Lord."
5 Offer the sacrifices of the righteous
and trust in the Lord.
In Verse 6 the speaker is David. He knows that God is our only help in times of difficulty and he seeks the light of his face.
Let the light of your face shine on us.
7 Fill my heart with joy
when their grain and new wine abound.
David again refers to the sustaining nature of peaceful sleep being assured that God provides for his safety.
for you alone, Lord,
make me dwell in safety.