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/14 00:04:42 UTC
[skywalking-python] branch master updated: [Enhancement] add tags
to decorators (#65)
This is an automated email from the ASF dual-hosted git repository.
kezhenxu94 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking-python.git
The following commit(s) were added to refs/heads/master by this push:
new 2ae7fa5 [Enhancement] add tags to decorators (#65)
2ae7fa5 is described below
commit 2ae7fa5043a78b6bb7b7762d3f0ffdafdbada56b
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Fri Aug 14 08:04:36 2020 +0800
[Enhancement] add tags to decorators (#65)
---
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: