@@ -61,7 +61,6 @@ async def fetch(self, session, url, headers=None):
6161 except aiohttp .web_exceptions .HTTPException :
6262 pass
6363
64-
6564 def test_publish (self ):
6665 @asyncio .coroutine
6766 def test ():
@@ -100,6 +99,44 @@ def test():
10099 self .assertTrue (type (rabbitmq_span .stack ) is list )
101100 self .assertGreater (len (rabbitmq_span .stack ), 0 )
102101
102+ def test_publish_alternative (self ):
103+ @asyncio .coroutine
104+ def test ():
105+ with async_tracer .start_active_span ('test' ):
106+ msg = asynqp .Message ({'hello' : 'world' }, content_type = 'application/json' )
107+ self .exchange .publish (msg , routing_key = 'routing.key' )
108+
109+ self .loop .run_until_complete (test ())
110+
111+ spans = self .recorder .queued_spans ()
112+ self .assertEqual (2 , len (spans ))
113+
114+ rabbitmq_span = spans [0 ]
115+ test_span = spans [1 ]
116+
117+ self .assertIsNone (async_tracer .active_span )
118+
119+ # Same traceId
120+ self .assertEqual (test_span .t , rabbitmq_span .t )
121+
122+ # Parent relationships
123+ self .assertEqual (rabbitmq_span .p , test_span .s )
124+
125+ # Error logging
126+ self .assertFalse (test_span .error )
127+ self .assertIsNone (test_span .ec )
128+ self .assertFalse (rabbitmq_span .error )
129+ self .assertIsNone (rabbitmq_span .ec )
130+
131+ # Rabbitmq
132+ self .assertEqual ('test.exchange' , rabbitmq_span .data .rabbitmq .exchange )
133+ self .assertEqual ('publish' , rabbitmq_span .data .rabbitmq .sort )
134+ self .assertIsNotNone (rabbitmq_span .data .rabbitmq .address )
135+ self .assertEqual ('routing.key' , rabbitmq_span .data .rabbitmq .key )
136+ self .assertIsNotNone (rabbitmq_span .stack )
137+ self .assertTrue (type (rabbitmq_span .stack ) is list )
138+ self .assertGreater (len (rabbitmq_span .stack ), 0 )
139+
103140 def test_many_publishes (self ):
104141 @asyncio .coroutine
105142 def test ():
0 commit comments