Implement stats endpoint for context and query instances