DS2 had an upper GI endoscopy at about 2 yo. When he had it done, you are allowed in the aesthesia room whilst they put lo to sleep (this is quite traumatic, just because they count down from 10 and their eyes roll back and they are gone. If like me, you are a control freak, you may want to be there for this, but I know some people prefer to send their dh/dp in instead). However, the actual procedure took about 30-45 mins iirc and then they go to the recovery room to wake up. With very little ones, you are allowed to be there as they regain consiousness so as they are not too distressed.
I will admit, it is not nice, but in the long run, if they find some useful info it will be worth it. In the case of ds2, he is dairy allergic and neocate also made him vomit. He was diagnosed with eosinophilic esophagitis, which made the doctors realise that whilst he was symptomatically similar to a child with reflux, he was not going to respond to reflux medication. Since we have worked out his allergies (we hope!), he has improved significantly.
I should also add, don't be worried though, it is a low risk procedure and they do know what they are doing! My comment that it is "not nice" is from my perspective of the parent waiting for my baby to come out again, rather than from ds2's perspective. He btw was completely unfazed by the whole process, aside from a sore throat for a day or so.