in skywalking/decorators.py [0:0]
def decorator(func):
_op = op or func.__name__
if inspect.iscoroutinefunction(func):
@wraps(func)
async def wrapper(*args, **kwargs):
context = get_context()
span = context.new_local_span(op=_op)
span.layer = layer
span.component = component
if tags:
for tag in tags:
span.tag(tag)
with span:
return await func(*args, **kwargs)
return wrapper
else:
@wraps(func)
def wrapper(*args, **kwargs):
context = get_context()
span = context.new_local_span(op=_op)
span.layer = layer
span.component = component
if tags:
for tag in tags:
span.tag(tag)
with span:
return func(*args, **kwargs)
return wrapper