Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]
fail-fast: false
env:
SW_PYTHON_VERSION: ${{ matrix.python-version }}
Expand All @@ -42,16 +42,12 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Set up dependencies
if: ${{ matrix.python-version != '3.5' }}
run: make setup install
- name: Lint codes
if: ${{ matrix.python-version != '3.5' }}
run: make lint
- name: Check license header
if: ${{ matrix.python-version != '3.5' }}
run: make license
- name: Run unit tests
if: ${{ matrix.python-version != '3.5' }}
run: make test

CheckStatus:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ def some_method():
some_other_method()


@trace(op='async_functions_are_also_supported')
async def async_func():
return 'asynchronous'


@trace()
async def async_func2():
return await async_func()


@runnable() # cross thread propagation
def some_method():
some_other_method()
Expand Down
2 changes: 1 addition & 1 deletion skywalking/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
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
Expand Down
16 changes: 8 additions & 8 deletions skywalking/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions skywalking/trace/span.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def raised(self) -> 'Span':

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':
Expand Down Expand Up @@ -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

Expand Down