This wasp is from a group of insects, which are parasites, as they lay their eggs inside the body of other insects. The long needle is not a sting but a long ovipositor, using its sensitive antennae this insect can detect the vibrations of wood-boring grubs like the goat moth caterpillars and beetle larvae, and sometimes even pupae. It then drills its ovipositor into the wood of growing, fallen or cut trees and like a hypodermic needle it injects a single egg into the grub larvae. I have seen this species boring into thick branches on growing trees frustratingly out of reach for my photography, but many photographers have filmed this interesting wasp drilling its ovipositor.
As a youngster, I hated parasitic wasps as I collected insect larvae from the wild, and it was terrifying to have a very lively parasitic was emerging from a chrysalis instead of an attractive moth. But what I always thought was very clever is a female parasite of some of these large species, lay a single egg into a moth caterpillar, the parasitic larvae live inside the caterpillar not destroying its internal organs, the full-grown moth larvae then buries underground to pupate. Eventually, the parasite grub will devour its host alive, leaving only an empty shell, then the parasite grub changes into its own pupae inside the moth pupae having a safe home to hibernate during the winter months.
Although parasites are real aliens of the insect world, living in the bodies of its host, they do control insect population, for example a hawk moth will lay hundreds of eggs but only a few will survive, because of birds and other prey, but especially parasites which are experts at finding their hosts, some parasites/flies are even small enough to live inside a moth or butterfly egg. I once witnessed many wasps/ flies emerging from a Poplar hawk egg and other eggs on the sallow leaf and bushes were all coloured black instead of a healthy green as they were full of wasps/flies waiting to hatch.