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/08/13 14:09:48 UTC
[skywalking-python] 01/01: [Enhancement] add tags to decorators
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch decorator/tag
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git
commit 0e25c52d33c3024abbcb9926c2a0b14cfa4a4560
Author: kezhenxu94 <ke...@163.com>
AuthorDate: Thu Aug 13 22:09:20 2020 +0800
[Enhancement] add tags to decorators
---
skywalking/decorators.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/skywalking/decorators.py b/skywalking/decorators.py
index efd4baf..a48e057 100644
--- a/skywalking/decorators.py
+++ b/skywalking/decorators.py
@@ -16,15 +16,18 @@
#
from functools import wraps
+from typing import List
from skywalking import Layer, Component
from skywalking.trace.context import get_context
+from skywalking.trace.tags import Tag
def trace(
op: str = None,
layer: Layer = Layer.Unknown,
component: Component = Component.Unknown,
+ tags: List[Tag] = None,
):
def decorator(func):
@wraps(func)
@@ -34,6 +37,7 @@ def trace(
with context.new_local_span(op=_op) as span:
span.layer = layer
span.component = component
+ [span.tag(tag) for tag in tags or []]
try:
result = func(*args, **kwargs)
return result
@@ -50,6 +54,7 @@ def runnable(
op: str = None,
layer: Layer = Layer.Unknown,
component: Component = Component.Unknown,
+ tags: List[Tag] = None,
):
def decorator(func):
snapshot = get_context().capture()
@@ -62,6 +67,7 @@ def runnable(
context.continued(snapshot)
span.layer = layer
span.component = component
+ [span.tag(tag) for tag in tags or []]
try:
func(*args, **kwargs)
except Exception: