Kibana version: 7.11.1
Elasticsearch version: 7.11.1
APM Server version: 7.11.0
APM Agent language and version: Python 6.3.3
Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):
Hi, I'm running a Python Flask application and connected it to APM. However, I've noticed that when I add an error handler to my application as below, APM will see the error without providing a stack trace.
@app.errorhandler(Exception)
def handle_anything(error):
try:
status_code = error.status_code
except AttributeError:
status_code = 500
response_dict = {"type": str(type(error)), "exception_message": str(error)}
app.logger.exception(response_dict, status_code=status_code)
response = jsonify(error=response_dict)
response.content_type = "application/json"
response.status_code = status_code
return response
If I remove this error handling, I get the expected output.
My question is can I add some more sophisticated error handling in a Flask application while still ensuring error traces are captured by the APM agent? Or explicitly ship error traces to APM server somehow?