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/07/15 02:30:41 UTC

[GitHub] [skywalking-python] kezhenxu94 commented on a change in pull request #35: add PyMsql Plugin

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



##########
File path: skywalking/plugins/sw_pymysql/__init__.py
##########
@@ -0,0 +1,57 @@
+#
+# 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
+
+from skywalking import Layer, Component
+from skywalking.trace import tags
+from skywalking.trace.carrier import Carrier
+from skywalking.trace.context import get_context
+from skywalking.trace.tags import Tag
+
+logger = logging.getLogger(__name__)
+
+
+def install():
+    # noinspection PyBroadException
+    try:
+        from pymysql.cursors import Cursor
+
+        _execute = Cursor.execute
+
+        def _sw_execute(this: Cursor, query, args=None):

Review comment:
       we can provide another option to allow the users to collect the `args`, though that can be done in another PR as an enhancement, if you want to do that, refer to `plugin.mysql.trace_sql_parameters` and `plugin.mysql.sql_parameters_max_length` in https://github.com/apache/skywalking/blob/cc9ea271a720e8def161a583595f75da9bda77a5/docs/en/setup/service-agent/java-agent/README.md#table-of-agent-configuration-properties 

##########
File path: tests/plugin/sw_pymysql/services/provider.py
##########
@@ -0,0 +1,45 @@
+#
+# 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 time
+
+from skywalking import agent, config
+
+if __name__ == '__main__':
+    config.service_name = 'provider'
+    config.logging_level = 'DEBUG'
+    agent.start()
+
+    from flask import Flask, jsonify
+    import pymysql.cursors

Review comment:
       Add `pymysql` to https://github.com/apache/skywalking-python/blob/10f5dbdc1952d23e5cbddf75548ca87e2d378d3a/setup.py#L44-L47 so that others could install the module when running `make setup-test` locally




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