Skip to content

Commit 930f4ec

Browse files
author
cooolr
authored
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
1 parent e118f26 commit 930f4ec

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

skywalking/plugins/sw_pymongo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ def inject_bulk_write(_Bulk, bulk_op_map):
101101
_execute = _Bulk.execute
102102

103103
def _sw_execute(this: _Bulk, *args, **kwargs):
104-
address = this.collection.database.client.address
105-
peer = "%s:%s" % address
104+
nodes = this.collection.database.client.nodes
105+
peer = ",".join(["%s:%s" % address for address in nodes])
106106
context = get_context()
107107

108108
sw_op = "MixedBulkWriteOperation"
@@ -134,8 +134,8 @@ def inject_cursor(Cursor):
134134
__send_message = Cursor._Cursor__send_message
135135

136136
def _sw_send_message(this: Cursor, operation):
137-
address = this.collection.database.client.address
138-
peer = "%s:%s" % address
137+
nodes = this.collection.database.client.nodes
138+
peer = ",".join(["%s:%s" % address for address in nodes])
139139

140140
context = get_context()
141141
op = "FindOperation"

0 commit comments

Comments
 (0)