tom-pytel commented on code in PR #224:
URL: https://github.com/apache/skywalking-python/pull/224#discussion_r923448533


##########
skywalking/plugins/sw_rabbitmq.py:
##########
@@ -73,8 +74,32 @@ def _sw_basic_publish(this, exchange,
 
 
 def _sw__on_deliver_func(__on_deliver):
+    from pika.adapters.blocking_connection import BlockingChannel
+
     def _sw__on_deliver(this, method_frame, header_frame, body):
         peer = f'{this.connection.params.host}:{this.connection.params.port}'
+        consumer_tag = method_frame.method.consumer_tag
+
+        # The following is a special case for one type of channel to allow any 
exit spans to be linked properly to the
+        # incoming segment. Otherwise, if we create the span here the span 
ends before any oser callbacks are called and
+        # so any new spans will not be linked to the incoming message.
+
+        defer_span = False
+
+        try:  # future-proofing if object structure changes
+            if consumer_tag not in this._cancelled and consumer_tag in 
this._consumers:
+                consumer = this._consumers[consumer_tag]
+
+                if isinstance(consumer.__self__, BlockingChannel):
+                    method_frame.method._sw_peer = peer
+                    defer_span = True
+
+        except Exception:

Review Comment:
   @sonatype-lift ignore



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to