Skip to content

Commit bc83671

Browse files
authored
chore: polish #92 and minor fix to logs (#97)
1 parent eca37b8 commit bc83671

File tree

5 files changed

+22
-16
lines changed

5 files changed

+22
-16
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
runs-on: ubuntu-latest
2929
strategy:
3030
matrix:
31-
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
31+
python-version: [3.6, 3.7, 3.8, 3.9]
3232
fail-fast: false
3333
env:
3434
SW_PYTHON_VERSION: ${{ matrix.python-version }}
@@ -42,16 +42,12 @@ jobs:
4242
with:
4343
python-version: ${{ matrix.python-version }}
4444
- name: Set up dependencies
45-
if: ${{ matrix.python-version != '3.5' }}
4645
run: make setup install
4746
- name: Lint codes
48-
if: ${{ matrix.python-version != '3.5' }}
4947
run: make lint
5048
- name: Check license header
51-
if: ${{ matrix.python-version != '3.5' }}
5249
run: make license
5350
- name: Run unit tests
54-
if: ${{ matrix.python-version != '3.5' }}
5551
run: make test
5652

5753
CheckStatus:

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ def some_method():
100100
some_other_method()
101101

102102

103+
@trace(op='async_functions_are_also_supported')
104+
async def async_func():
105+
return 'asynchronous'
106+
107+
108+
@trace()
109+
async def async_func2():
110+
return await async_func()
111+
112+
103113
@runnable() # cross thread propagation
104114
def some_method():
105115
some_other_method()

skywalking/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
if TYPE_CHECKING:
2424
from typing import List
2525

26-
RE_IGNORE_PATH = re.compile('^$') # type: 're.Pattern'
26+
RE_IGNORE_PATH = re.compile('^$') # type: re.Pattern
2727

2828
service_name = os.getenv('SW_AGENT_NAME') or 'Python Service Name' # type: str
2929
service_instance = os.getenv('SW_AGENT_INSTANCE') or str(uuid.uuid1()).replace('-', '') # type: str

skywalking/decorators.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ def trace(
3333
def decorator(func):
3434
_op = op or func.__name__
3535
context = get_context()
36+
37+
span = context.new_local_span(op=_op)
38+
span.layer = layer
39+
span.component = component
40+
[span.tag(tag) for tag in tags or []]
41+
3642
if inspect.iscoroutinefunction(func):
3743
@wraps(func)
3844
async def wrapper(*args, **kwargs):
39-
with context.new_local_span(op=_op) as span:
40-
span.layer = layer
41-
span.component = component
42-
[span.tag(tag) for tag in tags or []]
45+
with span:
4346
return await func(*args, **kwargs)
4447
return wrapper
4548

4649
else:
4750
@wraps(func)
4851
def wrapper(*args, **kwargs):
49-
with context.new_local_span(op=_op) as span:
50-
span.layer = layer
51-
span.component = component
52-
[span.tag(tag) for tag in tags or []]
52+
with span:
5353
return func(*args, **kwargs)
5454
return wrapper
5555

skywalking/trace/span.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def raised(self) -> 'Span':
8383

8484
def log(self, ex: Exception) -> 'Span':
8585
self.error_occurred = True
86-
self.logs.append(Log(items=LogItem(key='Traceback', val=str(ex))))
86+
self.logs.append(Log(items=[LogItem(key='Traceback', val=str(ex))]))
8787
return self
8888

8989
def tag(self, tag: Tag) -> 'Span':
@@ -230,7 +230,7 @@ class NoopSpan(Span):
230230
def __init__(self, context: 'SpanContext' = None, kind: 'Kind' = None):
231231
Span.__init__(self, context=context, kind=kind)
232232

233-
def extract(self, carrier: 'Carrier') -> 'Span':
233+
def extract(self, carrier: 'Carrier'):
234234
if carrier is not None:
235235
self.context._correlation = carrier.correlation_carrier.correlation
236236

0 commit comments

Comments
 (0)