capture destination host for instrumentations of services#618
Conversation
6c40a6a to
e1c5581
Compare
basepi
left a comment
There was a problem hiding this comment.
Looks great. One question about a filename, otherwise 👍 👍
| cls_name, method_name = method.split(".", 1) | ||
| signature = ".".join([instance.full_name, method_name]) | ||
| with capture_span(signature, span_type="db", span_subtype="mongodb", span_action="query", leaf=True): | ||
| host, port = instance.database.client.address |
There was a problem hiding this comment.
Some how this caused exception with PyMongo 3.9.0: TypeError: cannot unpack non-iterable NoneType object
Traceback (most recent call last):
File "/srv/brm-api_staging/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/srv/brm-api_staging/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/srv/brm-api_staging/venv/lib/python3.8/site-packages/flask_cors/extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/srv/brm-api_staging/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/srv/brm-api_staging/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/srv/brm-api_staging/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/srv/brm-api_staging/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "<decorator-gen-70>", line 2, in show_company
File "./geetest_client.py", line 211, in captcha_counter_decorator
return func(*args, **kwargs)
File "./company/__init__.py", line 413, in show_company
count = db_data_count.find_one({'crn': company['crn']}) or {}
File "/srv/brm-api_staging/venv/lib/python3.8/site-packages/elasticapm/instrumentation/packages/base.py", line 210, in call_if_sampling
return self.call(module, method, wrapped, instance, args, kwargs)
File "/srv/brm-api_staging/venv/lib/python3.8/site-packages/elasticapm/instrumentation/packages/pymongo.py", line 75, in call
host, port = instance.database.client.address
TypeError: cannot unpack non-iterable NoneType object
There was a problem hiding this comment.
@messense thanks for the heads up! Do you connect to MongoDB with a unix domain socket instead of address/port? That could cause this issue. I'll see if we can work around that.
There was a problem hiding this comment.
We have also encountered this issue. (We do not connect to mongo with unix domain socket).
There was a problem hiding this comment.
@messense @QuantumGhost I opened #797 to try and address this. Would you mind giving this a quick spin in a dev/staging environment? You can install it like this:
pip install "https://github.com/beniwohli/apm-agent-python/archive/pymongo-address.zip#egg=elastic-apm==100
Implementation of span destination information as per elastic/apm#180
refs elastic/apm#115