application_name is a PostgreSQL specific connection parameter which each client can (and should) set when connecting. It later on helps DBAs and operations staff correlate misbehaving queries with a particular bit of application code.
This SO question explains how to set application_name using SQLAlchemy, but unfortunately, it doesn't work on Heroku, because setting application_name was added on the PostgreSQL 8.5 branch (which was only released as 9.0) whereas the version of PostgreSQL client library (libpq) installed on Heroku's dynos was built from PostgreSQL 8.4.9.
What, if anything, can be done to set application_name on Heroku?