You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by to...@apache.org on 2021/06/03 23:22:33 UTC
[skywalking-python] branch master updated: removed incorrect plugin
sw_tornado5.py (#121)
This is an automated email from the ASF dual-hosted git repository.
tompytel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git
The following commit(s) were added to refs/heads/master by this push:
new 54ddace removed incorrect plugin sw_tornado5.py (#121)
54ddace is described below
commit 54ddace0c8daf9fd686816ae61615c772970aec1
Author: Tomasz Pytel <to...@gmail.com>
AuthorDate: Thu Jun 3 20:22:27 2021 -0300
removed incorrect plugin sw_tornado5.py (#121)
---
skywalking/plugins/sw_tornado.py | 2 +-
skywalking/plugins/sw_tornado5.py | 98 ---------------------------------------
2 files changed, 1 insertion(+), 99 deletions(-)
diff --git a/skywalking/plugins/sw_tornado.py b/skywalking/plugins/sw_tornado.py
index 249294f..e3722f5 100644
--- a/skywalking/plugins/sw_tornado.py
+++ b/skywalking/plugins/sw_tornado.py
@@ -25,7 +25,7 @@ from skywalking.trace.tags import Tag
version_rule = {
"name": "tornado",
- "rules": [">=6.0"]
+ "rules": [">=5.0"]
}
diff --git a/skywalking/plugins/sw_tornado5.py b/skywalking/plugins/sw_tornado5.py
deleted file mode 100644
index 1cef308..0000000
--- a/skywalking/plugins/sw_tornado5.py
+++ /dev/null
@@ -1,98 +0,0 @@
-#
-# 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 inspect import iscoroutinefunction, isawaitable
-
-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
-
-version_rule = {
- "name": "tornado",
- "rules": ["<6.0", ">=5.0"]
-}
-
-
-def install():
- from tornado.web import RequestHandler
- old_execute = RequestHandler._execute
- old_log_exception = RequestHandler.log_exception
- RequestHandler._execute = _gen_sw_get_response_func(old_execute)
-
- def _sw_handler_uncaught_exception(self: RequestHandler, ty, value, tb, *args, **kwargs):
- if value is not None:
- entry_span = get_context().active_span()
- if entry_span is not None:
- entry_span.raised()
-
- return old_log_exception(self, ty, value, tb, *args, **kwargs)
-
- RequestHandler.log_exception = _sw_handler_uncaught_exception
-
-
-def _gen_sw_get_response_func(old_execute):
- from tornado.gen import coroutine
-
- awaitable = iscoroutinefunction(old_execute)
- if awaitable:
- # Starting Tornado 5 RequestHandler._execute method is a standard Python coroutine (async/await)
- # In that case our method should be a coroutine function too
- async def _sw_get_response(self, *args, **kwargs):
- request = self.request
- context = get_context()
- carrier = Carrier()
- for item in carrier:
- if item.key.capitalize() in request.headers:
- item.val = request.headers[item.key.capitalize()]
- with context.new_entry_span(op=request.path, carrier=carrier) as span:
- span.layer = Layer.Http
- span.component = Component.Tornado
- span.peer = request.host
- span.tag(Tag(key=tags.HttpMethod, val=request.method))
- span.tag(
- Tag(key=tags.HttpUrl, val='{}://{}{}'.format(request.protocol, request.host, request.path)))
- result = old_execute(self, *args, **kwargs)
- if isawaitable(result):
- result = await result
- span.tag(Tag(key=tags.HttpStatus, val=self._status_code, overridable=True))
- if self._status_code >= 400:
- span.error_occurred = True
- return result
- else:
- @coroutine
- def _sw_get_response(self, *args, **kwargs):
- request = self.request
- context = get_context()
- carrier = Carrier()
- for item in carrier:
- if item.key.capitalize() in request.headers:
- item.val = request.headers[item.key.capitalize()]
- with context.new_entry_span(op=request.path, carrier=carrier) as span:
- span.layer = Layer.Http
- span.component = Component.Tornado
- span.peer = request.host
- span.tag(Tag(key=tags.HttpMethod, val=request.method))
- span.tag(
- Tag(key=tags.HttpUrl, val='{}://{}{}'.format(request.protocol, request.host, request.path)))
- result = yield from old_execute(self, *args, **kwargs)
- span.tag(Tag(key=tags.HttpStatus, val=self._status_code, overridable=True))
- if self._status_code >= 400:
- span.error_occurred = True
- return result
- return _sw_get_response