This project is based on https://github.com/Azure-Samples/docker-flask-postgres
The objective was to get a very simple project in Flask PostgreSQL, and inset Elastic APM to take a look at what is happening with each request to the app, specially what queries are made to the database.
I've created some bad routes to have interesting data on Elastic APM dashboard
# bad query
@APP.route('/bad_query')
def view_registered_guests_bad_query():
for _ in range(20):
guests = Guest.query.all()
return render_template('guest_list.html', guests=guests)
# error message
@APP.route('/hello')
def apm_message_hello():
apm.capture_message('hello, world!')
return render_template('apm_hello.html')
# Error
@APP.route('/error')
def apm_error():
try:
1 / 0
except ZeroDivisionError:
apm.capture_exception()
return render_template('apm_error.html')
# Unhandled error
@APP.route('/fatal_error')
def apm_fatal_error():
1 / 0
return render_template('apm_error.html')
Using a HTTP load generator I've generated some load on the server and Elastic APM quickly showed me where to look, I attach some screenshots