trace: refactor to support multiple env variables