Passage
When Doeg the Edomite came and told Saul: David went to the house of Achimelech.
When Doeg the Edomite came and told Saul: David went to the house of Achimelech.
Psalms 51:1 Unto the end, understanding for David,
Psalms 51:2 When Doeg the Edomite came and told Saul: David went to the house of Achimelech.
Psalms 51:3 Why dost thou glory in malice, thou that art mighty in iniquity?
Psalms 51:4 All the day long thy tongue hath devised injustice: as a sharp razor, thou hast wrought deceit.
The verse centers on "doeg", "edomite", "came", "told", "saul", "david", "went", and "house". It is saying that the verse draws attention to "doeg" and "edomite", so its meaning should be read from those terms before moving to application.
The nearby context moves from verse 1's "Unto the end understanding for David..." into verse 3's "Why dost thou glory in malice thou...", so "doeg" and "edomite" belong inside that flow. In Psalms context, the local focus is worship, trust, the LORD's kingship, and covenant mercy.
A plain takeaway is to answer the verse's own emphasis on "doeg" and "edomite" with trust shaped by these words, not by a vague optimism outside the passage.