@@ -57,13 +57,13 @@ def test_started(self):
5757 # pylint: disable=protected-access
5858 span = command_tracer ._pop_span (mock_event )
5959 self .assertIs (span .kind , trace_api .SpanKind .CLIENT )
60- self .assertEqual (span .name , "database_name.command_name " )
60+ self .assertEqual (span .name , "database_name.find " )
6161 self .assertEqual (span .attributes [SpanAttributes .DB_SYSTEM ], "mongodb" )
6262 self .assertEqual (
6363 span .attributes [SpanAttributes .DB_NAME ], "database_name"
6464 )
6565 self .assertEqual (
66- span .attributes [SpanAttributes .DB_STATEMENT ], "command_name "
66+ span .attributes [SpanAttributes .DB_STATEMENT ], "find "
6767 )
6868 self .assertEqual (
6969 span .attributes [SpanAttributes .NET_PEER_NAME ], "test.com"
@@ -181,7 +181,7 @@ def test_int_command(self):
181181
182182 self .assertEqual (len (spans_list ), 1 )
183183 span = spans_list [0 ]
184- self .assertEqual (span .name , "database_name.command_name " )
184+ self .assertEqual (span .name , "database_name.123 " )
185185
186186 def test_no_op_tracer (self ):
187187 mock_event = MockEvent ({})
@@ -199,10 +199,11 @@ def test_capture_statement_getmore(self):
199199 "command_name" : "getMore" ,
200200 "collection" : "test_collection" ,
201201 }
202+ mock_event = MockEvent (command_attrs )
203+
202204 command_tracer = CommandTracer (
203205 self .tracer , capture_statement = True
204206 )
205- mock_event = MockEvent (command_attrs )
206207 command_tracer .started (event = mock_event )
207208 command_tracer .succeeded (event = mock_event )
208209
@@ -297,6 +298,7 @@ def get(self, key, default=""):
297298class MockEvent :
298299 def __init__ (self , command_attrs , connection_id = None , request_id = "" ):
299300 self .command = MockCommand (command_attrs )
301+ self .command_name = self .command .get ("command_name" )
300302 self .connection_id = connection_id
301303 self .request_id = request_id
302304
0 commit comments