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 2021/06/23 02:11:38 UTC

[GitHub] [skywalking-python] kezhenxu94 commented on a change in pull request #125: Python celery plugin

kezhenxu94 commented on a change in pull request #125:
URL: https://github.com/apache/skywalking-python/pull/125#discussion_r656290342



##########
File path: skywalking/plugins/sw_celery.py
##########
@@ -0,0 +1,114 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from skywalking import Layer, Component, config
+from skywalking.trace import tags
+from skywalking.trace.carrier import Carrier
+from skywalking.trace.context import get_context
+from skywalking.trace.tags import Tag
+
+
+def install():
+    from urllib.parse import urlparse
+    from celery import Celery
+
+    def send_task(self, name, args=None, kwargs=None, **options):
+        # NOTE: Lines commented out below left for documentation purposes if sometime in the future exchange / queue
+        # names are wanted. Currently these do not match between producer and consumer so would need some work.
+
+        broker_url = self.conf['broker_url']
+        # exchange = options['exchange']
+        # queue = options['routing_key']
+        # op = 'celery/{}/{}/{}'.format(exchange or '', queue or '', name)
+        op = 'celery/' + name
+
+        if broker_url:
+            url = urlparse(broker_url)
+            peer = '{}:{}'.format(url.hostname, url.port)
+        else:
+            peer = '???'

Review comment:
       Is this the final state?

##########
File path: skywalking/agent/__init__.py
##########
@@ -65,14 +76,40 @@ def __init():
         __protocol = KafkaProtocol()
 
     plugins.install()
+    __init_threading()
 
 
 def __fini():
     __protocol.report(__queue, False)
     __queue.join()
+    __finished.set()
+
+
+def __fork_before():
+    if config.protocol != 'http':
+        logger.warning('fork() not currently supported with %s protocol' % config.protocol)

Review comment:
       Is it possible to make gRPC work in fork? Like I said in DM, recreate a brand new gRPC channel in forked process?




-- 
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.

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