You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2022/07/18 14:28:40 UTC

[GitHub] [skywalking-python] tom-pytel opened a new pull request, #224: Allow RabbitMQ BlockingChannel.basic_consume() to link with outgoing spans

tom-pytel opened a new pull request, #224:
URL: https://github.com/apache/skywalking-python/pull/224

   Previously, incoming rabbitmq messages could not link to outgoing spans due to how the `pika` works internally. This is a workaround which fixes that at least for `BlockingChannel.basic_consume()`. Other types of channels will need their own workarounds (and can use this as a model).


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-python] tom-pytel merged pull request #224: Allow RabbitMQ BlockingChannel.basic_consume() to link with outgoing spans

Posted by GitBox <gi...@apache.org>.
tom-pytel merged PR #224:
URL: https://github.com/apache/skywalking-python/pull/224


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-python] sonatype-lift[bot] commented on a diff in pull request #224: Allow RabbitMQ BlockingChannel.basic_consume() to link with outgoing spans

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #224:
URL: https://github.com/apache/skywalking-python/pull/224#discussion_r923448626


##########
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:
   I've recorded this as ignored for this pull request. If you change your mind, just comment `@sonatype-lift unignore`.



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-python] Superskyyy commented on pull request #224: Allow RabbitMQ BlockingChannel.basic_consume() to link with outgoing spans

Posted by GitBox <gi...@apache.org>.
Superskyyy commented on PR #224:
URL: https://github.com/apache/skywalking-python/pull/224#issuecomment-1188141477

   LGTM


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-python] kezhenxu94 commented on pull request #224: Allow RabbitMQ BlockingChannel.basic_consume() to link with outgoing spans

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on PR #224:
URL: https://github.com/apache/skywalking-python/pull/224#issuecomment-1187625744

   Can you check the failed unit tests?


-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-python] sonatype-lift[bot] commented on a diff in pull request #224: Allow RabbitMQ BlockingChannel.basic_consume() to link with outgoing spans

Posted by GitBox <gi...@apache.org>.
sonatype-lift[bot] commented on code in PR #224:
URL: https://github.com/apache/skywalking-python/pull/224#discussion_r923443038


##########
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:
   *try_except_pass:*  Try, Except, Pass detected.
   
   Reply with *"**@sonatype-lift help**"* for info about LiftBot commands.
   Reply with *"**@sonatype-lift ignore**"* to tell LiftBot to leave out the above finding from this PR.
   Reply with *"**@sonatype-lift ignoreall**"* to tell LiftBot to leave out all the findings from this PR and from the status bar in Github.
   
   When talking to LiftBot, you need to **refresh** the page to see its response. [Click here](https://help.sonatype.com/lift/talking-to-lift) to get to know more about LiftBot commands.
   
   ---
   
   Was this a good recommendation?
   [ [πŸ™ Not relevant](https://www.sonatype.com/lift-comment-rating?comment=299585279&lift_comment_rating=1) ] - [ [πŸ˜• Won't fix](https://www.sonatype.com/lift-comment-rating?comment=299585279&lift_comment_rating=2) ] - [ [πŸ˜‘ Not critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=299585279&lift_comment_rating=3) ] - [ [πŸ™‚ Critical, will fix](https://www.sonatype.com/lift-comment-rating?comment=299585279&lift_comment_rating=4) ] - [ [😊 Critical, fixing now](https://www.sonatype.com/lift-comment-rating?comment=299585279&lift_comment_rating=5) ]



-- 
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [skywalking-python] tom-pytel commented on a diff in pull request #224: Allow RabbitMQ BlockingChannel.basic_consume() to link with outgoing spans

Posted by GitBox <gi...@apache.org>.
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: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org