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/12/15 12:27:37 UTC

[GitHub] [skywalking-python] tom-pytel opened a new pull request #102: [Plugin] added pyramid plugin

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


   <!--
   - [ ] 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)
   - [x] 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] tom-pytel commented on a change in pull request #102: [Plugin] added pyramid plugin

Posted by GitBox <gi...@apache.org>.
tom-pytel commented on a change in pull request #102:
URL: https://github.com/apache/skywalking-python/pull/102#discussion_r543313313



##########
File path: skywalking/plugins/sw_pyramid.py
##########
@@ -0,0 +1,56 @@
+#
+# 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
+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 pyramid.router import Router
+
+    def _sw_invoke_request(self, request, *args, **kwargs):
+        context = get_context()
+        carrier = Carrier()
+
+        for item in carrier:
+            val = request.headers.get(item.key)
+
+            if val is not None:
+                item.val = val
+
+        with context.new_entry_span(op=request.path, carrier=carrier) as span:
+            span.layer = Layer.Http
+            span.component = Component.Pyramid
+            span.peer = request.remote_host or request.remote_addr
+
+            span.tag(Tag(key=tags.HttpMethod, val=request.method))  # pyre-ignore
+            span.tag(Tag(key=tags.HttpUrl, val=str(request.url)))  # pyre-ignore

Review comment:
       :facepalm::facepalm::facepalm:




----------------------------------------------------------------
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 #102: [Plugin] added pyramid plugin

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


   


----------------------------------------------------------------
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] tom-pytel commented on pull request #102: [Plugin] added pyramid plugin

Posted by GitBox <gi...@apache.org>.
tom-pytel commented on pull request #102:
URL: https://github.com/apache/skywalking-python/pull/102#issuecomment-745369163


   Ok, I've done the other annoying things so can you handle the test case?


----------------------------------------------------------------
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] tom-pytel commented on a change in pull request #102: [Plugin] added pyramid plugin

Posted by GitBox <gi...@apache.org>.
tom-pytel commented on a change in pull request #102:
URL: https://github.com/apache/skywalking-python/pull/102#discussion_r543337776



##########
File path: skywalking/plugins/sw_pyramid.py
##########
@@ -0,0 +1,56 @@
+#
+# 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
+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 pyramid.router import Router
+
+    def _sw_invoke_request(self, request, *args, **kwargs):
+        context = get_context()
+        carrier = Carrier()
+
+        for item in carrier:
+            val = request.headers.get(item.key)
+
+            if val is not None:
+                item.val = val
+
+        with context.new_entry_span(op=request.path, carrier=carrier) as span:
+            span.layer = Layer.Http
+            span.component = Component.Pyramid
+            span.peer = request.remote_host or request.remote_addr
+
+            span.tag(Tag(key=tags.HttpMethod, val=request.method))  # pyre-ignore
+            span.tag(Tag(key=tags.HttpUrl, val=str(request.url)))  # pyre-ignore

Review comment:
       Here is @TomMD's suggestion from that pull:
   
   > I think this is the second "missing argument" error on Tag.init. If you'd like I can make a PR (or you are free to) that adds igore = [ "Missing argument" ] to the config.toml. Otherwise I'm likely to do something in the backend that removes this seemingly common seemingly false positive.
   




----------------------------------------------------------------
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] TomMD commented on a change in pull request #102: [Plugin] added pyramid plugin

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



##########
File path: skywalking/plugins/sw_pyramid.py
##########
@@ -0,0 +1,56 @@
+#
+# 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
+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 pyramid.router import Router
+
+    def _sw_invoke_request(self, request, *args, **kwargs):
+        context = get_context()
+        carrier = Carrier()
+
+        for item in carrier:
+            val = request.headers.get(item.key)
+
+            if val is not None:
+                item.val = val
+
+        with context.new_entry_span(op=request.path, carrier=carrier) as span:
+            span.layer = Layer.Http
+            span.component = Component.Pyramid
+            span.peer = request.remote_host or request.remote_addr
+
+            span.tag(Tag(key=tags.HttpMethod, val=request.method))  # pyre-ignore
+            span.tag(Tag(key=tags.HttpUrl, val=str(request.url)))  # pyre-ignore

Review comment:
       @kezhenxu94 Yes I can absolutely do that.  I'm a bit buried so if you could give me till the end of the week I'd appreciate it.




----------------------------------------------------------------
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 #102: [Plugin] added pyramid plugin

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


   > Ok, I've done the other annoying things so can you handle the test case?
   
   Will do it tomorrow (hopefully)


----------------------------------------------------------------
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 #102: [Plugin] added pyramid plugin

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



##########
File path: skywalking/plugins/sw_pyramid.py
##########
@@ -0,0 +1,56 @@
+#
+# 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
+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 pyramid.router import Router
+
+    def _sw_invoke_request(self, request, *args, **kwargs):
+        context = get_context()
+        carrier = Carrier()
+
+        for item in carrier:
+            val = request.headers.get(item.key)
+
+            if val is not None:
+                item.val = val
+
+        with context.new_entry_span(op=request.path, carrier=carrier) as span:
+            span.layer = Layer.Http
+            span.component = Component.Pyramid
+            span.peer = request.remote_host or request.remote_addr
+
+            span.tag(Tag(key=tags.HttpMethod, val=request.method))  # pyre-ignore
+            span.tag(Tag(key=tags.HttpUrl, val=str(request.url)))  # pyre-ignore

Review comment:
       @TomMD can you please help to configure ignoring this in somewhere? Or how can I do it by myself?




----------------------------------------------------------------
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] tom-pytel commented on a change in pull request #102: [Plugin] added pyramid plugin

Posted by GitBox <gi...@apache.org>.
tom-pytel commented on a change in pull request #102:
URL: https://github.com/apache/skywalking-python/pull/102#discussion_r543336690



##########
File path: skywalking/plugins/sw_pyramid.py
##########
@@ -0,0 +1,56 @@
+#
+# 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
+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 pyramid.router import Router
+
+    def _sw_invoke_request(self, request, *args, **kwargs):
+        context = get_context()
+        carrier = Carrier()
+
+        for item in carrier:
+            val = request.headers.get(item.key)
+
+            if val is not None:
+                item.val = val
+
+        with context.new_entry_span(op=request.path, carrier=carrier) as span:
+            span.layer = Layer.Http
+            span.component = Component.Pyramid
+            span.peer = request.remote_host or request.remote_addr
+
+            span.tag(Tag(key=tags.HttpMethod, val=request.method))  # pyre-ignore
+            span.tag(Tag(key=tags.HttpUrl, val=str(request.url)))  # pyre-ignore

Review comment:
       Its strange how these lines got flagged as an error in aiohttp but not here under almost identical circumstances.




----------------------------------------------------------------
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 #102: [Plugin] added pyramid plugin

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



##########
File path: tests/plugin/sw_pyramid/test_plugin.py
##########
@@ -0,0 +1,37 @@
+#
+# 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 typing import Callable
+
+import pytest
+import requests
+
+from tests.plugin.base import TestPluginBase
+
+
+@pytest.fixture

Review comment:
       *Invalid decoration:*  Pyre was not able to infer the type of the decorator `pytest.fixture`.

##########
File path: tests/plugin/sw_pyramid/services/consumer.py
##########
@@ -0,0 +1,47 @@
+#
+# 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 urllib import request
+from wsgiref.simple_server import make_server
+
+from pyramid.config import Configurator
+from pyramid.response import Response
+
+from skywalking import agent, config
+
+
+def index(req):
+    data = '{"name": "whatever"}'.encode('utf8')
+    req = request.Request(f'http://provider:9091/{req.path.lstrip("/")}')
+    req.add_header('Content-Type', 'application/json; charset=utf-8')
+    req.add_header('Content-Length', str(len(data)))
+    with request.urlopen(req, data):

Review comment:
       *blacklist:*  Audit url open for permitted schemes. Allowing use of file:/ or custom schemes is often unexpected.




----------------------------------------------------------------
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] tom-pytel commented on pull request #102: [Plugin] added pyramid plugin

Posted by GitBox <gi...@apache.org>.
tom-pytel commented on pull request #102:
URL: https://github.com/apache/skywalking-python/pull/102#issuecomment-745257158


   Here is a snippet:
   ```py
   from wsgiref.simple_server import make_server
   from pyramid.config import Configurator
   from pyramid.response import Response
   
   from skywalking import agent
   from skywalking.decorators import trace
   from skywalking.trace.context import get_context
   import skywalking.trace.context as context
   
   agent.start()
   
   def index(request):
       return Response('Hello World!')
   
   def error(request):
       raise Exception('Error!')
   
   if __name__ == '__main__':
       with Configurator() as config:
           config.add_route('index', '/')
           config.add_route('error', '/error')
           config.add_view(index, route_name='index')
           config.add_view(error, route_name='error')
   
           app = config.make_wsgi_app()
   
       server = make_server('0.0.0.0', 8000, app)
   
       server.serve_forever()
   ```


----------------------------------------------------------------
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 #102: [Plugin] added pyramid plugin

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



##########
File path: skywalking/plugins/sw_pyramid.py
##########
@@ -0,0 +1,56 @@
+#
+# 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
+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 pyramid.router import Router
+
+    def _sw_invoke_request(self, request, *args, **kwargs):
+        context = get_context()
+        carrier = Carrier()
+
+        for item in carrier:
+            val = request.headers.get(item.key)
+
+            if val is not None:
+                item.val = val
+
+        with context.new_entry_span(op=request.path, carrier=carrier) as span:
+            span.layer = Layer.Http
+            span.component = Component.Pyramid
+            span.peer = request.remote_host or request.remote_addr
+
+            span.tag(Tag(key=tags.HttpMethod, val=request.method))  # pyre-ignore
+            span.tag(Tag(key=tags.HttpUrl, val=str(request.url)))  # pyre-ignore

Review comment:
       *Unused ignore:*  The `pyre-ignore` or `pyre-fixme` comment is not suppressing type errors, please remove it.




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