Hannah’s story is in 1 Samuel 1&2; the story in chapter 1, her prayer or song reacting to it in chapter 2:1-10.
Hannah is married but has been unable to conceive. When the family comes to worship and offer sacrifices she prays for a son, promising him to the Lord for his entire life. She prays so fervently in her heart that her lips are moving but no sound comes out so that Eli, the priest, thinks that she is drunk.
The Lord answers her prayer and she gives birth to Samuel, and once he is weaned she brings him to Eli to raise Samuel in service to the Lord. (Eli may not be the best choice to raise a child; his sons are described as corrupt, but that’s a different story. You can read it in the rest of chapter 2.)
There are those who hear echoes of Hannah’s song in Mary’s Magnificat in Luke 1:46-55. You might read them both and see if you agree.
Christian author Philip Yancey writes in his 2021 memoir, Where the Light Fell that he has hated this story for many years. A person could say that through his writing, including books like, What’s So Amazing About Grace? and, The Jesus I Never Knew that Yancey has been a prophetic voice to American Evangelical Christians, and therefore a type of Samuel. But since his path didn’t follow what his mother had envisioned, he received from her a judgement that not only had he betrayed her, but also God. Which is an example showing the truth of Isaiah 55:8, “For my thoughts are not your thoughts, neither are your ways my ways,” declares the LORD. (NIV).