You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/08/11 17:04:53 UTC

[skywalking-python] branch master updated: Update sw_pymongo.py to be compatible with cluster mode (#150)

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git


The following commit(s) were added to refs/heads/master by this push:
     new 930f4ec  Update sw_pymongo.py to be compatible with cluster mode (#150)
930f4ec is described below

commit 930f4ec97c29bc8c465a57336a88b9f4efbfd36c
Author: cooolr <32...@users.noreply.github.com>
AuthorDate: Thu Aug 12 01:04:50 2021 +0800

    Update sw_pymongo.py to be compatible with cluster mode (#150)
    
    replace the `this.collection.database.client.address` with the `this.collection.database.client.nodes` to be compatible with the mongodb cluster
---
 skywalking/plugins/sw_pymongo.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/skywalking/plugins/sw_pymongo.py b/skywalking/plugins/sw_pymongo.py
index 9d7f0f9..01abea7 100644
--- a/skywalking/plugins/sw_pymongo.py
+++ b/skywalking/plugins/sw_pymongo.py
@@ -101,8 +101,8 @@ def inject_bulk_write(_Bulk, bulk_op_map):
     _execute = _Bulk.execute
 
     def _sw_execute(this: _Bulk, *args, **kwargs):
-        address = this.collection.database.client.address
-        peer = "%s:%s" % address
+        nodes = this.collection.database.client.nodes
+        peer = ",".join(["%s:%s" % address for address in nodes])
         context = get_context()
 
         sw_op = "MixedBulkWriteOperation"
@@ -134,8 +134,8 @@ def inject_cursor(Cursor):
     __send_message = Cursor._Cursor__send_message
 
     def _sw_send_message(this: Cursor, operation):
-        address = this.collection.database.client.address
-        peer = "%s:%s" % address
+        nodes = this.collection.database.client.nodes
+        peer = ",".join(["%s:%s" % address for address in nodes])
 
         context = get_context()
         op = "FindOperation"