Welcome to the forum, @francois.tarlier!
I found one issue in your code. You need to do the app.config piece before you set up the apm object, or APM is set up without those config values:
app = Flask(__name__)
app.config["ELASTIC_APM"] = {"DEBUG": DEBUG}
apm = ElasticAPM(app, service_name="flask-app", logging=logging.INFO)
Additionally, did you install psutil? You'll need that to get any of the system metrics.
I took your code, with the one change I showed above, did
pip install flask 'elastic-apm[flask]' psutil
python app.py
curl localhost:8080/login
And saw both transactions and metrics in my local kibana instance.
My guess is that elasticapm.metrics is trying to send the following warning to the logs:
Could not register elasticapm.metrics.sets.cpu.CPUMetricSet metricset: psutil not found. Install it to get system and process metrics
But it's failing because something is odd in the logging. (Probably related to running it in docker -- I didn't tweak the logging at all but I am running it in a local virtualenv.)
Keep me posted if that code change and installing psutil fix the issue for you!