default-command-history-filter-garbage is a variable defined in `chistory.el'.
Its value is

(command-history-mode list-command-history electric-command-history)

A list of symbols to be ignored by `default-command-history-filter'.
If that function is given a list whose car is an element of this list,
then it will return non-nil (indicating the list should be discarded from
the history).
Initially, all commands related to the command history are discarded.

You can customize this variable.