@@ -35,6 +35,7 @@ def func():
35
35
36
36
37
37
log = logging .getLogger (__name__ )
38
+ log .setLevel (logging .DEBUG )
38
39
propagator = TraceContextTextMapPropagator ()
39
40
40
41
@@ -81,31 +82,30 @@ def __new__(cls):
81
82
82
83
83
84
def instrument_tracing (
84
- func = None ,
85
85
span_name : str = '' ,
86
86
attributes : Dict = {},
87
87
):
88
88
"""
89
89
Instrument tracing for a function.
90
90
91
- :param func: The function to be decorated.
92
91
:param span_name: The name of the span to be created.
93
92
:param attributes: The attributes to be added to the span.
94
93
:return: The decorated function or class.
95
94
"""
96
- log .info ('Instrumenting span for %s' , span_name )
97
- tracer = trace .get_tracer (__name__ )
98
- context = None
99
- if trace .get_current_span ():
100
- context = trace .get_current_span ().get_span_context ()
101
- else :
102
- context = propagator .extract (carrier = {})
103
95
104
96
def decorator_instrument_tracing (func ):
105
97
@functools .wraps (func )
106
98
def wrapper (* args , ** kwargs ):
107
99
if not os .getenv ('IIB_OTEL_TRACING' , '' ).lower () == 'true' :
108
100
return func (* args , ** kwargs )
101
+
102
+ log .info ('Instrumenting span for %s' , span_name )
103
+ tracer = trace .get_tracer (__name__ )
104
+ if trace .get_current_span ():
105
+ context = trace .get_current_span ().get_span_context ()
106
+ else :
107
+ context = propagator .extract (carrier = {})
108
+
109
109
log .debug ('Context inside %s: %s' , span_name , context )
110
110
if kwargs .get ('traceparent' ):
111
111
log .debug ('traceparent is %s' % str (kwargs .get ('traceparent' )))
0 commit comments