Act 3, scene 2 in Shakespeare's Hamlet is the "play-within-a-play" scene, in which visiting actors perform a play, The Murder of Gonzago, which—with "a speech of some dozen or sixteen lines" that Hamlet added to the play—closely resembles the manner in which Claudius murdered Hamlet's father.
The play seriously upsets Claudius, which seriously upsets his wife, Gertrude, who sends Rosencrantz and Guildenstern to Hamlet to tell him that she'd like to speak with him. Rather than do as his mother requests, Hamlet chooses to stay and banter with Rosencrantz and Guildenstern.
While Hamlet is playing words with Rosencrantz and Guildenstern, the "play-within-a-play" actors pass through with their musical instruments. Hamlet asks to see a recorder, which he then uses as the physical representation of an extended metaphor.
Rosencrantz and Guildenstern have standing orders from Claudius to find out what Hamlet knows and what's troubling him and report whatever they "glean" back to Claudius.
CLAUDIUS: I entreat you both
. . . so by your companies
To draw him on to pleasures, and to gather
So much as from occasion you may glean,
Whether aught to us unknown afflicts him thus
That open'd lies within our remedy.
Hamlet suspects that Rosencrantz and Guildenstern are spying on him for Claudius, and he calls them out for it.
HAMLET: Why do you go about to recover the wind of me, as if you
would drive me into a toil?
Then Hamlet asks Guildenstern to play the recorder, which Guildenstern says he cannot.
HAMLET: It is as easy as lying . . . Look you, these
are the stops.
GUILDENSTERN: But these cannot I command to any utterance
of harmony. I have not the skill.
HAMLET: Why, look you now, how unworthy a thing you make
of me! You would play upon me; you would seem to know
my stops; you would pluck out the heart of my mystery;
you would sound me from my lowest note to the top of my
compass; and there is much music, excellent voice, in
this little organ, yet cannot you make it speak. 'Sblood,
do you think I am easier to be played on than a pipe? Call
me what instrument you will, though you can fret me, you
cannot play upon me.
God bless you, sir!
Hamlet reprimands Rosencrantz and Guildenstern for spying on him, trying to trick him into revealing information about himself, trying to manipulate him, and trying to "play" him for a fool.
In fact, Hamlet has been playing Rosencrantz and Guildenstern all along, and they will play the ultimate price for trying to trick him when they get to England without him later in the play.