Skip to content

Commit da0f28a

Browse files
committed
fix flush
1 parent 101f17d commit da0f28a

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/lmnr/openllmetry_sdk/__init__.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,5 @@ def init(
6767
)
6868

6969
@staticmethod
70-
def flush():
71-
if getattr(TracerManager, "__tracer_wrapper", None):
72-
TracerManager.__tracer_wrapper.flush()
70+
def flush() -> bool:
71+
return TracerManager.__tracer_wrapper.flush()

src/lmnr/openllmetry_sdk/tracing/tracing.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,13 @@ def clear(cls):
236236
cls.__span_id_to_path = {}
237237
cls.__span_id_lists = {}
238238

239-
def flush(self):
239+
def shutdown(self):
240240
self.__spans_processor.force_flush()
241+
self.__spans_processor.shutdown()
242+
self.__tracer_provider.shutdown()
243+
244+
def flush(self):
245+
return self.__spans_processor.force_flush()
241246

242247
def get_tracer(self):
243248
return self.__tracer_provider.get_tracer(TRACER_NAME)

src/lmnr/sdk/laminar.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,16 @@ def deserialize_span_context(
639639
return LaminarSpanContext.deserialize(span_context)
640640

641641
@classmethod
642-
def flush(cls):
643-
TracerManager.flush()
642+
def flush(cls) -> bool:
643+
"""Flush the internal tracer.
644+
645+
Returns:
646+
bool: True if the tracer was flushed, False otherwise
647+
(e.g. no tracer or timeout).
648+
"""
649+
if not cls.is_initialized():
650+
return False
651+
return TracerManager.flush()
644652

645653
@classmethod
646654
def shutdown(cls):

0 commit comments

Comments
 (0)