Since you just want to custom query name for monitoring purpose, so i think you only need to change the query name in the ActiveRecord::ConnectionAdapters#log method, this method is the one log the sql query that be executed, include the query name.
Here is my solution:
# lib/active_record/base.rb
# note that MUST be base.rb
# otherwise you need to add initializer to extend Rails core
#
module ActiveRecord
  module ConnectionAdapters
    class AbstractAdapter
      attr_accessor :log_tag
      private
      alias old_log log
      def log(sql, name = "SQL", binds = [], type_casted_binds = [], statement_name = nil)
        if name != 'SCHEMA'
          name = @log_tag
          @log_tag = nil # reset
        end
        old_log(sql, name, binds, type_casted_binds, statement_name) do
          yield
        end
      end
    end
  end
  module QueryMethods
    def log_tag(tag_name) # class method
      spawn.log_tag(tag_name)
      self
    end
  end
  module Querying
    delegate :log_tag, to: :all
  end
  class Relation
    def log_tag(tag_name) # instance method
      conn = klass.connection
      conn.log_tag = tag_name
      self
    end
  end
end
Demo
Task.log_tag("DEMO").group(:status).count
# DEMO (0.7ms)  SELECT COUNT(*) AS count_all, "tasks"."status" AS tasks_status FROM "tasks" GROUP BY "tasks"."status"
Task.where(status: 6).log_tag("SIX").first(20)
# SIX (0.8ms)  SELECT "tasks".* FROM "tasks" WHERE "tasks"."status" = ? ORDER BY "tasks"."id" ASC LIMIT ?
Task.where(status: 6).first(20)
# (0.8ms)  SELECT "tasks".* FROM "tasks" WHERE "tasks"."status" = ? ORDER BY "tasks"."id" ASC LIMIT ?
Note
In case you want to fix query name for specific query, you can use a hash with key is the whole the specific sql string (or hash of whole sql, such as the way Rails core cache query: query_signature = ActiveSupport::Digest.hexdigest(to_sql)) and the value is the query name you want.
# set up before hand
ActiveRecord::ConnectionAdapters::LogTags[Product.where...to_sql] = "DEMO"
# AbstractAdapter
LogTags = Hash.new
def log(sql, name...)
  name = LogTags[sql]
  # ...
end