Elasticsearch version :
6.8.4 APM Server version :
7.6.0 APM Agent language and version :
Java - 1.16.0
Original install method (e.g. download page, yum, deb, from source, etc.) and version :
Download page
python agent is not capturing the handled exception error events. below is script to connect elasticsearch and performing search query on non existing index.
try:
es = Elasticsearch(['ip:9200'], http_auth=('user','pass'), timeout=30)
result = es.search(index="index123_read")
log.info(str(result))
except:
log.error("got error")
for this we are getting only elasticsearch span without any exception details.
We would like to capture the python handled exceptions error events
NotFoundError(404, u'index_not_found_exception', u'no such index', index123_read, index_or_alias)
is there anything python agent configuration to capture handled exception errors? or does it not support?
If you want log messages to be captured bei the Elastic APM agent, you need to set up our logging handler. How to do this depends a bit on wether you use a web framework. See the docs for Flask and Django. If you don't use one of these frameworks, it's probably easiest to adapt the last code snippet in the Flask section to your needs.
Another option is to explicitly capture the exception without going through logging, e.g.:
import elasticapm
apm = elasticapm.get_client()
try:
es = Elasticsearch(['ip:9200'], http_auth=('user','pass'), timeout=30)
result = es.search(index="index123_read")
log.info(str(result))
except:
apm.capture_exception(handled=True)
handled=True indicates that you caught the exception.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.