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 2020/09/27 13:29:08 UTC

[GitHub] [skywalking-python] Humbertzhang opened a new pull request #74: Support kafka reporter protocol

Humbertzhang opened a new pull request #74:
URL: https://github.com/apache/skywalking-python/pull/74


   <!-- Uncomment the following checklist WHEN AND ONLY WHEN you're adding a new plugin -->
   <!--
   - [ ] Add a test case for the new plugin
   - [ ] Add a component id in [the main repo](https://github.com/apache/skywalking/blob/master/oap-server/server-bootstrap/src/main/resources/component-libraries.yml#L415)
   - [ ] Add a logo in [the UI repo](https://github.com/apache/skywalking-rocketbot-ui/tree/master/src/views/components/topology/assets)
   - [ ] Rebuild the `requirements.txt` by running `tools/env/build_requirements_(linux|windows).sh`
   -->
   


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



[GitHub] [skywalking-python] Humbertzhang commented on a change in pull request #74: Support kafka reporter protocol

Posted by GitBox <gi...@apache.org>.
Humbertzhang commented on a change in pull request #74:
URL: https://github.com/apache/skywalking-python/pull/74#discussion_r495579907



##########
File path: docs/EnvVars.md
##########
@@ -22,3 +22,7 @@ Environment Variable | Description | Default
 | `SW_TRACE_IGNORE`| This config item controls that whether the trace should be ignore | `false` |
 | `SW_TRACE_IGNORE_PATH`| You can setup multiple URL path patterns, The endpoints match these patterns wouldn't be traced. the current matching rules follow Ant Path match style , like /path/*, /path/**, /path/?.| `''` |
 | `SW_ELASTICSEARCH_TRACE_DSL`| If true, trace all the DSL(Domain Specific Language) in ElasticSearch access, default is false | `false` |
+| `SW_KAFKA_REPORTER_BOOTSTRAP_SERVERS` | A list of host/port pairs to use for establishing the initial connection to the Kafka cluster. It is in the form host1:port1,host2:port2,... | `localhost:9092` |
+| `SW_KAFKA_REPORTER_TOPIC_MANAGEMENT` | Specifying Kafka topic name for service instance reporting and registering. | `skywalking-managements` | 
+| `SW_KAFKA_REPORTER_TOPIC_SEGMENT` | Specifying Kafka topic name for Tracing data. | `skywalking-segments` |
+| `SW_KAFKA_REPORTER_CONFIG_key` | The configs to init KafkaProducer. it support all the arguments listed [here](https://kafka-python.readthedocs.io/en/master/apidoc/KafkaProducer.html#kafka.KafkaProducer) | unset |

Review comment:
       I see! I have committed this suggestion, Thank you.




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



[GitHub] [skywalking-python] kezhenxu94 commented on pull request #74: Support kafka reporter protocol

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


   Please also add an E2E test case in the main repo to test this protocol, to make it easier, please refer to https://github.com/apache/skywalking/tree/master/test/e2e/e2e-test/docker/python which tests both `http` protocol and `grpc` protocol


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



[GitHub] [skywalking-python] kezhenxu94 merged pull request #74: Support Kafka reporter protocol

Posted by GitBox <gi...@apache.org>.
kezhenxu94 merged pull request #74:
URL: https://github.com/apache/skywalking-python/pull/74


   


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



[GitHub] [skywalking-python] kezhenxu94 commented on a change in pull request #74: Support kafka reporter protocol

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on a change in pull request #74:
URL: https://github.com/apache/skywalking-python/pull/74#discussion_r495578673



##########
File path: docs/EnvVars.md
##########
@@ -22,3 +22,7 @@ Environment Variable | Description | Default
 | `SW_TRACE_IGNORE`| This config item controls that whether the trace should be ignore | `false` |
 | `SW_TRACE_IGNORE_PATH`| You can setup multiple URL path patterns, The endpoints match these patterns wouldn't be traced. the current matching rules follow Ant Path match style , like /path/*, /path/**, /path/?.| `''` |
 | `SW_ELASTICSEARCH_TRACE_DSL`| If true, trace all the DSL(Domain Specific Language) in ElasticSearch access, default is false | `false` |
+| `SW_KAFKA_REPORTER_BOOTSTRAP_SERVERS` | A list of host/port pairs to use for establishing the initial connection to the Kafka cluster. It is in the form host1:port1,host2:port2,... | `localhost:9092` |
+| `SW_KAFKA_REPORTER_TOPIC_MANAGEMENT` | Specifying Kafka topic name for service instance reporting and registering. | `skywalking-managements` | 
+| `SW_KAFKA_REPORTER_TOPIC_SEGMENT` | Specifying Kafka topic name for Tracing data. | `skywalking-segments` |
+| `SW_KAFKA_REPORTER_CONFIG_key` | The configs to init KafkaProducer. it support all the arguments listed [here](https://kafka-python.readthedocs.io/en/master/apidoc/KafkaProducer.html#kafka.KafkaProducer) | unset |

Review comment:
       Some of the config items are not configureable in this way, for example `partitioner` is `callable` type.
   
   ```suggestion
   | `SW_KAFKA_REPORTER_CONFIG_key` | The configs to init KafkaProducer. it support the basic arguments (whose type is either `str`, `bool`, or `int`) listed [here](https://kafka-python.readthedocs.io/en/master/apidoc/KafkaProducer.html#kafka.KafkaProducer) | unset |
   ```




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



[GitHub] [skywalking-python] muse-dev[bot] commented on a change in pull request #74: Support kafka reporter protocol

Posted by GitBox <gi...@apache.org>.
muse-dev[bot] commented on a change in pull request #74:
URL: https://github.com/apache/skywalking-python/pull/74#discussion_r495573524



##########
File path: skywalking/client/kafka.py
##########
@@ -0,0 +1,112 @@
+#
+# 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.
+#
+
+import logging
+import os
+
+from skywalking import config
+from skywalking.client import ServiceManagementClient, TraceSegmentReportService
+from skywalking.protocol.common.Common_pb2 import KeyStringValuePair
+from skywalking.protocol.management.Management_pb2 import InstancePingPkg, InstanceProperties
+
+from kafka import KafkaProducer
+
+logger = logging.getLogger(__name__)
+
+kafka_configs = {}
+
+
+def __init_kafka_configs():
+    kafka_configs["bootstrap_servers"] = config.kafka_bootstrap_servers.split(",")
+    # process all kafka configs in env
+    kafka_keys = [key for key in os.environ.keys() if key.startswith("SW_KAFKA_REPORTER_CONFIG_")]
+    for kafka_key in kafka_keys:
+        key = kafka_key[25:]
+        val = os.environ.get(kafka_key)
+
+        if val is not None:
+            if val.isnumeric():
+                val = int(val)
+            elif val in ["True", "False"]:
+                val = eval(val)

Review comment:
       *blacklist:*  Use of possibly insecure function - consider using safer ast.literal_eval.




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



[GitHub] [skywalking-python] kezhenxu94 commented on pull request #74: Support Kafka reporter protocol

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


   @Humbertzhang please remember to add an E2E test in the main repo :)


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