From 723c5ad01e1b269c44831675091d9afba70bebb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lipovsk=C3=BD?= Date: Thu, 1 Feb 2024 16:16:03 +0100 Subject: [PATCH] Fixing logging in tracing.py [CLOUDDST-21024] --- iib/common/tracing.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/iib/common/tracing.py b/iib/common/tracing.py index b4531cd05..494168fe9 100644 --- a/iib/common/tracing.py +++ b/iib/common/tracing.py @@ -35,6 +35,7 @@ def func(): log = logging.getLogger(__name__) +log.setLevel(logging.DEBUG) propagator = TraceContextTextMapPropagator() @@ -81,31 +82,30 @@ def __new__(cls): def instrument_tracing( - func=None, span_name: str = '', attributes: Dict = {}, ): """ Instrument tracing for a function. - :param func: The function to be decorated. :param span_name: The name of the span to be created. :param attributes: The attributes to be added to the span. :return: The decorated function or class. """ - log.info('Instrumenting span for %s', span_name) - tracer = trace.get_tracer(__name__) - context = None - if trace.get_current_span(): - context = trace.get_current_span().get_span_context() - else: - context = propagator.extract(carrier={}) def decorator_instrument_tracing(func): @functools.wraps(func) def wrapper(*args, **kwargs): if not os.getenv('IIB_OTEL_TRACING', '').lower() == 'true': return func(*args, **kwargs) + + log.info('Instrumenting span for %s', span_name) + tracer = trace.get_tracer(__name__) + if trace.get_current_span(): + context = trace.get_current_span().get_span_context() + else: + context = propagator.extract(carrier={}) + log.debug('Context inside %s: %s', span_name, context) if kwargs.get('traceparent'): log.debug('traceparent is %s' % str(kwargs.get('traceparent')))