It's the URI, not necessarily an originating script. http://php.net/manual/en/reserved.variables.server.php
So it will depend on the url that was called in order to serve your script.
So for example, you could have htaccess rewrite the url so www.yoursite.com/something actually serves main.php which includes test.php. request URI would record /something and not any of the files that were used to serve the page.
You could just pass a unique ID to the wrapper method you created. You should be able to track and log which query was altered pretty easily assuming you write it out in a way that makes sense.