Skip to content

Commit 723c5ad

Browse files
committed
Fixing logging in tracing.py
[CLOUDDST-21024]
1 parent 60d8359 commit 723c5ad

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

iib/common/tracing.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def func():
3535

3636

3737
log = logging.getLogger(__name__)
38+
log.setLevel(logging.DEBUG)
3839
propagator = TraceContextTextMapPropagator()
3940

4041

@@ -81,31 +82,30 @@ def __new__(cls):
8182

8283

8384
def instrument_tracing(
84-
func=None,
8585
span_name: str = '',
8686
attributes: Dict = {},
8787
):
8888
"""
8989
Instrument tracing for a function.
9090
91-
:param func: The function to be decorated.
9291
:param span_name: The name of the span to be created.
9392
:param attributes: The attributes to be added to the span.
9493
:return: The decorated function or class.
9594
"""
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={})
10395

10496
def decorator_instrument_tracing(func):
10597
@functools.wraps(func)
10698
def wrapper(*args, **kwargs):
10799
if not os.getenv('IIB_OTEL_TRACING', '').lower() == 'true':
108100
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+
109109
log.debug('Context inside %s: %s', span_name, context)
110110
if kwargs.get('traceparent'):
111111
log.debug('traceparent is %s' % str(kwargs.get('traceparent')))

0 commit comments

Comments
 (0)