From e3db6d4f4e98f7764e1a3b33fe9e57533ba7d34e Mon Sep 17 00:00:00 2001 From: Benjamin Wohlwend Date: Tue, 27 Sep 2022 13:44:59 +0200 Subject: [PATCH 1/2] fix errors in pymongo tests introduced in #1639 --- tests/instrumentation/pymongo_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/instrumentation/pymongo_tests.py b/tests/instrumentation/pymongo_tests.py index 10d68628e..d93b3401d 100644 --- a/tests/instrumentation/pymongo_tests.py +++ b/tests/instrumentation/pymongo_tests.py @@ -99,7 +99,7 @@ def test_collection_count(instrument, elasticapm_client, mongo_database): assert span["context"]["destination"] == { "address": os.environ.get("MONGODB_HOST", "localhost"), "port": int(os.environ.get("MONGODB_PORT", 27017)), - "service": {"name": "", "resource": "mongodb", "type": ""}, + "service": {"name": "", "resource": "mongodb/elasticapm_test", "type": ""}, } @@ -258,7 +258,7 @@ def test_collection_find(instrument, elasticapm_client, mongo_database): assert span["context"]["destination"] == { "address": os.environ.get("MONGODB_HOST", "localhost"), "port": int(os.environ.get("MONGODB_PORT", 27017)), - "service": {"name": "", "resource/elasticapm_test": "mongodb", "type": ""}, + "service": {"name": "", "resource": "mongodb/elasticapm_test", "type": ""}, } From c78644b8690ec66fe4bc8a93427521ba1d1ec57b Mon Sep 17 00:00:00 2001 From: Benjamin Wohlwend Date: Wed, 28 Sep 2022 10:16:53 +0200 Subject: [PATCH 2/2] fix cursor refresh destination tracking --- elasticapm/instrumentation/packages/pymongo.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elasticapm/instrumentation/packages/pymongo.py b/elasticapm/instrumentation/packages/pymongo.py index d19036b6a..c7ca3faa9 100644 --- a/elasticapm/instrumentation/packages/pymongo.py +++ b/elasticapm/instrumentation/packages/pymongo.py @@ -132,7 +132,8 @@ def call(self, module, method, wrapped, instance, args, kwargs): span_type="db", span_subtype="mongodb", span_action="query", - extra={"destination": {}}, + extra=context, + leaf=True, ) as span: response = wrapped(*args, **kwargs) if span.context and instance.address: