the keyhole contour
Some integrands carry a branch point — a fractional power like x^s or a logarithm — that makes the function multivalued and forbids you from drawing a closed loop that encircles the branch point freely. The keyhole contour is the clever curve that respects a branch cut: it threads around the cut like a key around a lock's pin, so the function stays single-valued the whole way around.
Imagine a branch cut along the positive real axis (the usual choice for x^s or log x). The keyhole contour has four parts: a large circle of radius R run counterclockwise, then inward along the top edge of the cut, a tiny circle of radius epsilon around the branch point at the origin run clockwise, and back out along the bottom edge of the cut. The magic is that the top and bottom edges sit on opposite sides of the cut, where the multivalued function takes different values — for x^s the bottom edge value is e^(2 pi i s) times the top edge value, and for log x the bottom edge value is the top plus 2 pi i. So the two straight pieces do not cancel; they combine into a known multiple of the integral you want, while the large and small circles vanish in the limit. The residue theorem applied to the whole keyhole then solves for that integral.
This is the standard machine for integrals from 0 to infinity of x^(s-1) f(x) dx and for integrals involving log x, which resist all the earlier contours. The defining feature to keep straight: it is the jump in the function across the cut — not its residues alone — that produces the answer. You are exploiting multivaluedness, not avoiding it.
For the integral from 0 to infinity of x^(s-1) / (1 + x) dx with 0 < s < 1, the keyhole around the positive axis gives (1 - e^(2 pi i s)) times the integral = 2 pi i times the residue at z = -1, yielding the classic answer pi / sin(pi s).
The jump across the branch cut, not a residue alone, delivers the integral.
You must fix the branch of x^s or log z consistently along the whole contour; the top and bottom edges use the same branch but at arguments 0 and 2 pi, which is precisely why they differ. Forgetting this jump (treating top and bottom as equal) wrongly makes the straight parts cancel and gives zero.