fix: Improve TracingService initialization logic around deactivated (#5847)

* fix: improve TracingService initialization logic

- Updated the `start` method to remove the check for `self.deactivated`, allowing the service to start even if deactivated.
- Added a check in `initialize_tracers` to return early if the service is deactivated, preventing unnecessary initialization calls.

These changes streamline the service's startup process and ensure that tracer initialization respects the deactivated state.

* [autofix.ci] apply automated fixes

* [autofix.ci] apply automated fixes (attempt 2/3)

* [autofix.ci] apply automated fixes (attempt 3/3)

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Gabriel Luiz Freitas Almeida 2025-01-21 17:38:29 -03:00 committed by GitHub
commit c29e6ad3d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -77,7 +77,7 @@ class TracingService(Service):
self.logs_queue.task_done()
async def start(self) -> None:
if self.running or self.deactivated:
if self.running:
return
try:
self.running = True
@ -112,8 +112,11 @@ class TracingService(Service):
self.outputs_metadata = defaultdict(dict)
async def initialize_tracers(self) -> None:
if self.deactivated:
return
try:
await self.start()
self._initialize_langsmith_tracer()
self._initialize_langwatch_tracer()
self._initialize_langfuse_tracer()