You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2020/12/10 16:39:43 UTC
[skywalking-python] branch polish created (now 241fe08)
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a change to branch polish
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git.
at 241fe08 chore: polish #92 and minor fix to logs
This branch includes the following new commits:
new 241fe08 chore: polish #92 and minor fix to logs
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[skywalking-python] 01/01: chore: polish #92 and minor fix to logs
Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch polish
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git
commit 241fe0820805621f82a1373df498154ca427e3be
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Fri Dec 11 00:39:16 2020 +0800
chore: polish #92 and minor fix to logs
---
skywalking/config.py | 2 +-
skywalking/decorators.py | 16 ++++++++--------
skywalking/trace/span.py | 4 ++--
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/skywalking/config.py b/skywalking/config.py
index e4c4cbe..4ade9a2 100644
--- a/skywalking/config.py
+++ b/skywalking/config.py
@@ -23,7 +23,7 @@ from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import List
-RE_IGNORE_PATH = re.compile('^$') # type: 're.Pattern'
+RE_IGNORE_PATH = re.compile('^$') # type: re.Pattern
service_name = os.getenv('SW_AGENT_NAME') or 'Python Service Name' # type: str
service_instance = os.getenv('SW_AGENT_INSTANCE') or str(uuid.uuid1()).replace('-', '') # type: str
diff --git a/skywalking/decorators.py b/skywalking/decorators.py
index 81c4893..005210f 100644
--- a/skywalking/decorators.py
+++ b/skywalking/decorators.py
@@ -33,23 +33,23 @@ def trace(
def decorator(func):
_op = op or func.__name__
context = get_context()
+
+ span = context.new_local_span(op=_op)
+ span.layer = layer
+ span.component = component
+ [span.tag(tag) for tag in tags or []]
+
if inspect.iscoroutinefunction(func):
@wraps(func)
async def wrapper(*args, **kwargs):
- with context.new_local_span(op=_op) as span:
- span.layer = layer
- span.component = component
- [span.tag(tag) for tag in tags or []]
+ with span:
return await func(*args, **kwargs)
return wrapper
else:
@wraps(func)
def wrapper(*args, **kwargs):
- with context.new_local_span(op=_op) as span:
- span.layer = layer
- span.component = component
- [span.tag(tag) for tag in tags or []]
+ with span:
return func(*args, **kwargs)
return wrapper
diff --git a/skywalking/trace/span.py b/skywalking/trace/span.py
index c193168..24fa0f2 100644
--- a/skywalking/trace/span.py
+++ b/skywalking/trace/span.py
@@ -83,7 +83,7 @@ class Span(ABC):
def log(self, ex: Exception) -> 'Span':
self.error_occurred = True
- self.logs.append(Log(items=LogItem(key='Traceback', val=str(ex))))
+ self.logs.append(Log(items=[LogItem(key='Traceback', val=str(ex))]))
return self
def tag(self, tag: Tag) -> 'Span':
@@ -230,7 +230,7 @@ class NoopSpan(Span):
def __init__(self, context: 'SpanContext' = None, kind: 'Kind' = None):
Span.__init__(self, context=context, kind=kind)
- def extract(self, carrier: 'Carrier') -> 'Span':
+ def extract(self, carrier: 'Carrier'):
if carrier is not None:
self.context._correlation = carrier.correlation_carrier.correlation