The custom callback was only to show how the metrics can be calculated during training like in the example we have in the forum for XGBoost (as a kind of reporting overview).
If you want to really want to optimize for a specific metric the custom loss is the way to go.